From 2631277184f53f2d9a01b2ee179d874749476c34 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 13 Mar 2015 19:48:18 +0100 Subject: [PATCH] Always sleep some time after the keymap has changed. This works around a problem where sometimes chars are typed as if some random modifiers are pressed. --- src/autotype/x11/AutoTypeX11.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/autotype/x11/AutoTypeX11.cpp b/src/autotype/x11/AutoTypeX11.cpp index e2d877bae..47ab9127a 100644 --- a/src/autotype/x11/AutoTypeX11.cpp +++ b/src/autotype/x11/AutoTypeX11.cpp @@ -484,6 +484,14 @@ void AutoTypePlatformX11::updateKeymap() } } XFreeModifiermap(modifiers); + + /* Xlib needs some time until the mapping is distributed to + all clients */ + // TODO: we should probably only sleep while in the middle of typing something + timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 30 * 1000 * 1000; + nanosleep(&ts, Q_NULLPTR); } bool AutoTypePlatformX11::isRemapKeycodeValid() @@ -550,13 +558,6 @@ int AutoTypePlatformX11::AddKeysym(KeySym keysym) XFlush(m_dpy); updateKeymap(); - /* Xlib needs some time until the mapping is distributed to - all clients */ - timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = 30 * 1000 * 1000; - nanosleep(&ts, Q_NULLPTR); - return m_remapKeycode; }