From e2c422dcb54317acc42ca252d449f096ad78d7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 18 Mar 2015 07:47:49 +0100 Subject: [PATCH] Woraround possible broken cursor when creating mouse interception window The xcb_cursor_t returned by xcb-cursor library might be broken. If we set such a broken cursor directly in the create window call it will fail with a BadCursor value causing effects to break. This change works around this problem by creating just the window and moving the possible breaking call into a change window call. That will still fail, but the window is working. In addition it performs a safety check by only installing the cursor if it's not XCB_CURSOR_NONE. BUG: 344006 REVIEW: 123025 --- effects.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/effects.cpp b/effects.cpp index 3cccf31d51..4555fb8347 100644 --- a/effects.cpp +++ b/effects.cpp @@ -684,13 +684,13 @@ void EffectsHandlerImpl::startMouseInterception(Effect *effect, Qt::CursorShape if (!m_mouseInterceptionWindow.isValid()) { const QSize &s = screens()->size(); const QRect geo(0, 0, s.width(), s.height()); - const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_CURSOR; + const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; const uint32_t values[] = { true, - XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION, - Cursor::x11Cursor(shape) + XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION }; m_mouseInterceptionWindow.reset(Xcb::createInputWindow(geo, mask, values)); + defineCursor(shape); } else { defineCursor(shape); } @@ -1177,7 +1177,10 @@ void EffectsHandlerImpl::defineCursor(Qt::CursorShape shape) #endif return; } - m_mouseInterceptionWindow.defineCursor(Cursor::x11Cursor(shape)); + const xcb_cursor_t c = Cursor::x11Cursor(shape); + if (c != XCB_CURSOR_NONE) { + m_mouseInterceptionWindow.defineCursor(c); + } } bool EffectsHandlerImpl::checkInputWindowEvent(xcb_button_press_event_t *e)