From aa55cf98aec86354e3aefca308468f831ba1d226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 2 May 2013 19:04:43 +0200 Subject: [PATCH] Port Client's move resize grab window to XCB Using Xcb::Window to wrap this helper window and port all the used XLib calls to XCB. Also renaming the variable to m_ and camel case to follow general naming scheme. --- client.cpp | 2 +- client.h | 8 ++++---- geometry.cpp | 23 ++++++++++++----------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/client.cpp b/client.cpp index 5e2436650e..b85b5c0138 100644 --- a/client.cpp +++ b/client.cpp @@ -95,7 +95,7 @@ Client::Client() , bridge(new Bridge(this)) , m_activityUpdatesBlocked(false) , m_blockedActivityUpdatesRequireTransients(false) - , move_resize_grab_window(None) + , m_moveResizeGrabWindow() , move_resize_has_keyboard_grab(false) , m_managed(false) , transient_for (NULL) diff --git a/client.h b/client.h index 76b810ff04..174c541ab6 100644 --- a/client.h +++ b/client.h @@ -491,7 +491,7 @@ public: void keyPressEvent(uint key_code); // FRAME ?? void updateMouseGrab(); - Window moveResizeGrabWindow() const; + xcb_window_t moveResizeGrabWindow() const; const QPoint calculateGravitation(bool invert, int gravity = 0) const; // FRAME public? @@ -842,7 +842,7 @@ private: bool m_blockedActivityUpdatesRequireTransients; bool buttonDown; bool moveResizeMode; - Window move_resize_grab_window; + Xcb::Window m_moveResizeGrabWindow; bool move_resize_has_keyboard_grab; bool unrestrictedMoveResize; int moveResizeStartScreen; @@ -1234,9 +1234,9 @@ inline const WindowRules* Client::rules() const return &client_rules; } -inline Window Client::moveResizeGrabWindow() const +inline xcb_window_t Client::moveResizeGrabWindow() const { - return move_resize_grab_window; + return m_moveResizeGrabWindow; } inline KShortcut Client::shortcut() const diff --git a/geometry.cpp b/geometry.cpp index ee7403458e..21ea1171fd 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2534,20 +2534,22 @@ bool Client::startMoveResize() // This reportedly improves smoothness of the moveresize operation, // something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug* // (http://lists.kde.org/?t=107302193400001&r=1&w=2) - XSetWindowAttributes attrs; QRect r = workspace()->clientArea(FullArea, this); - move_resize_grab_window = XCreateWindow(display(), rootWindow(), r.x(), r.y(), - r.width(), r.height(), 0, CopyFromParent, InputOnly, CopyFromParent, 0, &attrs); - XMapRaised(display(), move_resize_grab_window); - if (XGrabPointer(display(), move_resize_grab_window, False, - ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask, - GrabModeAsync, GrabModeAsync, move_resize_grab_window, Cursor::x11Cursor(m_cursor), xTime()) == Success) + m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, NULL, rootWindow()); + m_moveResizeGrabWindow.map(); + m_moveResizeGrabWindow.raise(); + const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(connection(), false, m_moveResizeGrabWindow, + XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW, + XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursor::x11Cursor(m_cursor), xTime()); + ScopedCPointer pointerGrab(xcb_grab_pointer_reply(connection(), cookie, NULL)); + if (!pointerGrab.isNull() && pointerGrab->status == XCB_GRAB_STATUS_SUCCESS) { has_grab = true; + } if (grabXKeyboard(frameId())) has_grab = move_resize_has_keyboard_grab = true; if (!has_grab) { // at least one grab is necessary in order to be able to finish move/resize - XDestroyWindow(display(), move_resize_grab_window); - move_resize_grab_window = None; + m_moveResizeGrabWindow.reset(); return false; } @@ -2663,8 +2665,7 @@ void Client::leaveMoveResize() ungrabXKeyboard(); move_resize_has_keyboard_grab = false; XUngrabPointer(display(), xTime()); - XDestroyWindow(display(), move_resize_grab_window); - move_resize_grab_window = None; + m_moveResizeGrabWindow.reset(); workspace()->setClientIsMoving(0); moveResizeMode = false; #ifdef HAVE_XSYNC