diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-10-07 20:22:46 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-07 22:27:13 +0200 |
commit | 8ba313ee5a50786735e40cd6d0eb67ec5063c700 (patch) | |
tree | 6cb980fbe2d6d198654fc742dd95a0b01e4701bf /src/plugins/platforms/xcb | |
parent | c5006a6fe23195a977bfd84c61d715e0b19850a7 (diff) |
Make sure window state is synced back to Qt from the XCB plugin.
We should properly react to the property notify events.
Task-number: QTBUG-21856
Change-Id: I0d2aa90b7d8da3b96acf4d88684b0200de7d7413
Reviewed-on: http://codereview.qt-project.org/6266
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 4 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 47 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 1 |
3 files changed, 49 insertions, 3 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 3d1a145442..08c569c993 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -527,9 +527,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) handled = false; break; case XCB_PROPERTY_NOTIFY: - setTime(((xcb_property_notify_event_t *)event)->time); -// qDebug() << "XCB_PROPERTY_NOTIFY"; - handled = false; + HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent); break; default: handled = false; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 48a59ec28e..4d2e5b0c3d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1331,6 +1331,53 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) QWindowSystemInterface::handleLeaveEvent(window()); } +void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) +{ + connection()->setTime(event->time); + + bool propertyDeleted = event->state == XCB_PROPERTY_DELETE; + + if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) { + if (propertyDeleted) + return; + + xcb_get_property_cookie_t get_cookie = + xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE), + XCB_ATOM_ANY, 0, 1024); + + xcb_generic_error_t *error; + + xcb_get_property_reply_t *reply = + xcb_get_property_reply(xcb_connection(), get_cookie, &error); + + xcb_atom_t wm_state = XCB_WM_STATE_WITHDRAWN; + if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { + if (reply->length != 0) + wm_state = ((long *)xcb_get_property_value(reply))[0]; + free(reply); + } else if (error) { + connection()->handleXcbError(error); + free(error); + } + + QVector<xcb_atom_t> netWmState = getNetWmState(); + + bool maximized = netWmState.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ)) + && netWmState.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); + bool fullscreen = netWmState.contains(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); + + Qt::WindowState state = Qt::WindowNoState; + if (wm_state == XCB_WM_STATE_ICONIC) + state = Qt::WindowMinimized; + else if (maximized) + state = Qt::WindowMaximized; + else if (fullscreen) + state = Qt::WindowFullScreen; + + QWindowSystemInterface::handleWindowStateChanged(window(), state); + } +} + void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *) { QWindowSystemInterface::handleWindowActivated(window()); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index f470bbcd85..f33ff5c2eb 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -103,6 +103,7 @@ public: void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event); void handleFocusInEvent(const xcb_focus_in_event_t *event); void handleFocusOutEvent(const xcb_focus_out_event_t *event); + void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event); void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers); |