2017-11-08 11:25:15 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright 2015 Marco Martin <mart@kde.org> *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU Library General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU Library General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "fullscreenpanel.h"
|
|
|
|
|
|
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QGuiApplication>
|
|
|
|
|
|
|
|
|
|
#include <kwindowsystem.h>
|
|
|
|
|
|
2018-02-10 13:42:38 +00:00
|
|
|
#include <KWayland/Client/connection_thread.h>
|
|
|
|
|
#include <KWayland/Client/plasmashell.h>
|
|
|
|
|
#include <KWayland/Client/registry.h>
|
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
#include <KWayland/Client/shell.h>
|
|
|
|
|
|
2017-11-08 11:25:15 +00:00
|
|
|
FullScreenPanel::FullScreenPanel(QQuickWindow *parent)
|
|
|
|
|
: QQuickWindow(parent)
|
|
|
|
|
{
|
2018-02-11 10:45:57 +00:00
|
|
|
setFlags(Qt::FramelessWindowHint);
|
|
|
|
|
setWindowState(Qt::WindowFullScreen);
|
2017-11-08 11:25:15 +00:00
|
|
|
// connect(this, &FullScreenPanel::activeFocusItemChanged, this, [this]() {qWarning()<<"hide()";});
|
|
|
|
|
connect(this, &QWindow::activeChanged, this, &FullScreenPanel::activeChanged);
|
2018-02-10 13:42:38 +00:00
|
|
|
initWayland();
|
2017-11-08 11:25:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FullScreenPanel::~FullScreenPanel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-10 13:42:38 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
);
|
2018-02-11 10:45:57 +00:00
|
|
|
/*
|
2018-02-10 13:42:38 +00:00
|
|
|
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);
|
|
|
|
|
}
|
2018-02-11 10:45:57 +00:00
|
|
|
);*/
|
2018-02-10 13:42:38 +00:00
|
|
|
registry->setup();
|
|
|
|
|
connection->roundtrip();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-08 11:25:15 +00:00
|
|
|
void FullScreenPanel::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
2018-02-10 13:42:38 +00:00
|
|
|
using namespace KWayland::Client;
|
2017-11-08 11:25:15 +00:00
|
|
|
QQuickWindow::showEvent(event);
|
2018-02-12 08:37:12 +00:00
|
|
|
// setWindowState(Qt::WindowFullScreen);
|
2017-11-08 11:25:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "fullscreenpanel.moc"
|
|
|
|
|
|