2021-03-01 20:03:25 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
2016-08-24 14:57:15 +00:00
|
|
|
|
|
|
|
|
#include "taskpanel.h"
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QQuickItem>
|
|
|
|
|
#include <QQuickWindow>
|
|
|
|
|
#include <QtQml>
|
|
|
|
|
|
|
|
|
|
#include <KWayland/Client/connection_thread.h>
|
2021-08-31 00:02:17 +00:00
|
|
|
#include <KWayland/Client/output.h>
|
2016-08-24 14:57:15 +00:00
|
|
|
#include <KWayland/Client/plasmashell.h>
|
|
|
|
|
#include <KWayland/Client/plasmawindowmanagement.h>
|
|
|
|
|
#include <KWayland/Client/registry.h>
|
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
#include <Plasma/Package>
|
|
|
|
|
|
2021-02-24 01:05:41 +00:00
|
|
|
#include <virtualkeyboardinterface.h>
|
|
|
|
|
|
2022-04-24 11:44:41 +00:00
|
|
|
TaskPanel::TaskPanel(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
|
|
|
|
: Plasma::Containment(parent, data, args)
|
2016-08-24 14:57:15 +00:00
|
|
|
{
|
|
|
|
|
setHasConfigurationInterface(true);
|
2017-09-14 10:07:05 +00:00
|
|
|
initWayland();
|
2021-02-24 01:05:41 +00:00
|
|
|
|
2021-08-31 00:02:17 +00:00
|
|
|
qmlRegisterUncreatableType<KWayland::Client::Output>("org.kde.plasma.phone.taskpanel", 1, 0, "Output", "nope");
|
2021-08-25 20:57:45 +00:00
|
|
|
|
|
|
|
|
connect(this, &Plasma::Containment::locationChanged, this, &TaskPanel::locationChanged);
|
|
|
|
|
connect(this, &Plasma::Containment::locationChanged, this, [this] {
|
|
|
|
|
auto l = location();
|
|
|
|
|
setFormFactor(l == Plasma::Types::LeftEdge || l == Plasma::Types::RightEdge ? Plasma::Types::Vertical : Plasma::Types::Horizontal);
|
|
|
|
|
});
|
2016-08-24 14:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TaskPanel::initWayland()
|
|
|
|
|
{
|
|
|
|
|
if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
ConnectionThread *connection = ConnectionThread::fromApplication(this);
|
2020-07-23 11:47:40 +00:00
|
|
|
|
2016-08-24 14:57:15 +00:00
|
|
|
if (!connection) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-06 21:18:20 +00:00
|
|
|
|
2019-05-03 14:19:31 +00:00
|
|
|
auto *registry = new Registry(this);
|
2016-08-24 14:57:15 +00:00
|
|
|
registry->create(connection);
|
2022-04-06 21:18:20 +00:00
|
|
|
|
2016-08-24 14:57:15 +00:00
|
|
|
connect(registry, &Registry::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) {
|
|
|
|
|
m_shellInterface = registry->createPlasmaShell(name, version, this);
|
2021-03-19 07:52:22 +00:00
|
|
|
|
2016-08-25 09:59:48 +00:00
|
|
|
if (!m_panel) {
|
|
|
|
|
return;
|
2016-08-24 14:57:15 +00:00
|
|
|
}
|
|
|
|
|
Surface *s = Surface::fromWindow(m_panel);
|
|
|
|
|
if (!s) {
|
2021-03-19 07:52:22 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2016-08-24 14:57:15 +00:00
|
|
|
m_shellSurface = m_shellInterface->createSurface(s, this);
|
2016-08-25 09:59:48 +00:00
|
|
|
m_shellSurface->setSkipTaskbar(true);
|
2021-03-19 07:52:22 +00:00
|
|
|
});
|
2016-08-24 14:57:15 +00:00
|
|
|
registry->setup();
|
2017-09-14 09:41:15 +00:00
|
|
|
connection->roundtrip();
|
2016-08-24 14:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWindow *TaskPanel::panel()
|
|
|
|
|
{
|
|
|
|
|
return m_panel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TaskPanel::setPanel(QWindow *panel)
|
|
|
|
|
{
|
|
|
|
|
if (panel == m_panel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 11:01:07 +00:00
|
|
|
if (m_panel) {
|
|
|
|
|
disconnect(m_panel, &QWindow::visibilityChanged, this, &TaskPanel::updatePanelVisibility);
|
|
|
|
|
}
|
2016-08-24 14:57:15 +00:00
|
|
|
m_panel = panel;
|
2017-09-14 11:01:07 +00:00
|
|
|
connect(m_panel, &QWindow::visibilityChanged, this, &TaskPanel::updatePanelVisibility, Qt::QueuedConnection);
|
2022-02-13 04:23:57 +00:00
|
|
|
Q_EMIT panelChanged();
|
2017-09-14 11:01:07 +00:00
|
|
|
updatePanelVisibility();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-13 04:23:57 +00:00
|
|
|
void TaskPanel::setPanelHeight(qreal height)
|
|
|
|
|
{
|
|
|
|
|
if (m_panel) {
|
|
|
|
|
m_panel->setHeight(height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 11:01:07 +00:00
|
|
|
void TaskPanel::updatePanelVisibility()
|
|
|
|
|
{
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
if (!m_panel->isVisible()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Surface *s = Surface::fromWindow(m_panel);
|
2016-08-24 14:57:15 +00:00
|
|
|
|
|
|
|
|
if (!s) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-08-25 09:59:48 +00:00
|
|
|
|
2016-08-24 14:57:15 +00:00
|
|
|
m_shellSurface = m_shellInterface->createSurface(s, this);
|
2016-08-25 09:59:48 +00:00
|
|
|
if (m_shellSurface) {
|
|
|
|
|
m_shellSurface->setSkipTaskbar(true);
|
|
|
|
|
}
|
2016-08-24 14:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-19 12:17:22 +00:00
|
|
|
K_PLUGIN_CLASS_WITH_JSON(TaskPanel, "package/metadata.json")
|
2016-08-24 14:57:15 +00:00
|
|
|
|
|
|
|
|
#include "taskpanel.moc"
|