From cdcea91b5099ba00ffdaea3a4b2de57ac33b5dfb Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 1 Dec 2013 19:09:20 +0100 Subject: [PATCH] Use nanosleep() instead of the deprecated usleep(). --- src/autotype/x11/AutoTypeX11.cpp | 9 ++++++++- src/autotype/x11/AutoTypeX11.h | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/autotype/x11/AutoTypeX11.cpp b/src/autotype/x11/AutoTypeX11.cpp index 74b3cbef9..477678369 100644 --- a/src/autotype/x11/AutoTypeX11.cpp +++ b/src/autotype/x11/AutoTypeX11.cpp @@ -19,6 +19,8 @@ #include "AutoTypeX11.h" #include "KeySymMap.h" +#include + bool AutoTypePlatformX11::m_catchXErrors = false; bool AutoTypePlatformX11::m_xErrorOccured = false; int (*AutoTypePlatformX11::m_oldXErrorHandler)(Display*, XErrorEvent*) = Q_NULLPTR; @@ -496,9 +498,14 @@ int AutoTypePlatformX11::AddKeysym(KeySym keysym) m_keysymTable[inx] = keysym; XChangeKeyboardMapping(m_dpy, m_specialCharacterKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1); XFlush(m_dpy); + /* Xlib needs some time until the mapping is distributed to all clients */ - usleep(10000); + timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 10 * 1000 * 1000; + nanosleep(&ts, Q_NULLPTR); + return m_specialCharacterKeycode; } diff --git a/src/autotype/x11/AutoTypeX11.h b/src/autotype/x11/AutoTypeX11.h index 66ee7bc18..c94897bef 100644 --- a/src/autotype/x11/AutoTypeX11.h +++ b/src/autotype/x11/AutoTypeX11.h @@ -28,7 +28,6 @@ #include #include #include -#include #include "autotype/AutoTypePlatformPlugin.h" #include "autotype/AutoTypeAction.h"