about summary refs log tree commit diff stats
path: root/wm.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 18:15:11 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 18:15:11 +0200
commit586f66331d1105be03c42e6faeae1672b974a98a (patch)
treeb5a4f654969baf431ac0f10dad2354d70e7efc2b /wm.c
parent33996500763b04119a6867dfa4040a4236c21a41 (diff)
downloaddwm-586f66331d1105be03c42e6faeae1672b974a98a.tar.gz
added bar event timer
Diffstat (limited to 'wm.c')
-rw-r--r--wm.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/wm.c b/wm.c
index b156cba..f247372 100644
--- a/wm.c
+++ b/wm.c
@@ -3,10 +3,15 @@
  * See LICENSE file for license details.
  */
 
+#include <errno.h>
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <sys/types.h>
+#include <sys/time.h>
+
 #include <X11/cursorfont.h>
 #include <X11/Xatom.h>
 #include <X11/Xproto.h>
@@ -160,12 +165,9 @@ startup_error_handler(Display *dpy, XErrorEvent *error)
 static void
 cleanup()
 {
-	/*
-	Client *c;
-	for(c=client; c; c=c->next)
-		reparent_client(c, root, c->sel->rect.x, c->sel->rect.y);
+	while(clients)
+		unmanage(clients);
 	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
-	*/
 }
 
 int
@@ -176,6 +178,11 @@ main(int argc, char *argv[])
 	unsigned int mask;
 	Window w;
 	XEvent ev;
+	fd_set fds;
+	struct timeval t, timeout = {
+		.tv_usec = 0,
+		.tv_sec = STATUSDELAY,
+	};
 
 	/* command line args */
 	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
@@ -264,9 +271,19 @@ main(int argc, char *argv[])
 	scan_wins();
 
 	while(running) {
-		XNextEvent(dpy, &ev);
-		if(handler[ev.type])
-			(handler[ev.type]) (&ev); /* call handler */
+		if(XPending(dpy) > 0) {
+			XNextEvent(dpy, &ev);
+			if(handler[ev.type])
+				(handler[ev.type]) (&ev); /* call handler */
+			continue;
+		}
+		FD_ZERO(&fds);
+		FD_SET(ConnectionNumber(dpy), &fds);
+		t = timeout;
+		if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
+			continue;
+		else if(errno != EINTR)
+			draw_bar();
 	}
 
 	cleanup();
#n207'>207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344