Use nanosleep() instead of the deprecated usleep().

This commit is contained in:
Felix Geyer 2013-12-01 19:09:20 +01:00
parent 4549c97e51
commit cdcea91b50
2 changed files with 8 additions and 2 deletions

View File

@ -19,6 +19,8 @@
#include "AutoTypeX11.h" #include "AutoTypeX11.h"
#include "KeySymMap.h" #include "KeySymMap.h"
#include <time.h>
bool AutoTypePlatformX11::m_catchXErrors = false; bool AutoTypePlatformX11::m_catchXErrors = false;
bool AutoTypePlatformX11::m_xErrorOccured = false; bool AutoTypePlatformX11::m_xErrorOccured = false;
int (*AutoTypePlatformX11::m_oldXErrorHandler)(Display*, XErrorEvent*) = Q_NULLPTR; int (*AutoTypePlatformX11::m_oldXErrorHandler)(Display*, XErrorEvent*) = Q_NULLPTR;
@ -496,9 +498,14 @@ int AutoTypePlatformX11::AddKeysym(KeySym keysym)
m_keysymTable[inx] = keysym; m_keysymTable[inx] = keysym;
XChangeKeyboardMapping(m_dpy, m_specialCharacterKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1); XChangeKeyboardMapping(m_dpy, m_specialCharacterKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
XFlush(m_dpy); XFlush(m_dpy);
/* Xlib needs some time until the mapping is distributed to /* Xlib needs some time until the mapping is distributed to
all clients */ all clients */
usleep(10000); timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 10 * 1000 * 1000;
nanosleep(&ts, Q_NULLPTR);
return m_specialCharacterKeycode; return m_specialCharacterKeycode;
} }

View File

@ -28,7 +28,6 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/XTest.h> #include <X11/extensions/XTest.h>
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#include <unistd.h>
#include "autotype/AutoTypePlatformPlugin.h" #include "autotype/AutoTypePlatformPlugin.h"
#include "autotype/AutoTypeAction.h" #include "autotype/AutoTypeAction.h"