Change to the linux kernel coding style
[wmaker-crm.git] / wmlib / command.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001/* command.c - WindowMaker commands
6830b057 dan2004-10-12 21:28:27 +00002 *
9d2e6ef9 scottc1998-09-29 22:36:29 +00003 * WMlib - WindowMaker application programming interface
6830b057 dan2004-10-12 21:28:27 +00004 *
4153e2fd dan2003-01-16 23:30:45 +00005 * Copyright (C) 1997-2003 Alfredo K. Kojima
6830b057 dan2004-10-12 21:28:27 +00006 *
9d2e6ef9 scottc1998-09-29 22:36:29 +00007 * 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.
6830b057 dan2004-10-12 21:28:27 +000011 *
9d2e6ef9 scottc1998-09-29 22:36:29 +000012 * 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.
6830b057 dan2004-10-12 21:28:27 +000016 *
9d2e6ef9 scottc1998-09-29 22:36:29 +000017 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <X11/Xlib.h>
23#include <stdlib.h>
24
25#include "WMaker.h"
26#include "app.h"
27
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020028static Atom getwmfunc(Display * dpy)
9d2e6ef9 scottc1998-09-29 22:36:29 +000029{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020030 return XInternAtom(dpy, "_WINDOWMAKER_WM_FUNCTION", False);
9d2e6ef9 scottc1998-09-29 22:36:29 +000031}
32
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020033void WMHideApplication(WMAppContext * app)
9d2e6ef9 scottc1998-09-29 22:36:29 +000034{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020035 XEvent event;
9d2e6ef9 scottc1998-09-29 22:36:29 +000036
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020037 event.xclient.type = ClientMessage;
38 event.xclient.message_type = getwmfunc(app->dpy);
39 event.xclient.format = 32;
40 event.xclient.display = app->dpy;
41 event.xclient.window = app->main_window;
42 event.xclient.data.l[0] = WMFHideApplication;
43 event.xclient.data.l[1] = 0;
44 event.xclient.data.l[2] = 0;
45 event.xclient.data.l[3] = 0;
46 XSendEvent(app->dpy, RootWindow(app->dpy, app->screen_number), False,
47 SubstructureNotifyMask | SubstructureRedirectMask, &event);
9d2e6ef9 scottc1998-09-29 22:36:29 +000048}
49
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020050void WMHideOthers(WMAppContext * app)
9d2e6ef9 scottc1998-09-29 22:36:29 +000051{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020052 XEvent event;
9d2e6ef9 scottc1998-09-29 22:36:29 +000053
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020054 event.xclient.type = ClientMessage;
55 event.xclient.message_type = getwmfunc(app->dpy);
56 event.xclient.format = 32;
57 event.xclient.display = app->dpy;
58 event.xclient.window = app->main_window;
59 event.xclient.data.l[0] = WMFHideOtherApplications;
60 event.xclient.data.l[1] = 0;
61 event.xclient.data.l[2] = 0;
62 event.xclient.data.l[3] = 0;
63 XSendEvent(app->dpy, RootWindow(app->dpy, app->screen_number), False,
64 SubstructureNotifyMask | SubstructureRedirectMask, &event);
9d2e6ef9 scottc1998-09-29 22:36:29 +000065}
66
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020067void WMSetWindowAttributes(Display * dpy, Window window, GNUstepWMAttributes * attributes)
9d2e6ef9 scottc1998-09-29 22:36:29 +000068{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020069 Atom atom;
6830b057 dan2004-10-12 21:28:27 +000070
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020071 atom = XInternAtom(dpy, "_GNUSTEP_WM_ATTR", False);
72 XChangeProperty(dpy, window, atom, atom, 32, PropModeReplace,
73 (unsigned char *)attributes, sizeof(GNUstepWMAttributes) / sizeof(CARD32));
9d2e6ef9 scottc1998-09-29 22:36:29 +000074}