From 192a50fe8c3c38517f2ff59c6ffcbb01f8f147bd Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sun, 15 Dec 2019 16:29:13 +0100 Subject: [PATCH] [Plasma Dialog] Use QXcbWindowFunctions for setting window types Qt WindowFlags doesn't know ... but Qt XCB does, such as Notification type. This ensures QXcbWindow keeps the correct window types around so we don't have Qt setting it back to e.g. Dialog when we change some flags and then having to manually set it back using KWindowSystem. Only for types that aren't in NET WM like OSD and Critical Notifications will it have to fall back to the old codepath. It also just uses it directly on Wayland. Differential Revision: https://phabricator.kde.org/D26000 --- src/plasmaquick/dialog.cpp | 55 +++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 74134ee7c..63a2ff9f3 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -57,6 +57,10 @@ #include #endif +#if HAVE_X11 +#include +#endif + //Unfortunately QWINDOWSIZE_MAX is not exported #define DIALOGSIZE_MAX ((1<<24)-1) @@ -336,17 +340,7 @@ void DialogPrivate::updateVisibility(bool visible) if (visible) { q->raise(); - if (type != Dialog::Normal) { - KWindowSystem::setType(q->winId(), (NET::WindowType)type); - } else { - q->setFlags(Qt::FramelessWindowHint | q->flags()); - } - - if (type == Dialog::Dock || type == Dialog::Notification || type == Dialog::OnScreenDisplay || type == Dialog::CriticalNotification) { - KWindowSystem::setOnAllDesktops(q->winId(), true); - } else { - KWindowSystem::setOnAllDesktops(q->winId(), false); - } + applyType(); } } @@ -725,7 +719,44 @@ void DialogPrivate::setupWaylandIntegration() void DialogPrivate::applyType() { if (type != Dialog::Normal) { - KWindowSystem::setType(q->winId(), static_cast(type)); + /*QXcbWindowFunctions::WmWindowType*/ int wmType = 0; + +#if HAVE_X11 + if (KWindowSystem::isPlatformX11()) { + switch (type) { + case Dialog::Normal: + Q_UNREACHABLE(); + break; + case Dialog::Dock: + wmType = QXcbWindowFunctions::WmWindowType::Dock; + break; + case Dialog::DialogWindow: + wmType = QXcbWindowFunctions::WmWindowType::Dialog; + break; + case Dialog::PopupMenu: + wmType = QXcbWindowFunctions::WmWindowType::PopupMenu; + break; + case Dialog::Tooltip: + wmType = QXcbWindowFunctions::WmWindowType::Tooltip; + break; + case Dialog::Notification: + wmType = QXcbWindowFunctions::WmWindowType::Notification; + break; + case Dialog::OnScreenDisplay: + case Dialog::CriticalNotification: + // Not supported by Qt + break; + } + + if (wmType) { + QXcbWindowFunctions::setWmWindowType(q, static_cast(wmType)); + } + } +#endif + + if (!wmType) { + KWindowSystem::setType(q->winId(), static_cast(type)); + } } else { q->setFlags(Qt::FramelessWindowHint | q->flags()); }