diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-22 22:04:49 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-22 22:04:49 +0100 |
commit | 62019ffba459ec76f846518c78b2178622efe491 (patch) | |
tree | e088ce8efab141ea2f7ec0ba6712ab95e7a8c03f /plugingui/eventhandler.cc | |
parent | 75491ae08b645e784b260b2d28e246a441de7f32 (diff) |
Accumulate scroll wheel events in X11.
Diffstat (limited to 'plugingui/eventhandler.cc')
-rw-r--r-- | plugingui/eventhandler.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc index 1953da2..1cf67fc 100644 --- a/plugingui/eventhandler.cc +++ b/plugingui/eventhandler.cc @@ -327,11 +327,20 @@ GUI::Event *GUI::EventHandler::getNextEvent() if(xe.type == ButtonPress || xe.type == ButtonRelease) { if(xe.xbutton.button == 4 || xe.xbutton.button == 5) { + int scroll = 1; + while(true) { // Hack to make sure only the last event is played. + if(!hasEvent()) break; + XEvent nxe; + XPeekEvent(gctx->display, &nxe); + if(nxe.type != ButtonPress && nxe.type != ButtonRelease) break; + scroll += 1; + XNextEvent(gctx->display, &xe); + } ScrollEvent *e = new ScrollEvent(); e->window_id = xe.xbutton.window; e->x = xe.xbutton.x; e->y = xe.xbutton.y; - e->delta = xe.xbutton.button==4?-1:1; + e->delta = scroll * (xe.xbutton.button==4?-1:1); event = e; } else { ButtonEvent *e = new ButtonEvent(); |