From a31293f79d298389f1a0eca56cde540f8bad9eec Mon Sep 17 00:00:00 2001 From: Julius Zint Date: Wed, 26 Jan 2022 10:17:08 +0100 Subject: [PATCH] Adapt to Layer Shell Qt API change The Layer Shell Qt library is updated to match its API more closely to the protocol. It is now possible, or rather required if the behavior should not change, to specify a desired output for a LayerShell window. --- ksplash/ksplashqml/splashapp.cpp | 3 +-- ksplash/ksplashqml/splashwindow.cpp | 4 +++- ksplash/ksplashqml/splashwindow.h | 4 +++- logout-greeter/greeter.cpp | 3 +-- logout-greeter/shutdowndlg.cpp | 19 +++++++++++-------- logout-greeter/shutdowndlg.h | 4 +++- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/ksplash/ksplashqml/splashapp.cpp b/ksplash/ksplashqml/splashapp.cpp index 3933efcc3..e627b4851 100644 --- a/ksplash/ksplashqml/splashapp.cpp +++ b/ksplash/ksplashqml/splashapp.cpp @@ -131,9 +131,8 @@ void SplashApp::adoptScreen(QScreen *screen) if (screen->geometry().isNull()) { return; } - SplashWindow *w = new SplashWindow(m_testing, m_window, m_theme); + SplashWindow *w = new SplashWindow(m_testing, m_window, m_theme, screen); w->setGeometry(screen->geometry()); - w->setScreen(screen); w->setStage(m_stage); w->setVisible(true); m_windows << w; diff --git a/ksplash/ksplashqml/splashwindow.cpp b/ksplash/ksplashqml/splashwindow.cpp index 58d64e9ce..2ef8f87b5 100644 --- a/ksplash/ksplashqml/splashwindow.cpp +++ b/ksplash/ksplashqml/splashwindow.cpp @@ -24,7 +24,7 @@ #include -SplashWindow::SplashWindow(bool testing, bool window, const QString &theme) +SplashWindow::SplashWindow(bool testing, bool window, const QString &theme, QScreen *screen) : KQuickAddons::QuickViewSharedEngine() , m_stage(0) , m_testing(testing) @@ -36,9 +36,11 @@ SplashWindow::SplashWindow(bool testing, bool window, const QString &theme) layerShellWindow->setScope(QStringLiteral("ksplashqml")); layerShellWindow->setLayer(LayerShellQt::Window::LayerOverlay); layerShellWindow->setExclusiveZone(-1); + layerShellWindow->setDesiredOutput(screen); } } + setScreen(screen); setColor(Qt::transparent); setDefaultAlphaBuffer(true); setClearBeforeRendering(true); diff --git a/ksplash/ksplashqml/splashwindow.h b/ksplash/ksplashqml/splashwindow.h index a8a932335..6c2def05f 100644 --- a/ksplash/ksplashqml/splashwindow.h +++ b/ksplash/ksplashqml/splashwindow.h @@ -6,6 +6,8 @@ #pragma once +#include + #include class QMouseEvent; @@ -14,7 +16,7 @@ class QKeyEvent; class SplashWindow : public KQuickAddons::QuickViewSharedEngine { public: - SplashWindow(bool testing, bool window, const QString &theme); + SplashWindow(bool testing, bool window, const QString &theme, QScreen *screen); void setStage(int stage); virtual void setGeometry(const QRect &rect); diff --git a/logout-greeter/greeter.cpp b/logout-greeter/greeter.cpp index 54a7cc934..0c25700df 100644 --- a/logout-greeter/greeter.cpp +++ b/logout-greeter/greeter.cpp @@ -60,7 +60,7 @@ void Greeter::adoptScreen(QScreen *screen) return; } // TODO: last argument is the theme, maybe add command line option for it? - KSMShutdownDlg *w = new KSMShutdownDlg(nullptr, m_shutdownType); + KSMShutdownDlg *w = new KSMShutdownDlg(nullptr, m_shutdownType, screen); w->installEventFilter(this); m_dialogs << w; @@ -72,7 +72,6 @@ void Greeter::adoptScreen(QScreen *screen) connect(w, &KSMShutdownDlg::accepted, this, []() { QApplication::exit(1); }); - w->setScreen(screen); w->setGeometry(screen->geometry()); w->init(); } diff --git a/logout-greeter/shutdowndlg.cpp b/logout-greeter/shutdowndlg.cpp index bb16a2f4c..a22d115a4 100644 --- a/logout-greeter/shutdowndlg.cpp +++ b/logout-greeter/shutdowndlg.cpp @@ -54,7 +54,7 @@ static const QString s_dbusPropertiesInterface = QStringLiteral("org.freedesktop static const QString s_login1ManagerInterface = QStringLiteral("org.freedesktop.login1.Manager"); static const QString s_login1RebootToFirmwareSetup = QStringLiteral("RebootToFirmwareSetup"); -KSMShutdownDlg::KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype) +KSMShutdownDlg::KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype, QScreen *screen) : QuickViewSharedEngine(parent) , m_result(false) // this is a WType_Popup on purpose. Do not change that! Not @@ -63,6 +63,16 @@ KSMShutdownDlg::KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype) // window stuff setClearBeforeRendering(true); setColor(QColor(Qt::transparent)); + setScreen(screen); + + if (KWindowSystem::isPlatformWayland()) { + if (auto w = LayerShellQt::Window::get(this)) { + w->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityExclusive); + w->setExclusiveZone(-1); + w->setLayer(LayerShellQt::Window::LayerOverlay); + w->setDesiredOutput(screen); + } + } setResizeMode(KQuickAddons::QuickViewSharedEngine::SizeRootObjectToView); @@ -189,13 +199,6 @@ void KSMShutdownDlg::init() setKeyboardGrabEnabled(true); KWindowEffects::enableBlurBehind(this, true); - if (KWindowSystem::isPlatformWayland()) { - if (auto w = LayerShellQt::Window::get(this)) { - w->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityExclusive); - w->setExclusiveZone(-1); - w->setLayer(LayerShellQt::Window::LayerOverlay); - } - } } void KSMShutdownDlg::resizeEvent(QResizeEvent *e) diff --git a/logout-greeter/shutdowndlg.h b/logout-greeter/shutdowndlg.h index fbdd03e96..556f93526 100644 --- a/logout-greeter/shutdowndlg.h +++ b/logout-greeter/shutdowndlg.h @@ -8,6 +8,8 @@ #pragma once +#include + #include #include #include @@ -18,7 +20,7 @@ class KSMShutdownDlg : public KQuickAddons::QuickViewSharedEngine Q_OBJECT public: - KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype); + KSMShutdownDlg(QWindow *parent, KWorkSpace::ShutdownType sdtype, QScreen *screen); void init(); bool result() const;