From 0b27bcd6d15f34ad62667dd3b0f2f23f6261b2c6 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 7 May 2015 17:36:57 +0300 Subject: [PATCH 1/1] Restore documented behavior for the WA_X11NetWmWindowType* attributes Use QXcbWindowFunctions::setWmWindowType() to add the corresponding types to the window's _NET_WM_WINDOW_TYPE X11 window property. Change-Id: Ia2413ad7a69ab8d49b448de11dd07c77101a564c Task-number: QTBUG-39887 --- src/widgets/kernel/qwidget.cpp | 44 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index e38262d97fc8e28618141868165a5526cb952aa8..78680f8961b9911fafea68d33db243dba1b901c1 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1409,6 +1409,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win->setProperty("_q_showWithoutActivating", QVariant(true)); if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow)) win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); + setNetWmWindowTypes(); win->setFlags(data.window_flags); fixPosIncludesFrame(); if (q->testAttribute(Qt::WA_Moved) @@ -11128,7 +11129,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; } -#ifdef Q_WS_X11 case Qt::WA_X11NetWmWindowTypeDesktop: case Qt::WA_X11NetWmWindowTypeDock: case Qt::WA_X11NetWmWindowTypeToolBar: @@ -11142,10 +11142,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) case Qt::WA_X11NetWmWindowTypeNotification: case Qt::WA_X11NetWmWindowTypeCombo: case Qt::WA_X11NetWmWindowTypeDND: - if (testAttribute(Qt::WA_WState_Created)) - d->setNetWmWindowTypes(); + d->setNetWmWindowTypes(); break; -#endif case Qt::WA_StaticContents: if (QWidgetBackingStore *bs = d->maybeBackingStore()) { @@ -12784,6 +12782,44 @@ void QWidget::clearMask() setMask(QRegion()); } +void QWidgetPrivate::setNetWmWindowTypes() +{ + Q_Q(QWidget); + + if (!q->windowHandle()) + return; + + int wmWindowType = 0; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop)) + wmWindowType |= QXcbWindowFunctions::Desktop; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock)) + wmWindowType |= QXcbWindowFunctions::Dock; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar)) + wmWindowType |= QXcbWindowFunctions::Toolbar; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu)) + wmWindowType |= QXcbWindowFunctions::Menu; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility)) + wmWindowType |= QXcbWindowFunctions::Utility; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash)) + wmWindowType |= QXcbWindowFunctions::Splash; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog)) + wmWindowType |= QXcbWindowFunctions::Dialog; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu)) + wmWindowType |= QXcbWindowFunctions::DropDownMenu; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu)) + wmWindowType |= QXcbWindowFunctions::PopupMenu; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip)) + wmWindowType |= QXcbWindowFunctions::Tooltip; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification)) + wmWindowType |= QXcbWindowFunctions::Notification; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo)) + wmWindowType |= QXcbWindowFunctions::Combo; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND)) + wmWindowType |= QXcbWindowFunctions::Dnd; + + QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast(wmWindowType)); +} + QT_END_NAMESPACE #include "moc_qwidget.cpp" diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 85e1cf9..2d2948a 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -750,7 +750,6 @@ public: void setWindowRole(); void sendStartupMessage(const char *message) const; - void setNetWmWindowTypes(); void x11UpdateIsOpaque(); bool isBackgroundInherited() const; void updateX11AcceptFocus(); @@ -847,6 +846,8 @@ public: static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool); void registerTouchWindow(bool enable = true); #endif + void setNetWmWindowTypes(); + bool stealKeyboardGrab(bool grab); bool stealMouseGrab(bool grab); }; -- 2.4.2