From 3cb987ceb27cf489350587c02de1e8af6c94e814 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Wed, 7 Mar 2018 17:20:08 +0800 Subject: [PATCH] fix XFlush wait for events flushing --- key/keypress_c.h | 2 +- mouse/mouse_c.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/key/keypress_c.h b/key/keypress_c.h index e01c223..ae0fdaa 100644 --- a/key/keypress_c.h +++ b/key/keypress_c.h @@ -22,7 +22,7 @@ (XTestFakeKeyEvent(display, \ XKeysymToKeycode(display, key), \ is_press, CurrentTime), \ - XFlush(display)) + XSync(display, false)) #define X_KEY_EVENT_WAIT(display, key, is_press) \ (X_KEY_EVENT(display, key, is_press), \ microsleep(DEADBEEF_UNIFORM(0.0, 62.5))) diff --git a/mouse/mouse_c.h b/mouse/mouse_c.h index e83ce07..dadce4c 100644 --- a/mouse/mouse_c.h +++ b/mouse/mouse_c.h @@ -105,7 +105,7 @@ void moveMouse(MMPoint point){ Display *display = XGetMainDisplay(); XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, point.x, point.y); - XFlush(display); + XSync(display, false); #elif defined(IS_WINDOWS) //Mouse motion is now done using SendInput with MOUSEINPUT. We use Absolute mouse positioning #define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1)) @@ -183,7 +183,7 @@ void toggleMouse(bool down, MMMouseButton button){ #elif defined(USE_X11) Display *display = XGetMainDisplay(); XTestFakeButtonEvent(display, button, down ? True : False, CurrentTime); - XFlush(display); + XSync(display, false); #elif defined(IS_WINDOWS) mouse_event(MMMouseToMEventF(down, button), 0, 0, 0, 0); #endif @@ -276,7 +276,7 @@ void scrollMouse(int scrollMagnitude, MMMouseWheelDirection scrollDirection){ XTestFakeButtonEvent(display, dir, 0, CurrentTime); } - XFlush(display); + XSync(display, false); #elif defined(IS_WINDOWS) @@ -338,7 +338,7 @@ void scrollMouseXY(int x, int y){ XTestFakeButtonEvent(display, ydir, 0, CurrentTime); } - XFlush(display); + XSync(display, false); #elif defined(IS_WINDOWS)