From 5a07dfe1df384d55596e614c04b31e7ea2090636 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 1 May 2014 22:05:57 -0400 Subject: avoid redundant flushes --- src/window-xlib.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/window-xlib.c b/src/window-xlib.c index 7325595..7324690 100644 --- a/src/window-xlib.c +++ b/src/window-xlib.c @@ -78,6 +78,8 @@ static struct function_key application_cursor_keys[] = { static void runes_window_backend_get_next_event(uv_work_t *req); static void runes_window_backend_process_event(uv_work_t *req, int status); +static Bool runes_window_backend_find_flush_events( + Display *dpy, XEvent *e, XPointer arg); static void runes_window_backend_resize_window( RunesTerm *t, int width, int height); static void runes_window_backend_flush(RunesTerm *t); @@ -379,6 +381,13 @@ static void runes_window_backend_process_event(uv_work_t *req, int status) ); } else if (a == w->atoms[RUNES_ATOM_RUNES_FLUSH]) { + Bool res = True; + + while (res) { + res = XCheckIfEvent( + w->dpy, e, runes_window_backend_find_flush_events, + (XPointer)w); + } runes_window_backend_flush(t); } break; @@ -399,6 +408,22 @@ static void runes_window_backend_process_event(uv_work_t *req, int status) } } +static Bool runes_window_backend_find_flush_events( + Display *dpy, XEvent *e, XPointer arg) +{ + RunesWindowBackend *w = (RunesWindowBackend *)arg; + + UNUSED(dpy); + + if (e->type == ClientMessage) { + Atom a = e->xclient.data.l[0]; + return a == w->atoms[RUNES_ATOM_RUNES_FLUSH] ? True : False; + } + else { + return False; + } +} + static void runes_window_backend_resize_window( RunesTerm *t, int width, int height) { -- cgit v1.2.3-54-g00ecf