From 02fd43edb80f560e7185026bef778539c90263a6 Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Sat, 10 Feb 2018 19:12:38 +0530 Subject: [PATCH] use wayland to fullscreen and skip taskbar doesn't work for now --- components/fullscreenpanel.cpp | 62 +++++++++++++++++++++++++++++++--- components/fullscreenpanel.h | 21 +++++++++++- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/components/fullscreenpanel.cpp b/components/fullscreenpanel.cpp index d42a9449..cbea393b 100644 --- a/components/fullscreenpanel.cpp +++ b/components/fullscreenpanel.cpp @@ -26,24 +26,78 @@ #include +#include +#include +#include +#include +#include + FullScreenPanel::FullScreenPanel(QQuickWindow *parent) : QQuickWindow(parent) { - setFlags(Qt::FramelessWindowHint); - setWindowState(Qt::WindowFullScreen); + //setFlags(Qt::FramelessWindowHint); + //setWindowState(Qt::WindowFullScreen); // connect(this, &FullScreenPanel::activeFocusItemChanged, this, [this]() {qWarning()<<"hide()";}); connect(this, &QWindow::activeChanged, this, &FullScreenPanel::activeChanged); + initWayland(); } FullScreenPanel::~FullScreenPanel() { } +void FullScreenPanel::initWayland() +{ + if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + return; + } + using namespace KWayland::Client; + ConnectionThread *connection = ConnectionThread::fromApplication(this); + if (!connection) { + return; + } + Registry *registry = new Registry(this); + registry->create(connection); + + m_surface = Surface::fromWindow(this); + if (!m_surface) { + return; + } + connect(registry, &Registry::plasmaShellAnnounced, this, + [this, registry] (quint32 name, quint32 version) { + + m_plasmaShellInterface = registry->createPlasmaShell(name, version, this); + + m_plasmaShellSurface = m_plasmaShellInterface->createSurface(m_surface, this); + m_plasmaShellSurface->setSkipTaskbar(true); + } + ); + connect(registry, &Registry::shellAnnounced, this, + [this, registry] (quint32 name, quint32 version) { + + m_shellInterface = registry->createShell(name, version, this); + if (!m_shellInterface) { + return; + } + //bshah: following code results in error... + //wl_surface@67: error 0: ShellSurface already created + //Wayland display got fatal error 71: Protocol error + //Additionally, errno was set to 71: Protocol error + m_shellSurface = m_shellInterface->createSurface(m_surface, this); + } + ); + registry->setup(); + connection->roundtrip(); +} + void FullScreenPanel::showEvent(QShowEvent *event) { + using namespace KWayland::Client; QQuickWindow::showEvent(event); - setWindowState(Qt::WindowFullScreen); - KWindowSystem::setState(winId(), NET::SkipTaskbar); + + if (m_shellSurface) { + m_shellSurface->setFullscreen(); + } } diff --git a/components/fullscreenpanel.h b/components/fullscreenpanel.h index beb893f7..310d12b4 100644 --- a/components/fullscreenpanel.h +++ b/components/fullscreenpanel.h @@ -21,6 +21,19 @@ #include +namespace KWayland +{ +namespace Client +{ +class PlasmaWindow; +class PlasmaShell; +class PlasmaShellSurface; +class Shell; +class ShellSurface; +class Surface; +} +} + class FullScreenPanel : public QQuickWindow { Q_OBJECT @@ -36,7 +49,13 @@ Q_SIGNALS: protected: void showEvent(QShowEvent *event); - +private: + void initWayland(); + KWayland::Client::PlasmaShellSurface *m_plasmaShellSurface = nullptr; + KWayland::Client::ShellSurface *m_shellSurface = nullptr; + KWayland::Client::Surface *m_surface = nullptr; + KWayland::Client::PlasmaShell *m_plasmaShellInterface = nullptr; + KWayland::Client::Shell *m_shellInterface = nullptr; }; #endif