comparison wm.c @ 14:5c078b66347b

added bar event timer
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 18:15:11 +0200
parents 5cc5e55a132d
children 359b6e563b95
comparison
equal deleted inserted replaced
13:5cc5e55a132d 14:5c078b66347b
1 /* 1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5 5
6 #include <errno.h>
7
6 #include <stdarg.h> 8 #include <stdarg.h>
7 #include <stdio.h> 9 #include <stdio.h>
8 #include <stdlib.h> 10 #include <stdlib.h>
11
12 #include <sys/types.h>
13 #include <sys/time.h>
9 14
10 #include <X11/cursorfont.h> 15 #include <X11/cursorfont.h>
11 #include <X11/Xatom.h> 16 #include <X11/Xatom.h>
12 #include <X11/Xproto.h> 17 #include <X11/Xproto.h>
13 18
158 } 163 }
159 164
160 static void 165 static void
161 cleanup() 166 cleanup()
162 { 167 {
163 /* 168 while(clients)
164 Client *c; 169 unmanage(clients);
165 for(c=client; c; c=c->next)
166 reparent_client(c, root, c->sel->rect.x, c->sel->rect.y);
167 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); 170 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
168 */
169 } 171 }
170 172
171 int 173 int
172 main(int argc, char *argv[]) 174 main(int argc, char *argv[])
173 { 175 {
174 int i; 176 int i;
175 XSetWindowAttributes wa; 177 XSetWindowAttributes wa;
176 unsigned int mask; 178 unsigned int mask;
177 Window w; 179 Window w;
178 XEvent ev; 180 XEvent ev;
181 fd_set fds;
182 struct timeval t, timeout = {
183 .tv_usec = 0,
184 .tv_sec = STATUSDELAY,
185 };
179 186
180 /* command line args */ 187 /* command line args */
181 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { 188 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
182 switch (argv[i][1]) { 189 switch (argv[i][1]) {
183 case 'v': 190 case 'v':
262 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); 269 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
263 270
264 scan_wins(); 271 scan_wins();
265 272
266 while(running) { 273 while(running) {
267 XNextEvent(dpy, &ev); 274 if(XPending(dpy) > 0) {
268 if(handler[ev.type]) 275 XNextEvent(dpy, &ev);
269 (handler[ev.type]) (&ev); /* call handler */ 276 if(handler[ev.type])
277 (handler[ev.type]) (&ev); /* call handler */
278 continue;
279 }
280 FD_ZERO(&fds);
281 FD_SET(ConnectionNumber(dpy), &fds);
282 t = timeout;
283 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
284 continue;
285 else if(errno != EINTR)
286 draw_bar();
270 } 287 }
271 288
272 cleanup(); 289 cleanup();
273 XCloseDisplay(dpy); 290 XCloseDisplay(dpy);
274 291