diff options
author | Błażej Szczygieł <spaz16@wp.pl> | 2015-10-18 00:16:15 +0200 |
---|---|---|
committer | Błażej Szczygieł <spaz16@wp.pl> | 2016-01-05 21:12:34 +0000 |
commit | 0b3da1907d46a03e8838c4086b23d48ba69c8776 (patch) | |
tree | f341edac0ae35e2b2b8e003c645fa125f302d0e1 /src/plugins/platforms/xcb/qxcbwindow.cpp | |
parent | 2d8b0d1cd566cc0c3ab600650b66cdc771d8314f (diff) |
xcb: fix drag and drop when window is hidden
This patch fixes drag and drop operation on XCB platform when window
will be hidden. The window can be hidden during dnd operation by
switching virtual desktops or by minimizing all windows (show desktop)
using key shortcut.
The ShapedPixmapWindow must grab mouse before dnd operation if mouse is
not grabbed by other window (like in Qt4).
Task-number: QTBUG-46243
Change-Id: I807bc842719a2d0ea0f4dcb733c06c1fd08813e1
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index bec167fec2..4e4a0cdaef 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -594,12 +594,16 @@ QXcbWindow::~QXcbWindow() { if (window()->type() != Qt::ForeignWindow) destroy(); + else if (connection()->mouseGrabber() == this) + connection()->setMouseGrabber(Q_NULLPTR); } void QXcbWindow::destroy() { if (connection()->focusWindow() == this) doFocusOut(); + if (connection()->mouseGrabber() == this) + connection()->setMouseGrabber(Q_NULLPTR); if (m_syncCounter && m_usingSyncProtocol) Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter)); @@ -847,6 +851,9 @@ void QXcbWindow::hide() xcb_flush(xcb_connection()); + if (connection()->mouseGrabber() == this) + connection()->setMouseGrabber(Q_NULLPTR); + m_mapped = false; } @@ -2357,6 +2364,8 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev QWindowSystemInterface::handleWindowStateChanged(window(), newState); m_lastWindowStateEvent = newState; m_windowState = newState; + if (m_windowState == Qt::WindowMinimized && connection()->mouseGrabber() == this) + connection()->setMouseGrabber(Q_NULLPTR); } return; } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) { @@ -2411,9 +2420,15 @@ bool QXcbWindow::setKeyboardGrabEnabled(bool grab) bool QXcbWindow::setMouseGrabEnabled(bool grab) { + if (!grab && connection()->mouseGrabber() == this) + connection()->setMouseGrabber(Q_NULLPTR); #ifdef XCB_USE_XINPUT22 - if (connection()->xi2MouseEvents()) - return connection()->xi2SetMouseGrabEnabled(m_window, grab); + if (connection()->xi2MouseEvents()) { + bool result = connection()->xi2SetMouseGrabEnabled(m_window, grab); + if (grab && result) + connection()->setMouseGrabber(this); + return result; + } #endif if (grab && !connection()->canGrab()) return false; @@ -2432,6 +2447,8 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab) xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, NULL); bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); free(reply); + if (result) + connection()->setMouseGrabber(this); return result; } |