1 /* -*-c-*- */
2 /* Copyright (C) 2001  Dominik Vogt */
3 /* This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see: <http://www.gnu.org/licenses/>
15  */
16 
17 #include "config.h"
18 #include <X11/Xlib.h>
19 #include <stdio.h>
20 #include "fvwmlib.h"
21 #include "Event.h"
22 
23 /*
24  * Return the subwindow member of an event if the event type has one.
25  */
GetSubwindowFromEvent(Display * dpy,const XEvent * eventp)26 Window GetSubwindowFromEvent(Display *dpy, const XEvent *eventp)
27 {
28 	if (eventp == NULL)
29 	{
30 		return None;
31 	}
32 	switch (eventp->type)
33 	{
34 	case ButtonPress:
35 	case ButtonRelease:
36 		return eventp->xbutton.subwindow;
37 	case KeyPress:
38 	case KeyRelease:
39 		return eventp->xkey.subwindow;
40 	case EnterNotify:
41 	case LeaveNotify:
42 		return eventp->xcrossing.subwindow;
43 	case MotionNotify:
44 		return eventp->xmotion.subwindow;
45 	default:
46 		return None;
47 	}
48 }
49