[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
This commit is contained in:
Kai Uwe Broulik 2019-12-15 16:29:13 +01:00
parent 00ddc6c1f0
commit 192a50fe8c

View File

@ -57,6 +57,10 @@
#include <xcb/shape.h> #include <xcb/shape.h>
#endif #endif
#if HAVE_X11
#include <QtPlatformHeaders/QXcbWindowFunctions>
#endif
//Unfortunately QWINDOWSIZE_MAX is not exported //Unfortunately QWINDOWSIZE_MAX is not exported
#define DIALOGSIZE_MAX ((1<<24)-1) #define DIALOGSIZE_MAX ((1<<24)-1)
@ -336,17 +340,7 @@ void DialogPrivate::updateVisibility(bool visible)
if (visible) { if (visible) {
q->raise(); q->raise();
if (type != Dialog::Normal) { applyType();
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);
}
} }
} }
@ -725,7 +719,44 @@ void DialogPrivate::setupWaylandIntegration()
void DialogPrivate::applyType() void DialogPrivate::applyType()
{ {
if (type != Dialog::Normal) { if (type != Dialog::Normal) {
KWindowSystem::setType(q->winId(), static_cast<NET::WindowType>(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<QXcbWindowFunctions::WmWindowType>(wmType));
}
}
#endif
if (!wmType) {
KWindowSystem::setType(q->winId(), static_cast<NET::WindowType>(type));
}
} else { } else {
q->setFlags(Qt::FramelessWindowHint | q->flags()); q->setFlags(Qt::FramelessWindowHint | q->flags());
} }