From 4a5d5d26aa8c66ef9c4e64cc355c63888b04d4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Mon, 29 Oct 2012 18:25:17 +0100 Subject: Overhauled window drawing - Draw onto pixmap as before, but use the same size for the pixmap as for the window, allocate new pixmap after configure requests - Use XCopyArea() instead of XSetWindowBackgroundPixmap(), which now requires handling of Expose events --- main.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index f6d09f5..848d1a4 100644 --- a/main.c +++ b/main.c @@ -420,7 +420,7 @@ void run(void) { fd_set fds; struct timeval timeout; XEvent ev, nextev; - unsigned int qlen; + bool discard; redraw(); @@ -453,10 +453,20 @@ void run(void) { do { XNextEvent(win.env.dpy, &ev); - qlen = XEventsQueued(win.env.dpy, QueuedAlready); - if (qlen > 0) + discard = false; + if (XEventsQueued(win.env.dpy, QueuedAlready) > 0) { XPeekEvent(win.env.dpy, &nextev); - } while (qlen > 0 && ev.type == nextev.type); + switch (ev.type) { + case ConfigureNotify: + discard = ev.type == nextev.type; + break; + case KeyPress: + discard = (nextev.type == KeyPress || nextev.type == KeyRelease) + && ev.xkey.keycode == nextev.xkey.keycode; + break; + } + } + } while (discard); switch (ev.type) { /* handle events */ @@ -482,9 +492,11 @@ void run(void) { } } break; + case Expose: + win_expose(&win, &ev.xexpose); + break; case KeyPress: - if (qlen == 0 || ev.xkey.keycode != nextev.xkey.keycode) - on_keypress(&ev.xkey); + on_keypress(&ev.xkey); break; case MotionNotify: if (mode == MODE_IMAGE) { -- cgit v1.2.3