Skip to content

Commit b7d58ea

Browse files
author
Egil
committed
Don't process more than one raw pointer movement at a time
1 parent bab1007 commit b7d58ea

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

glass-renderer/picking.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "picking.h"
22
#include "wm.h"
3+
#include "mainloop.h"
34

45
GLuint picking_fb;
56

@@ -69,7 +70,8 @@ void pick(int x, int y, int *winx, int *winy, Item **item, Item **parent_item) {
6970
view_pick(picking_fb, view, x, y, winx, winy, item, parent_item);
7071
}
7172

72-
void raw_motion_detected(void *data, xcb_query_pointer_reply_t *reply, xcb_generic_error_t *error) {
73+
static Bool processing_raw_motion_detected = False;
74+
void raw_motion_detected_load(void *data, xcb_query_pointer_reply_t *reply, xcb_generic_error_t *error) {
7375
mouse.root = reply->root;
7476
mouse.win = reply->child;
7577
mouse.root_x = reply->root_x;
@@ -108,4 +110,12 @@ void raw_motion_detected(void *data, xcb_query_pointer_reply_t *reply, xcb_gener
108110
DEBUG("position", "Point %d,%d -> NONE\n", mouse.root_x, mouse.root_y);
109111
}
110112
trigger_draw();
113+
processing_raw_motion_detected = False;
114+
}
115+
116+
void raw_motion_detected(void) {
117+
if (processing_raw_motion_detected) return;
118+
processing_raw_motion_detected = True;
119+
xcb_query_pointer_cookie_t query_pointer_cookie = xcb_query_pointer(xcb_display, root);
120+
MAINLOOP_XCB_DEFER(query_pointer_cookie, &raw_motion_detected_load, NULL);
111121
}

glass-renderer/picking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
extern int init_picking();
99
extern void pick(int x, int y, int *winx, int *winy, Item **item, Item **parent_item);
10-
extern void raw_motion_detected(void *data, xcb_query_pointer_reply_t *reply, xcb_generic_error_t *error);
10+
extern void raw_motion_detected(void);
1111

1212
#endif

glass-renderer/wm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ Bool main_event_handler_function(EventHandler *handler, XEvent *event) {
147147
} else if (cookie->type == GenericEvent) {
148148
if (XGetEventData(display, cookie)) {
149149
if (cookie->evtype == XI_RawMotion) {
150-
xcb_query_pointer_cookie_t query_pointer_cookie = xcb_query_pointer(xcb_display, root);
151-
MAINLOOP_XCB_DEFER(query_pointer_cookie, &raw_motion_detected, NULL);
150+
raw_motion_detected();
152151
} else {
153152
DEBUG("event", "Unknown XGenericEventCookie\n");
154153
}

0 commit comments

Comments
 (0)