From 221f7216d1b6fda90f1aba36b2509aa62e158bee Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 9 Mar 2013 20:01:41 +0100 Subject: Ignore duplicate mouxe move events in X11. Only play the last one. Also a bit of spring cleaning... --- plugingui/eventhandler.cc | 55 +++++++---------------------------------------- 1 file changed, 8 insertions(+), 47 deletions(-) (limited to 'plugingui/eventhandler.cc') diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc index 088380f..57718c2 100644 --- a/plugingui/eventhandler.cc +++ b/plugingui/eventhandler.cc @@ -296,47 +296,15 @@ GUI::Event *GUI::EventHandler::getNextEvent() XEvent xe; XNextEvent(gctx->display, &xe); - //printf("XEvent ?%d[%d]\n", ConfigureNotify, xe.type); - -/** - * KeyPress 2 - * KeyRelease 3 - * ButtonPress 4 - * ButtonRelease 5 - * MotionNotify 6 - * EnterNotify 7 - * LeaveNotify 8 - * FocusIn 9 - * FocusOut 10 - * KeymapNotify 11 - * Expose 12 - * GraphicsExpose 13 - * NoExpose 14 - * VisibilityNotify 15 - * CreateNotify 16 - * DestroyNotify 17 - * UnmapNotify 18 - * MapNotify 19 - * MapRequest 20 - * ReparentNotify 21 - * ConfigureNotify 22 - * ConfigureRequest 23 - * GravityNotify 24 - * ResizeRequest 25 - * CirculateNotify 26 - * CirculateRequest 27 - * PropertyNotify 28 - * SelectionClear 29 - * SelectionRequest 30 - * SelectionNotify 31 - * ColormapNotify 32 - * ClientMessage 33 - * MappingNotify 34 - * GenericEvent 35 - * LASTEvent 36 // must be bigger than any event # - **/ - if(xe.type == MotionNotify) { + while(true) { // Hack to make sure only the last event is played. + if(!hasEvent()) break; + XEvent nxe; + XPeekEvent(gctx->display, &nxe); + if(nxe.type != MotionNotify) break; + XNextEvent(gctx->display, &xe); + } + MouseMoveEvent *e = new MouseMoveEvent(); e->window_id = xe.xmotion.window; e->x = xe.xmotion.x; @@ -355,13 +323,6 @@ GUI::Event *GUI::EventHandler::getNextEvent() } if(xe.type == ConfigureNotify) { - /* - if(hasEvent()) { // Hack to make sure only the last resize event is played. - XEvent nxe; - XPeekEvent(gctx->display, &nxe); - if(xe.type == ConfigureNotify) return NULL; - } - */ ResizeEvent *e = new ResizeEvent(); e->window_id = xe.xconfigure.window; // e->x = xe.xconfigure.x; -- cgit v1.2.3