Commit d532b56c authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

ksplash: Use LayerShellQt instead of KWayland::Client::PlasmaShell

Results in cleaner and less involved code.
parent 187f082d
......@@ -77,6 +77,7 @@ find_package(KWinDBusInterface CONFIG REQUIRED)
find_package(KF5Screen CONFIG REQUIRED)
find_package(KScreenLocker 5.13.80 REQUIRED)
find_package(ScreenSaverDBusInterface CONFIG REQUIRED)
find_package(LayerShellQt CONFIG REQUIRED)
find_package(KF5Holidays)
set_package_properties(KF5Holidays PROPERTIES DESCRIPTION "Holidays provider for Plasma calendar"
TYPE OPTIONAL
......
......@@ -14,10 +14,10 @@ target_link_libraries(ksplashqml
KF5::ConfigCore
KF5::Package
KF5::QuickAddons
KF5::WaylandClient
KF5::WindowSystem
KF5::QuickAddons
PW::KWorkspace
LayerShellQt::Interface
)
install(TARGETS ksplashqml ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -30,10 +30,8 @@
#include <qscreen.h>
#include <KQuickAddons/QtQuickSettings>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/registry.h>
#include <KWindowSystem>
#include <LayerShellQt/Shell>
#define TEST_STEP_INTERVAL 2000
......@@ -140,6 +138,7 @@ void SplashApp::adoptScreen(QScreen *screen)
{
SplashWindow *w = new SplashWindow(m_testing, m_window, m_theme);
w->setGeometry(screen->geometry());
w->setScreen(screen);
w->setStage(m_stage);
w->setVisible(true);
m_windows << w;
......@@ -156,16 +155,5 @@ void SplashApp::setupWaylandIntegration()
if (!KWindowSystem::isPlatformWayland()) {
return;
}
using namespace KWayland::Client;
ConnectionThread *connection = ConnectionThread::fromApplication(this);
if (!connection) {
return;
}
Registry *registry = new Registry(this);
registry->create(connection);
connect(registry, &Registry::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) {
m_waylandPlasmaShell = registry->createPlasmaShell(name, version, this);
});
registry->setup();
connection->roundtrip();
LayerShellQt::Shell::useLayerShell();
}
......@@ -27,14 +27,6 @@
class SplashWindow;
namespace KWayland
{
namespace Client
{
class PlasmaShell;
}
}
class SplashApp : public QGuiApplication
{
Q_OBJECT
......@@ -44,11 +36,6 @@ public:
explicit SplashApp(int &argc, char **argv);
~SplashApp() override;
KWayland::Client::PlasmaShell *waylandPlasmaShellInterface() const
{
return m_waylandPlasmaShell;
}
public Q_SLOTS:
Q_SCRIPTABLE void setStage(const QString &messgae);
......@@ -66,8 +53,6 @@ private:
QBasicTimer m_timer;
QString m_theme;
KWayland::Client::PlasmaShell *m_waylandPlasmaShell = nullptr;
private Q_SLOTS:
void adoptScreen(QScreen *);
};
......
......@@ -33,8 +33,6 @@
#include <KPackage/Package>
#include <KPackage/PackageLoader>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/surface.h>
#include <KWindowSystem>
SplashWindow::SplashWindow(bool testing, bool window, const QString &theme)
......@@ -80,23 +78,6 @@ void SplashWindow::setStage(int stage)
rootObject()->setProperty("stage", stage);
}
bool SplashWindow::event(QEvent *e)
{
if (e->type() == QEvent::PlatformSurface) {
auto pe = static_cast<QPlatformSurfaceEvent *>(e);
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
}
return KQuickAddons::QuickViewSharedEngine::event(e);
}
void SplashWindow::keyPressEvent(QKeyEvent *event)
{
KQuickAddons::QuickViewSharedEngine::keyPressEvent(event);
......@@ -133,32 +114,4 @@ void SplashWindow::setGeometry(const QRect &rect)
Q_ASSERT(package.isValid());
setSource(QUrl::fromLocalFile(package.filePath("splashmainscript")));
}
if (m_shellSurface) {
m_shellSurface->setPosition(geometry().topLeft());
}
}
void SplashWindow::setupWaylandIntegration()
{
if (m_shellSurface) {
// already setup
return;
}
if (SplashApp *a = qobject_cast<SplashApp *>(qApp)) {
using namespace KWayland::Client;
PlasmaShell *interface = a->waylandPlasmaShellInterface();
if (!interface) {
return;
}
Surface *s = Surface::fromWindow(this);
if (!s) {
return;
}
m_shellSurface = interface->createSurface(s, this);
// Use OSD to make it go above all other windows
// that's the closest we have to the X11 unmanged layer we have on Wayland
m_shellSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay);
m_shellSurface->setPosition(geometry().topLeft());
}
}
......@@ -25,14 +25,6 @@
class QMouseEvent;
class QKeyEvent;
namespace KWayland
{
namespace Client
{
class PlasmaShellSurface;
}
}
class SplashWindow : public KQuickAddons::QuickViewSharedEngine
{
public:
......@@ -42,17 +34,14 @@ public:
virtual void setGeometry(const QRect &rect);
protected:
bool event(QEvent *e) override;
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
private:
void setupWaylandIntegration();
int m_stage;
const bool m_testing;
const bool m_window;
const QString m_theme;
KWayland::Client::PlasmaShellSurface *m_shellSurface = nullptr;
};
#endif // SPLASH_WINDOW_H_
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment