From 17d68c4fc371c32bd58d0a94ac63f0170edaf29e Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 7 May 2015 17:36:57 +0300 Subject: [PATCH] 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 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidget.cpp | 47 +++++++++++++++++++++++++++++++--- src/widgets/kernel/qwidget_p.h | 3 ++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 03f642bd9b..1926611442 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1427,6 +1427,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(true); // do nothing if none of WA_X11NetWmWindowType* is set win->setFlags(data.window_flags); fixPosIncludesFrame(); if (q->testAttribute(Qt::WA_Moved) @@ -11224,7 +11225,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; } -#ifdef Q_DEAD_CODE_FROM_QT4_X11 case Qt::WA_X11NetWmWindowTypeDesktop: case Qt::WA_X11NetWmWindowTypeDock: case Qt::WA_X11NetWmWindowTypeToolBar: @@ -11238,10 +11238,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()) { @@ -12909,6 +12907,47 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new widget->setParent(static_cast(newParent)); } +void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing) +{ + 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; + + if (wmWindowType == 0 && skipIfMissing) + return; + + QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast(wmWindowType)); +} + #ifndef QT_NO_DEBUG_STREAM static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 9681cb03ec..b130c5421a 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -758,7 +758,6 @@ public: void setWindowRole(); void sendStartupMessage(const char *message) const; - void setNetWmWindowTypes(); void x11UpdateIsOpaque(); bool isBackgroundInherited() const; void updateX11AcceptFocus(); @@ -855,6 +854,8 @@ public: static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool); void registerTouchWindow(bool enable = true); #endif + void setNetWmWindowTypes(bool skipIfMissing = false); + bool stealKeyboardGrab(bool grab); bool stealMouseGrab(bool grab); };