Skip to content

Commit 9f3a4c4

Browse files
Use XSync instead of XFlush everywhere - fixes #347
1 parent 34d3653 commit 9f3a4c4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/keypress.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(XTestFakeKeyEvent(display, \
2323
XKeysymToKeycode(display, key), \
2424
is_press, CurrentTime), \
25-
XFlush(display))
25+
XSync(display, false))
2626
#define X_KEY_EVENT_WAIT(display, key, is_press) \
2727
(X_KEY_EVENT(display, key, is_press), \
2828
microsleep(DEADBEEF_UNIFORM(0.0, 62.5)))
@@ -162,25 +162,25 @@ void tapKeyCode(MMKeyCode code, MMKeyFlags flags)
162162
}
163163

164164
void toggleKey(char c, const bool down, MMKeyFlags flags)
165-
{
165+
{
166166
MMKeyCode keyCode = keyCodeForChar(c);
167-
167+
168168
//Prevent unused variable warning for Mac and Linux.
169169
#if defined(IS_WINDOWS)
170170
int modifiers;
171-
#endif
172-
171+
#endif
172+
173173
if (isupper(c) && !(flags & MOD_SHIFT)) {
174174
flags |= MOD_SHIFT; /* Not sure if this is safe for all layouts. */
175175
}
176-
176+
177177
#if defined(IS_WINDOWS)
178178
modifiers = keyCode >> 8; // Pull out modifers.
179179
if ((modifiers & 1) != 0) flags |= MOD_SHIFT; // Uptdate flags from keycode modifiers.
180180
if ((modifiers & 2) != 0) flags |= MOD_CONTROL;
181181
if ((modifiers & 4) != 0) flags |= MOD_ALT;
182182
keyCode = keyCode & 0xff; // Mask out modifiers.
183-
#endif
183+
#endif
184184
toggleKeyCode(keyCode, down, flags);
185185
}
186186

src/mouse.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void moveMouse(MMPoint point)
103103
Display *display = XGetMainDisplay();
104104
XWarpPointer(display, None, DefaultRootWindow(display),
105105
0, 0, 0, 0, point.x, point.y);
106-
XFlush(display);
106+
XSync(display, false);
107107
#elif defined(IS_WINDOWS)
108108
//Mouse motion is now done using SendInput with MOUSEINPUT. We use Absolute mouse positioning
109109
#define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
@@ -184,7 +184,7 @@ void toggleMouse(bool down, MMMouseButton button)
184184
#elif defined(USE_X11)
185185
Display *display = XGetMainDisplay();
186186
XTestFakeButtonEvent(display, button, down ? True : False, CurrentTime);
187-
XFlush(display);
187+
XSync(display, false);
188188
#elif defined(IS_WINDOWS)
189189
mouse_event(MMMouseToMEventF(down, button), 0, 0, 0, 0);
190190
#endif
@@ -278,7 +278,7 @@ void scrollMouse(int x, int y)
278278
YTestFakeButtonEvent(display, ydir, 0, CurrentTime);
279279
}
280280

281-
XFlush(display);
281+
XSync(display, false);
282282

283283
#elif defined(IS_WINDOWS)
284284

0 commit comments

Comments
 (0)