summaryrefslogtreecommitdiffstats
path: root/wm.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 16:14:22 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 16:14:22 +0200
commit33996500763b04119a6867dfa4040a4236c21a41 (patch)
tree7abc832f02c0478dd9b8e339c3ee7874d1bb7787 /wm.c
parentnew stuff (diff)
downloaddwm-33996500763b04119a6867dfa4040a4236c21a41.tar.gz
dwm-33996500763b04119a6867dfa4040a4236c21a41.zip
added protocol killing stuff
Diffstat (limited to '')
-rw-r--r--wm.c66
1 files changed, 62 insertions, 4 deletions
diff --git a/wm.c b/wm.c
index ef4721d..b156cba 100644
--- a/wm.c
+++ b/wm.c
@@ -16,18 +16,18 @@
16/* X structs */ 16/* X structs */
17Display *dpy; 17Display *dpy;
18Window root, barwin; 18Window root, barwin;
19Atom net_atom[NetLast]; 19Atom wm_atom[WMLast], net_atom[NetLast];
20Cursor cursor[CurLast]; 20Cursor cursor[CurLast];
21XRectangle rect, barrect; 21XRectangle rect, barrect;
22Bool running = True; 22Bool running = True;
23Bool sel_screen;
23 24
24char *bartext, tag[256]; 25char *bartext, tag[256];
25int screen, sel_screen; 26int screen;
26 27
27Brush brush = {0}; 28Brush brush = {0};
28Client *clients = NULL; 29Client *clients = NULL;
29 30Client *stack = NULL;
30enum { WM_PROTOCOL_DELWIN = 1 };
31 31
32static Bool other_wm_running; 32static Bool other_wm_running;
33static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 33static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
@@ -62,6 +62,62 @@ scan_wins()
62 XFree(wins); 62 XFree(wins);
63} 63}
64 64
65static int
66win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
67{
68 Atom real;
69 int format;
70 unsigned long res, extra;
71 int status;
72
73 status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
74 &res, &extra, prop);
75
76 if(status != Success || *prop == 0) {
77 return 0;
78 }
79 if(res == 0) {
80 free((void *) *prop);
81 }
82 return res;
83}
84
85int
86win_proto(Window w)
87{
88 Atom *protocols;
89 long res;
90 int protos = 0;
91 int i;
92
93 res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L,
94 ((unsigned char **) &protocols));
95 if(res <= 0) {
96 return protos;
97 }
98 for(i = 0; i < res; i++) {
99 if(protocols[i] == wm_atom[WMDelete])
100 protos |= WM_PROTOCOL_DELWIN;
101 }
102 free((char *) protocols);
103 return protos;
104}
105
106void
107send_message(Window w, Atom a, long value)
108{
109 XEvent e;
110
111 e.type = ClientMessage;
112 e.xclient.window = w;
113 e.xclient.message_type = a;
114 e.xclient.format = 32;
115 e.xclient.data.l[0] = value;
116 e.xclient.data.l[1] = CurrentTime;
117 XSendEvent(dpy, w, False, NoEventMask, &e);
118 XFlush(dpy);
119}
120
65/* 121/*
66 * There's no way to check accesses to destroyed windows, thus 122 * There's no way to check accesses to destroyed windows, thus
67 * those cases are ignored (especially on UnmapNotify's). 123 * those cases are ignored (especially on UnmapNotify's).
@@ -160,6 +216,8 @@ main(int argc, char *argv[])
160 x_error_handler = XSetErrorHandler(error_handler); 216 x_error_handler = XSetErrorHandler(error_handler);
161 217
162 /* init atoms */ 218 /* init atoms */
219 wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
220 wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
163 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); 221 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
164 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); 222 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
165 223