Mercurial > dwm-meillo
annotate wm.c @ 30:2e0fb4130bfb
new stuff, fixed several issues
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Wed, 12 Jul 2006 17:50:31 +0200 |
parents | f96fb3fd8203 |
children | 386649deb651 |
rev | line source |
---|---|
0 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * See LICENSE file for license details. | |
4 */ | |
5 | |
14 | 6 #include <errno.h> |
7 | |
0 | 8 #include <stdarg.h> |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 | |
14 | 12 #include <sys/types.h> |
13 #include <sys/time.h> | |
14 | |
0 | 15 #include <X11/cursorfont.h> |
16 #include <X11/Xatom.h> | |
17 #include <X11/Xproto.h> | |
18 | |
19 #include "wm.h" | |
20 | |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
21 /* X structs */ |
0 | 22 Display *dpy; |
5 | 23 Window root, barwin; |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
24 Atom wm_atom[WMLast], net_atom[NetLast]; |
0 | 25 Cursor cursor[CurLast]; |
5 | 26 Bool running = True; |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
27 Bool sel_screen; |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
28 |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
29 char statustext[1024], tag[256]; |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
30 int screen, sx, sy, sw, sh, bx, by, bw, bh; |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
31 |
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
32 Brush brush = {0}; |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
33 Client *clients = NULL; |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
34 Client *stack = NULL; |
0 | 35 |
36 static Bool other_wm_running; | |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
37 static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; |
0 | 38 static int (*x_error_handler) (Display *, XErrorEvent *); |
39 | |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
40 static const char *status[] = { |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
41 "sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
42 " `uptime | sed 's/.*://; s/,//g'`" |
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
43 " `acpi | awk '{print $4}' | sed 's/,//'`", 0 |
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
44 }; |
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
45 |
0 | 46 static void |
47 usage() | |
48 { | |
49 fputs("usage: gridwm [-v]\n", stderr); | |
50 exit(1); | |
51 } | |
52 | |
53 static void | |
54 scan_wins() | |
55 { | |
56 unsigned int i, num; | |
57 Window *wins; | |
58 XWindowAttributes wa; | |
59 Window d1, d2; | |
60 | |
61 if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { | |
62 for(i = 0; i < num; i++) { | |
63 if(!XGetWindowAttributes(dpy, wins[i], &wa)) | |
64 continue; | |
65 if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) | |
66 continue; | |
67 if(wa.map_state == IsViewable) | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
68 manage(wins[i], &wa); |
0 | 69 } |
70 } | |
71 if(wins) | |
72 XFree(wins); | |
73 } | |
74 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
75 static int |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
76 win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
77 { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
78 Atom real; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
79 int format; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
80 unsigned long res, extra; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
81 int status; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
82 |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
83 status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format, |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
84 &res, &extra, prop); |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
85 |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
86 if(status != Success || *prop == 0) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
87 return 0; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
88 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
89 if(res == 0) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
90 free((void *) *prop); |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
91 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
92 return res; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
93 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
94 |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
95 int |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
96 win_proto(Window w) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
97 { |
30
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
27
diff
changeset
|
98 unsigned char *protocols; |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
99 long res; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
100 int protos = 0; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
101 int i; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
102 |
30
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
27
diff
changeset
|
103 res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L, &protocols); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
104 if(res <= 0) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
105 return protos; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
106 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
107 for(i = 0; i < res; i++) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
108 if(protocols[i] == wm_atom[WMDelete]) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
109 protos |= WM_PROTOCOL_DELWIN; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
110 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
111 free((char *) protocols); |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
112 return protos; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
113 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
114 |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
115 void |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
116 send_message(Window w, Atom a, long value) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
117 { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
118 XEvent e; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
119 |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
120 e.type = ClientMessage; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
121 e.xclient.window = w; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
122 e.xclient.message_type = a; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
123 e.xclient.format = 32; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
124 e.xclient.data.l[0] = value; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
125 e.xclient.data.l[1] = CurrentTime; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
126 XSendEvent(dpy, w, False, NoEventMask, &e); |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
127 XFlush(dpy); |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
128 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
129 |
0 | 130 /* |
131 * There's no way to check accesses to destroyed windows, thus | |
132 * those cases are ignored (especially on UnmapNotify's). | |
133 * Other types of errors call Xlib's default error handler, which | |
134 * calls exit(). | |
135 */ | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
136 int |
0 | 137 error_handler(Display *dpy, XErrorEvent *error) |
138 { | |
139 if(error->error_code == BadWindow | |
140 || (error->request_code == X_SetInputFocus | |
141 && error->error_code == BadMatch) | |
142 || (error->request_code == X_PolyText8 | |
143 && error->error_code == BadDrawable) | |
144 || (error->request_code == X_PolyFillRectangle | |
145 && error->error_code == BadDrawable) | |
146 || (error->request_code == X_PolySegment | |
147 && error->error_code == BadDrawable) | |
148 || (error->request_code == X_ConfigureWindow | |
149 && error->error_code == BadMatch) | |
150 || (error->request_code == X_GrabKey | |
151 && error->error_code == BadAccess)) | |
152 return 0; | |
153 fprintf(stderr, "gridwm: fatal error: request code=%d, error code=%d\n", | |
154 error->request_code, error->error_code); | |
155 return x_error_handler(dpy, error); /* may call exit() */ | |
156 } | |
157 | |
158 /* | |
159 * Startup Error handler to check if another window manager | |
160 * is already running. | |
161 */ | |
162 static int | |
163 startup_error_handler(Display *dpy, XErrorEvent *error) | |
164 { | |
165 other_wm_running = True; | |
166 return -1; | |
167 } | |
168 | |
169 static void | |
170 cleanup() | |
171 { | |
14 | 172 while(clients) |
173 unmanage(clients); | |
0 | 174 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); |
175 } | |
176 | |
27
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
177 void |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
178 run(void *aux) |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
179 { |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
180 spawn(dpy, aux); |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
181 } |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
182 |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
183 void |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
184 quit(void *aux) |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
185 { |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
186 running = False; |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
187 } |
f96fb3fd8203
added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents:
26
diff
changeset
|
188 |
0 | 189 int |
190 main(int argc, char *argv[]) | |
191 { | |
192 int i; | |
193 XSetWindowAttributes wa; | |
194 unsigned int mask; | |
195 Window w; | |
5 | 196 XEvent ev; |
14 | 197 fd_set fds; |
198 struct timeval t, timeout = { | |
199 .tv_usec = 0, | |
200 .tv_sec = STATUSDELAY, | |
201 }; | |
0 | 202 |
203 /* command line args */ | |
204 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { | |
205 switch (argv[i][1]) { | |
206 case 'v': | |
207 fprintf(stdout, "%s", version); | |
208 exit(0); | |
209 break; | |
210 default: | |
211 usage(); | |
212 break; | |
213 } | |
214 } | |
215 | |
216 dpy = XOpenDisplay(0); | |
217 if(!dpy) | |
218 error("gridwm: cannot connect X server\n"); | |
219 | |
220 screen = DefaultScreen(dpy); | |
221 root = RootWindow(dpy, screen); | |
222 | |
223 /* check if another WM is already running */ | |
224 other_wm_running = False; | |
225 XSetErrorHandler(startup_error_handler); | |
226 /* this causes an error if some other WM is running */ | |
227 XSelectInput(dpy, root, SubstructureRedirectMask); | |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
228 XFlush(dpy); |
0 | 229 |
230 if(other_wm_running) | |
231 error("gridwm: another window manager is already running\n"); | |
232 | |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
233 sx = sy = 0; |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
234 sw = DisplayWidth(dpy, screen); |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
235 sh = DisplayHeight(dpy, screen); |
0 | 236 sel_screen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
237 | |
238 XSetErrorHandler(0); | |
239 x_error_handler = XSetErrorHandler(error_handler); | |
240 | |
241 /* init atoms */ | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
242 wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
243 wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
0 | 244 net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); |
245 net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); | |
246 | |
247 XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32, | |
248 PropModeReplace, (unsigned char *) net_atom, NetLast); | |
249 | |
250 | |
251 /* init cursors */ | |
252 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); | |
253 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); | |
254 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); | |
255 | |
8 | 256 update_keys(); |
0 | 257 |
5 | 258 /* style */ |
259 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); | |
260 loadfont(dpy, &brush.font, FONT); | |
261 | |
262 wa.override_redirect = 1; | |
263 wa.background_pixmap = ParentRelative; | |
264 wa.event_mask = ExposureMask; | |
265 | |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
266 bx = by = 0; |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
267 bw = sw; |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
268 bh = texth(&brush.font); |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
269 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), |
5 | 270 CopyFromParent, DefaultVisual(dpy, screen), |
271 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); | |
272 XDefineCursor(dpy, barwin, cursor[CurNormal]); | |
273 XMapRaised(dpy, barwin); | |
21
3ef108a5ca0a
implemented draw_client stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
274 |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
21
diff
changeset
|
275 brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); |
21
3ef108a5ca0a
implemented draw_client stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
276 brush.gc = XCreateGC(dpy, root, 0, 0); |
3ef108a5ca0a
implemented draw_client stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
277 |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
278 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); |
5 | 279 draw_bar(); |
0 | 280 |
9
d567f430a81d
fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents:
8
diff
changeset
|
281 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ |
d567f430a81d
fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents:
8
diff
changeset
|
282 | LeaveWindowMask; |
0 | 283 wa.cursor = cursor[CurNormal]; |
284 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | |
285 | |
5 | 286 scan_wins(); |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
287 |
5 | 288 while(running) { |
14 | 289 if(XPending(dpy) > 0) { |
290 XNextEvent(dpy, &ev); | |
291 if(handler[ev.type]) | |
292 (handler[ev.type]) (&ev); /* call handler */ | |
293 continue; | |
294 } | |
295 FD_ZERO(&fds); | |
296 FD_SET(ConnectionNumber(dpy), &fds); | |
297 t = timeout; | |
298 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0) | |
299 continue; | |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
300 else if(errno != EINTR) { |
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
301 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); |
14 | 302 draw_bar(); |
16
359b6e563b95
several changes, new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
14
diff
changeset
|
303 } |
5 | 304 } |
0 | 305 |
306 cleanup(); | |
307 XCloseDisplay(dpy); | |
308 | |
309 return 0; | |
310 } |