tAvoid treating to much mousepress events - glazier - window management experiments
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit 48dda2dad2bb45959ae90b0b869ad033a377c057
(DIR) parent 92a6cbbeac2b7e3691f10db5e5f971f925bcdda1
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Tue, 22 Oct 2019 22:10:09 +0200
Avoid treating to much mousepress events
Diffstat:
M glazier.c | 7 +++++++
1 file changed, 7 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/glazier.c b/glazier.c
t@@ -224,12 +224,18 @@ cb_mouse_press(xcb_generic_event_t *ev)
{
int x, y, w, h;
xcb_cursor_t p;
+ static xcb_timestamp_t lasttime = 0;
xcb_cursor_context_t *cx;
xcb_grab_pointer_cookie_t c;
xcb_grab_pointer_reply_t *r;
xcb_button_press_event_t *e;
e = (xcb_button_press_event_t *)ev;
+
+ /* ignore some motion events if they happen too often */
+ if (e->time - lasttime < 32)
+ return 0;
+
if (verbose)
fprintf(stderr, "%s 0x%08x\n", XEV(e), e->event);
t@@ -243,6 +249,7 @@ cb_mouse_press(xcb_generic_event_t *ev)
cursor.x = e->root_x - wm_get_attribute(e->event, ATTR_X);
cursor.y = e->root_y - wm_get_attribute(e->event, ATTR_Y);
cursor.b = e->detail;
+ lasttime = e->time;
switch(e->detail) {
case 1: