1 /* command.c - WindowMaker commands
2  *
3  * WMlib - WindowMaker application programming interface
4  *
5  * Copyright (C) 1997-2003 Alfredo K. Kojima
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Library General Public
9  *  License as published by the Free Software Foundation; either
10  *  version 2 of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Library General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Library General Public
18  *  License along with this library; if not, write to the Free
19  *  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20  *  MA 02110-1301, USA.
21  */
22 
23 #include <X11/Xlib.h>
24 #include <stdlib.h>
25 
26 #include "WMaker.h"
27 #include "app.h"
28 
getwmfunc(Display * dpy)29 static Atom getwmfunc(Display * dpy)
30 {
31 	return XInternAtom(dpy, "_WINDOWMAKER_WM_FUNCTION", False);
32 }
33 
WMHideApplication(WMAppContext * app)34 void WMHideApplication(WMAppContext * app)
35 {
36 	XEvent event;
37 
38 	event.xclient.type = ClientMessage;
39 	event.xclient.message_type = getwmfunc(app->dpy);
40 	event.xclient.format = 32;
41 	event.xclient.display = app->dpy;
42 	event.xclient.window = app->main_window;
43 	event.xclient.data.l[0] = WMFHideApplication;
44 	event.xclient.data.l[1] = 0;
45 	event.xclient.data.l[2] = 0;
46 	event.xclient.data.l[3] = 0;
47 	XSendEvent(app->dpy, RootWindow(app->dpy, app->screen_number), False,
48 		   SubstructureNotifyMask | SubstructureRedirectMask, &event);
49 }
50 
WMHideOthers(WMAppContext * app)51 void WMHideOthers(WMAppContext * app)
52 {
53 	XEvent event;
54 
55 	event.xclient.type = ClientMessage;
56 	event.xclient.message_type = getwmfunc(app->dpy);
57 	event.xclient.format = 32;
58 	event.xclient.display = app->dpy;
59 	event.xclient.window = app->main_window;
60 	event.xclient.data.l[0] = WMFHideOtherApplications;
61 	event.xclient.data.l[1] = 0;
62 	event.xclient.data.l[2] = 0;
63 	event.xclient.data.l[3] = 0;
64 	XSendEvent(app->dpy, RootWindow(app->dpy, app->screen_number), False,
65 		   SubstructureNotifyMask | SubstructureRedirectMask, &event);
66 }
67 
WMSetWindowAttributes(Display * dpy,Window window,GNUstepWMAttributes * attributes)68 void WMSetWindowAttributes(Display * dpy, Window window, GNUstepWMAttributes * attributes)
69 {
70 	Atom atom;
71 
72 	atom = XInternAtom(dpy, "_GNUSTEP_WM_ATTR", False);
73 	XChangeProperty(dpy, window, atom, atom, 32, PropModeReplace,
74 			(unsigned char *)attributes, sizeof(GNUstepWMAttributes) / sizeof(CARD32));
75 }
76