diff --git a/.gitignore b/.gitignore index f7f93e78..ec4d2a83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ node_modules/ prebuilds/ +/.idea \ No newline at end of file diff --git a/src/keypress.c b/src/keypress.c index 6d58a2f1..1faeceb7 100644 --- a/src/keypress.c +++ b/src/keypress.c @@ -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))) @@ -162,25 +162,25 @@ void tapKeyCode(MMKeyCode code, MMKeyFlags flags) } void toggleKey(char c, const bool down, MMKeyFlags flags) -{ +{ MMKeyCode keyCode = keyCodeForChar(c); - + //Prevent unused variable warning for Mac and Linux. #if defined(IS_WINDOWS) int modifiers; -#endif - +#endif + if (isupper(c) && !(flags & MOD_SHIFT)) { flags |= MOD_SHIFT; /* Not sure if this is safe for all layouts. */ } - + #if defined(IS_WINDOWS) modifiers = keyCode >> 8; // Pull out modifers. if ((modifiers & 1) != 0) flags |= MOD_SHIFT; // Uptdate flags from keycode modifiers. if ((modifiers & 2) != 0) flags |= MOD_CONTROL; if ((modifiers & 4) != 0) flags |= MOD_ALT; keyCode = keyCode & 0xff; // Mask out modifiers. -#endif +#endif toggleKeyCode(keyCode, down, flags); } diff --git a/src/mouse.c b/src/mouse.c index 8f47f7b6..4f1a2979 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -103,7 +103,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)) @@ -184,7 +184,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 @@ -290,7 +290,7 @@ void scrollMouse(int x, int y) XTestFakeButtonEvent(display, ydir, 0, CurrentTime); } - XFlush(display); + XSync(display, false); #elif defined(IS_WINDOWS)