Mercurial > dwm-meillo
comparison wm.c @ 9:d567f430a81d
fixed several stuff (gridwm gets better and better)
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 12:52:57 +0200 |
parents | 7066ff2fe8bc |
children | 703255003abb |
comparison
equal
deleted
inserted
replaced
8:7066ff2fe8bc | 9:d567f430a81d |
---|---|
14 #include "wm.h" | 14 #include "wm.h" |
15 | 15 |
16 /* X structs */ | 16 /* X structs */ |
17 Display *dpy; | 17 Display *dpy; |
18 Window root, barwin; | 18 Window root, barwin; |
19 Atom wm_atom[WMLast], net_atom[NetLast]; | 19 Atom net_atom[NetLast]; |
20 Cursor cursor[CurLast]; | 20 Cursor cursor[CurLast]; |
21 XRectangle rect, barrect; | 21 XRectangle rect, barrect; |
22 Bool running = True; | 22 Bool running = True; |
23 Client *client = NULL; | 23 Client *clients = NULL; |
24 | 24 |
25 char *bartext, tag[256]; | 25 char *bartext, tag[256]; |
26 int screen, sel_screen; | 26 int screen, sel_screen; |
27 | 27 |
28 /* draw structs */ | 28 /* draw structs */ |
59 manage(create_client(wins[i], &wa)); | 59 manage(create_client(wins[i], &wa)); |
60 } | 60 } |
61 } | 61 } |
62 if(wins) | 62 if(wins) |
63 XFree(wins); | 63 XFree(wins); |
64 } | |
65 | |
66 static int | |
67 win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) | |
68 { | |
69 Atom real; | |
70 int format; | |
71 unsigned long res, extra; | |
72 int status; | |
73 | |
74 status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format, | |
75 &res, &extra, prop); | |
76 | |
77 if(status != Success || *prop == NULL) { | |
78 return 0; | |
79 } | |
80 if(res == 0) | |
81 free((void *) *prop); | |
82 return res; | |
83 } | |
84 | |
85 int | |
86 win_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 } | 64 } |
105 | 65 |
106 /* | 66 /* |
107 * There's no way to check accesses to destroyed windows, thus | 67 * There's no way to check accesses to destroyed windows, thus |
108 * those cases are ignored (especially on UnmapNotify's). | 68 * those cases are ignored (especially on UnmapNotify's). |
199 | 159 |
200 XSetErrorHandler(0); | 160 XSetErrorHandler(0); |
201 x_error_handler = XSetErrorHandler(error_handler); | 161 x_error_handler = XSetErrorHandler(error_handler); |
202 | 162 |
203 /* init atoms */ | 163 /* init atoms */ |
204 wm_atom[WMState] = XInternAtom(dpy, "WM_STATE", False); | |
205 wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); | |
206 wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); | |
207 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); | 164 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); |
208 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); | 165 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); |
209 | 166 |
210 XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32, | 167 XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32, |
211 PropModeReplace, (unsigned char *) net_atom, NetLast); | 168 PropModeReplace, (unsigned char *) net_atom, NetLast); |
240 bartext = NULL; | 197 bartext = NULL; |
241 XDefineCursor(dpy, barwin, cursor[CurNormal]); | 198 XDefineCursor(dpy, barwin, cursor[CurNormal]); |
242 XMapRaised(dpy, barwin); | 199 XMapRaised(dpy, barwin); |
243 draw_bar(); | 200 draw_bar(); |
244 | 201 |
245 wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; | 202 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ |
203 | LeaveWindowMask; | |
246 wa.cursor = cursor[CurNormal]; | 204 wa.cursor = cursor[CurNormal]; |
247 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | 205 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
248 | 206 |
249 scan_wins(); | 207 scan_wins(); |
250 | 208 |