From b42914ba7b2c2ec08abeb4ec658ffaea019e3e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Apr 2011 09:44:34 +0200 Subject: Set the _NET_WM_WINDOW_TYPE property in the XCB backend. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 38 ++++++++++++++++++++++++++++++++ src/plugins/platforms/xcb/qxcbwindow.h | 1 + 2 files changed, 39 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f0b9e32..ad91602 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -304,6 +304,8 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) { Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); + setNetWmWindowTypes(flags); + if (type == Qt::ToolTip) flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint; if (type == Qt::Popup) @@ -407,6 +409,42 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) return QPlatformWindow::setWindowFlags(flags); } +void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags) +{ + // in order of decreasing priority + QVector windowTypes; + + Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); + + switch (type) { + case Qt::Dialog: + case Qt::Sheet: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); + break; + case Qt::Tool: + case Qt::Drawer: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); + break; + case Qt::ToolTip: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); + break; + case Qt::SplashScreen: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); + break; + default: + break; + } + + if (flags & Qt::FramelessWindowHint) + windowTypes.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); + + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); + + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, + windowTypes.count(), windowTypes.constData())); +} + WId QXcbWindow::winId() const { return m_window; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 0fa4d0f..e049837 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -92,6 +92,7 @@ public: void updateSyncRequestCounter(); private: + void setNetWmWindowTypes(Qt::WindowFlags flags); QXcbScreen *m_screen; -- cgit v0.12