Port (un)grabXKeyboard to XCB

remotes/origin/Plasma/5.0
Martin Gräßlin 13 years ago
parent 023de5b75e
commit 7e9d7f3959
  1. 16
      utils.cpp
  2. 2
      utils.h

@ -235,7 +235,7 @@ bool grabbedXServer()
static bool keyboard_grabbed = false; static bool keyboard_grabbed = false;
bool grabXKeyboard(Window w) bool grabXKeyboard(xcb_window_t w)
{ {
if (QWidget::keyboardGrabber() != NULL) if (QWidget::keyboardGrabber() != NULL)
return false; return false;
@ -243,11 +243,17 @@ bool grabXKeyboard(Window w)
return false; return false;
if (qApp->activePopupWidget() != NULL) if (qApp->activePopupWidget() != NULL)
return false; return false;
if (w == None) if (w == XCB_WINDOW_NONE)
w = rootWindow(); w = rootWindow();
if (XGrabKeyboard(display(), w, False, const xcb_grab_keyboard_cookie_t c = xcb_grab_keyboard_unchecked(connection(), false, w, xTime(),
GrabModeAsync, GrabModeAsync, xTime()) != GrabSuccess) XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
ScopedCPointer<xcb_grab_keyboard_reply_t> grab(xcb_grab_keyboard_reply(connection(), c, NULL));
if (grab.isNull()) {
return false; return false;
}
if (grab->status != XCB_GRAB_STATUS_SUCCESS) {
return false;
}
keyboard_grabbed = true; keyboard_grabbed = true;
return true; return true;
} }
@ -259,7 +265,7 @@ void ungrabXKeyboard()
kDebug(1212) << "ungrabXKeyboard() called but keyboard not grabbed!"; kDebug(1212) << "ungrabXKeyboard() called but keyboard not grabbed!";
} }
keyboard_grabbed = false; keyboard_grabbed = false;
XUngrabKeyboard(display(), CurrentTime); xcb_ungrab_keyboard(connection(), XCB_TIME_CURRENT_TIME);
} }
QPoint cursorPos() QPoint cursorPos()

@ -221,7 +221,7 @@ void updateXTime();
void grabXServer(); void grabXServer();
void ungrabXServer(); void ungrabXServer();
bool grabbedXServer(); bool grabbedXServer();
bool grabXKeyboard(Window w = rootWindow()); bool grabXKeyboard(xcb_window_t w = rootWindow());
void ungrabXKeyboard(); void ungrabXKeyboard();
/** /**

Loading…
Cancel
Save