diff options
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 67 |
1 files changed, 52 insertions, 15 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 2e3d1cf9f8..bfadd69db5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1432,6 +1432,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) @@ -1477,6 +1478,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO data.window_flags = win->flags(); + if (!topData()->role.isNull()) + QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); + QBackingStore *store = q->backingStore(); if (!store) { @@ -6353,13 +6357,11 @@ QString QWidget::windowRole() const */ void QWidget::setWindowRole(const QString &role) { -#if defined(Q_DEAD_CODE_FROM_QT4_X11) Q_D(QWidget); + d->createTLExtra(); d->topData()->role = role; - d->setWindowRole(); -#else - Q_UNUSED(role) -#endif + if (windowHandle()) + QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); } /*! @@ -10364,14 +10366,13 @@ void QWidgetPrivate::setWindowFlags(Qt::WindowFlags flags) // the old type was a window and/or the new type is a window QPoint oldPos = q->pos(); bool visible = q->isVisible(); + const bool windowFlagChanged = (q->data->window_flags ^ flags) & Qt::Window; q->setParent(q->parentWidget(), flags); // if both types are windows or neither of them are, we restore // the old position - if (!((q->data->window_flags ^ flags) & Qt::Window) - && (visible || q->testAttribute(Qt::WA_Moved))) { + if (!windowFlagChanged && (visible || q->testAttribute(Qt::WA_Moved))) q->move(oldPos); - } // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated. adjustQuitOnCloseAttribute(); } else { @@ -11252,7 +11253,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: @@ -11266,10 +11266,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()) { @@ -11325,9 +11323,7 @@ bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const This feature is available on Embedded Linux, \macos, Windows, and X11 platforms that support the Composite extension. - This feature is not available on Windows CE. - - Note that under X11 you need to have a composite manager running, + \note On X11 you need to have a composite manager running, and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager you are using. @@ -12940,6 +12936,47 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new widget->setParent(static_cast<QWidget*>(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<QXcbWindowFunctions::WmWindowType>(wmWindowType)); +} + #ifndef QT_NO_DEBUG_STREAM static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) |