diff options
Diffstat (limited to 'src/plugins')
-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); |