2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2012-08-30 06:20:26 +00:00
|
|
|
|
|
|
|
// own
|
|
|
|
#include "dbusinterface.h"
|
2014-06-02 06:51:28 +00:00
|
|
|
#include "compositingadaptor.h"
|
2020-11-07 19:34:55 +00:00
|
|
|
#include "pluginsadaptor.h"
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
#include "virtualdesktopmanageradaptor.h"
|
2012-12-29 23:15:30 +00:00
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
// kwin
|
2015-01-23 08:06:05 +00:00
|
|
|
#include "atoms.h"
|
2014-06-02 06:51:28 +00:00
|
|
|
#include "composite.h"
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/output.h"
|
|
|
|
#include "core/renderbackend.h"
|
2016-03-14 09:23:52 +00:00
|
|
|
#include "debug_console.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "kwinadaptor.h"
|
2014-06-02 06:51:28 +00:00
|
|
|
#include "main.h"
|
2013-07-28 15:42:21 +00:00
|
|
|
#include "placement.h"
|
2020-11-07 19:34:55 +00:00
|
|
|
#include "pluginmanager.h"
|
2020-10-29 21:28:06 +00:00
|
|
|
#include "unmanaged.h"
|
2012-11-16 07:23:47 +00:00
|
|
|
#include "virtualdesktops.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "workspace.h"
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2013-04-04 14:14:12 +00:00
|
|
|
#include "activities.h"
|
|
|
|
#endif
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2012-12-29 23:15:30 +00:00
|
|
|
// Qt
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <QOpenGLContext>
|
2012-12-29 23:15:30 +00:00
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
DBusInterface::DBusInterface(QObject *parent)
|
|
|
|
: QObject(parent)
|
2014-10-13 20:35:04 +00:00
|
|
|
, m_serviceName(QStringLiteral("org.kde.KWin"))
|
2012-08-30 06:20:26 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
(void)new KWinAdaptor(this);
|
2012-08-30 06:20:26 +00:00
|
|
|
|
|
|
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
2013-07-23 05:02:52 +00:00
|
|
|
dbus.registerObject(QStringLiteral("/KWin"), this);
|
2022-07-19 07:16:27 +00:00
|
|
|
dbus.registerService(m_serviceName);
|
2013-07-23 05:02:52 +00:00
|
|
|
dbus.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"),
|
2012-08-30 06:20:26 +00:00
|
|
|
Workspace::self(), SLOT(slotReloadConfig()));
|
2022-07-15 12:58:12 +00:00
|
|
|
|
|
|
|
connect(Workspace::self(), &Workspace::showingDesktopChanged, this, &DBusInterface::onShowingDesktopChanged);
|
2012-12-29 23:15:30 +00:00
|
|
|
}
|
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
DBusInterface::~DBusInterface()
|
|
|
|
{
|
2014-10-13 20:35:04 +00:00
|
|
|
QDBusConnection::sessionBus().unregisterService(m_serviceName);
|
2012-08-30 06:20:26 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 12:58:12 +00:00
|
|
|
bool DBusInterface::showingDesktop() const
|
|
|
|
{
|
|
|
|
return workspace()->showingDesktop();
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:18:25 +00:00
|
|
|
void DBusInterface::reconfigure()
|
|
|
|
{
|
|
|
|
Workspace::self()->reconfigure();
|
|
|
|
}
|
2012-11-22 10:07:33 +00:00
|
|
|
|
2013-04-08 12:30:24 +00:00
|
|
|
void DBusInterface::killWindow()
|
|
|
|
{
|
|
|
|
Workspace::self()->slotKillWindow();
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:18:25 +00:00
|
|
|
void DBusInterface::cascadeDesktop()
|
|
|
|
{
|
|
|
|
workspace()->placement()->cascadeDesktop();
|
|
|
|
}
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2023-01-11 14:18:25 +00:00
|
|
|
void DBusInterface::unclutterDesktop()
|
|
|
|
{
|
|
|
|
workspace()->placement()->unclutterDesktop();
|
|
|
|
}
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2023-01-11 14:18:25 +00:00
|
|
|
QString DBusInterface::supportInformation()
|
|
|
|
{
|
|
|
|
return Workspace::self()->supportInformation();
|
|
|
|
}
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2022-04-07 21:26:47 +00:00
|
|
|
QString DBusInterface::activeOutputName()
|
|
|
|
{
|
|
|
|
return Workspace::self()->activeOutput()->name();
|
|
|
|
}
|
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
bool DBusInterface::startActivity(const QString &in0)
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2022-07-20 10:53:54 +00:00
|
|
|
if (!Workspace::self()->activities()) {
|
2015-07-07 09:48:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-07-20 10:53:54 +00:00
|
|
|
return Workspace::self()->activities()->start(in0);
|
2013-04-04 14:14:12 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2012-08-30 06:20:26 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
bool DBusInterface::stopActivity(const QString &in0)
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2022-07-20 10:53:54 +00:00
|
|
|
if (!Workspace::self()->activities()) {
|
2015-07-07 09:48:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-07-20 10:53:54 +00:00
|
|
|
return Workspace::self()->activities()->stop(in0);
|
2013-04-04 14:14:12 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2012-11-16 07:23:47 +00:00
|
|
|
int DBusInterface::currentDesktop()
|
|
|
|
{
|
|
|
|
return VirtualDesktopManager::self()->current();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DBusInterface::setCurrentDesktop(int desktop)
|
|
|
|
{
|
|
|
|
return VirtualDesktopManager::self()->setCurrent(desktop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DBusInterface::nextDesktop()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
VirtualDesktopManager::self()->moveTo(VirtualDesktopManager::Direction::Next);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DBusInterface::previousDesktop()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
VirtualDesktopManager::self()->moveTo(VirtualDesktopManager::Direction::Previous);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
2016-03-14 09:23:52 +00:00
|
|
|
void DBusInterface::showDebugConsole()
|
|
|
|
{
|
|
|
|
DebugConsole *console = new DebugConsole;
|
|
|
|
console->show();
|
|
|
|
}
|
2014-06-02 06:51:28 +00:00
|
|
|
|
2021-01-30 00:37:13 +00:00
|
|
|
void DBusInterface::replace()
|
|
|
|
{
|
|
|
|
QCoreApplication::exit(133);
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
namespace
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
QVariantMap clientToVariantMap(const Window *c)
|
2018-12-08 16:06:51 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
return
|
|
|
|
{
|
2018-12-08 16:06:51 +00:00
|
|
|
{QStringLiteral("resourceClass"), c->resourceClass()},
|
2022-03-23 10:13:38 +00:00
|
|
|
{QStringLiteral("resourceName"), c->resourceName()},
|
|
|
|
{QStringLiteral("desktopFile"), c->desktopFileName()},
|
|
|
|
{QStringLiteral("role"), c->windowRole()},
|
|
|
|
{QStringLiteral("caption"), c->captionNormal()},
|
|
|
|
{QStringLiteral("clientMachine"), c->wmClientMachine(true)},
|
|
|
|
{QStringLiteral("localhost"), c->isLocalhost()},
|
|
|
|
{QStringLiteral("type"), c->windowType()},
|
|
|
|
{QStringLiteral("x"), c->x()},
|
|
|
|
{QStringLiteral("y"), c->y()},
|
|
|
|
{QStringLiteral("width"), c->width()},
|
|
|
|
{QStringLiteral("height"), c->height()},
|
|
|
|
{QStringLiteral("desktops"), c->desktopIds()},
|
|
|
|
{QStringLiteral("minimized"), c->isMinimized()},
|
|
|
|
{QStringLiteral("shaded"), c->isShade()},
|
|
|
|
{QStringLiteral("fullscreen"), c->isFullScreen()},
|
|
|
|
{QStringLiteral("keepAbove"), c->keepAbove()},
|
|
|
|
{QStringLiteral("keepBelow"), c->keepBelow()},
|
|
|
|
{QStringLiteral("noBorder"), c->noBorder()},
|
|
|
|
{QStringLiteral("skipTaskbar"), c->skipTaskbar()},
|
|
|
|
{QStringLiteral("skipPager"), c->skipPager()},
|
|
|
|
{QStringLiteral("skipSwitcher"), c->skipSwitcher()},
|
|
|
|
{QStringLiteral("maximizeHorizontal"), c->maximizeMode() & MaximizeHorizontal},
|
|
|
|
{QStringLiteral("maximizeVertical"), c->maximizeMode() & MaximizeVertical},
|
2023-01-13 15:14:53 +00:00
|
|
|
{QStringLiteral("uuid"), c->internalId().toString()},
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2022-03-23 10:13:38 +00:00
|
|
|
{QStringLiteral("activities"), c->activities()},
|
2021-01-04 18:06:11 +00:00
|
|
|
#endif
|
2018-12-08 16:06:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-12 20:40:05 +00:00
|
|
|
QVariantMap DBusInterface::queryWindowInfo()
|
|
|
|
{
|
|
|
|
m_replyQueryWindowInfo = message();
|
|
|
|
setDelayedReply(true);
|
2022-11-05 10:14:59 +00:00
|
|
|
kwinApp()->startInteractiveWindowSelection(
|
2022-04-22 17:39:12 +00:00
|
|
|
[this](Window *t) {
|
2022-04-18 08:24:28 +00:00
|
|
|
if (!t) {
|
2020-10-29 21:28:06 +00:00
|
|
|
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply(
|
|
|
|
QStringLiteral("org.kde.KWin.Error.UserCancel"),
|
|
|
|
QStringLiteral("User cancelled the query")));
|
2022-04-18 08:24:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (t->isClient()) {
|
|
|
|
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(t)));
|
|
|
|
} else {
|
|
|
|
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply(
|
|
|
|
QStringLiteral("org.kde.KWin.Error.InvalidWindow"),
|
|
|
|
QStringLiteral("Tried to query information about an unmanaged window")));
|
2018-02-12 20:40:05 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2018-02-12 20:40:05 +00:00
|
|
|
return QVariantMap{};
|
|
|
|
}
|
|
|
|
|
2018-12-08 16:06:51 +00:00
|
|
|
QVariantMap DBusInterface::getWindowInfo(const QString &uuid)
|
|
|
|
{
|
|
|
|
const auto id = QUuid::fromString(uuid);
|
2022-04-22 17:39:12 +00:00
|
|
|
const auto client = workspace()->findAbstractClient([&id](const Window *c) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return c->internalId() == id;
|
|
|
|
});
|
2018-12-08 16:06:51 +00:00
|
|
|
if (client) {
|
|
|
|
return clientToVariantMap(client);
|
|
|
|
} else {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-15 12:58:12 +00:00
|
|
|
void DBusInterface::showDesktop(bool show)
|
|
|
|
{
|
|
|
|
workspace()->setShowingDesktop(show, true);
|
|
|
|
|
|
|
|
auto m = message();
|
|
|
|
if (m.service().isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep track of whatever D-Bus client asked to show the desktop. If
|
|
|
|
// they disappear from the bus, cancel the show desktop state so we do
|
|
|
|
// not end up in a state where we are stuck showing the desktop.
|
|
|
|
static QPointer<QDBusServiceWatcher> watcher;
|
|
|
|
|
|
|
|
if (show) {
|
|
|
|
if (watcher) {
|
|
|
|
// If we get a second call to `showDesktop(true)`, drop the previous
|
|
|
|
// watcher and watch the new client. That way, we simply always
|
|
|
|
// track the last state.
|
|
|
|
watcher->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
watcher = new QDBusServiceWatcher(m.service(), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration, this);
|
|
|
|
connect(watcher, &QDBusServiceWatcher::serviceUnregistered, []() {
|
|
|
|
workspace()->setShowingDesktop(false, true);
|
|
|
|
watcher->deleteLater();
|
|
|
|
});
|
|
|
|
} else if (watcher) {
|
|
|
|
// Someone cancelled showing the desktop, so there's no more need to
|
|
|
|
// watch to cancel the show desktop state.
|
|
|
|
watcher->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DBusInterface::onShowingDesktopChanged(bool show, bool /*animated*/)
|
|
|
|
{
|
|
|
|
Q_EMIT showingDesktopChanged(show);
|
|
|
|
}
|
|
|
|
|
2014-06-02 06:51:28 +00:00
|
|
|
CompositorDBusInterface::CompositorDBusInterface(Compositor *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_compositor(parent)
|
|
|
|
{
|
|
|
|
connect(m_compositor, &Compositor::compositingToggled, this, &CompositorDBusInterface::compositingToggled);
|
|
|
|
new CompositingAdaptor(this);
|
|
|
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
|
|
|
dbus.registerObject(QStringLiteral("/Compositor"), this);
|
|
|
|
dbus.connect(QString(), QStringLiteral("/Compositor"), QStringLiteral("org.kde.kwin.Compositing"),
|
2019-07-02 18:28:45 +00:00
|
|
|
QStringLiteral("reinit"), this, SLOT(reinitialize()));
|
2014-06-02 06:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString CompositorDBusInterface::compositingType() const
|
|
|
|
{
|
2021-11-10 10:34:18 +00:00
|
|
|
if (!m_compositor->compositing()) {
|
2014-06-02 06:51:28 +00:00
|
|
|
return QStringLiteral("none");
|
|
|
|
}
|
2021-11-10 10:34:18 +00:00
|
|
|
switch (m_compositor->backend()->compositingType()) {
|
2021-06-09 12:10:25 +00:00
|
|
|
case OpenGLCompositing:
|
2015-10-30 12:18:30 +00:00
|
|
|
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
|
|
|
return QStringLiteral("gles");
|
|
|
|
} else {
|
|
|
|
return QStringLiteral("gl2");
|
|
|
|
}
|
2014-06-02 06:51:28 +00:00
|
|
|
case QPainterCompositing:
|
2015-01-24 02:13:45 +00:00
|
|
|
return QStringLiteral("qpainter");
|
2014-06-02 06:51:28 +00:00
|
|
|
case NoCompositing:
|
|
|
|
default:
|
|
|
|
return QStringLiteral("none");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CompositorDBusInterface::isActive() const
|
|
|
|
{
|
|
|
|
return m_compositor->isActive();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CompositorDBusInterface::isCompositingPossible() const
|
|
|
|
{
|
2022-11-02 18:47:01 +00:00
|
|
|
return m_compositor->compositingPossible();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CompositorDBusInterface::compositingNotPossibleReason() const
|
|
|
|
{
|
|
|
|
return m_compositor->compositingNotPossibleReason();
|
2014-06-02 06:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CompositorDBusInterface::isOpenGLBroken() const
|
|
|
|
{
|
2022-11-02 18:47:01 +00:00
|
|
|
return m_compositor->openGLCompositingIsBroken();
|
2014-06-02 06:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 10:56:25 +00:00
|
|
|
bool CompositorDBusInterface::platformRequiresCompositing() const
|
|
|
|
{
|
2022-11-02 18:34:25 +00:00
|
|
|
return kwinApp()->operationMode() != Application::OperationModeX11; // TODO: Remove this property?
|
2016-08-26 10:56:25 +00:00
|
|
|
}
|
|
|
|
|
2014-06-02 06:51:28 +00:00
|
|
|
void CompositorDBusInterface::resume()
|
|
|
|
{
|
2019-08-07 17:33:20 +00:00
|
|
|
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
2022-03-23 10:13:38 +00:00
|
|
|
static_cast<X11Compositor *>(m_compositor)->resume(X11Compositor::ScriptSuspend);
|
2019-08-07 17:33:20 +00:00
|
|
|
}
|
2014-06-02 06:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompositorDBusInterface::suspend()
|
|
|
|
{
|
2019-08-07 17:33:20 +00:00
|
|
|
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
2022-03-23 10:13:38 +00:00
|
|
|
static_cast<X11Compositor *>(m_compositor)->suspend(X11Compositor::ScriptSuspend);
|
2019-08-07 17:33:20 +00:00
|
|
|
}
|
2014-06-02 06:51:28 +00:00
|
|
|
}
|
|
|
|
|
2019-07-02 18:28:45 +00:00
|
|
|
void CompositorDBusInterface::reinitialize()
|
|
|
|
{
|
2019-07-02 20:30:27 +00:00
|
|
|
m_compositor->reinitialize();
|
2019-07-02 18:28:45 +00:00
|
|
|
}
|
|
|
|
|
2014-06-02 06:51:28 +00:00
|
|
|
QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const
|
|
|
|
{
|
|
|
|
QStringList interfaces;
|
2015-10-30 10:50:31 +00:00
|
|
|
bool supportsGlx = false;
|
|
|
|
#if HAVE_EPOXY_GLX
|
|
|
|
supportsGlx = (kwinApp()->operationMode() == Application::OperationModeX11);
|
|
|
|
#endif
|
2015-10-30 12:18:30 +00:00
|
|
|
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
|
|
|
supportsGlx = false;
|
|
|
|
}
|
2014-06-02 06:51:28 +00:00
|
|
|
if (supportsGlx) {
|
|
|
|
interfaces << QStringLiteral("glx");
|
|
|
|
}
|
|
|
|
interfaces << QStringLiteral("egl");
|
|
|
|
return interfaces;
|
|
|
|
}
|
|
|
|
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
VirtualDesktopManagerDBusInterface::VirtualDesktopManagerDBusInterface(VirtualDesktopManager *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_manager(parent)
|
|
|
|
{
|
|
|
|
qDBusRegisterMetaType<KWin::DBusDesktopDataStruct>();
|
|
|
|
qDBusRegisterMetaType<KWin::DBusDesktopDataVector>();
|
|
|
|
|
|
|
|
new VirtualDesktopManagerAdaptor(this);
|
|
|
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/VirtualDesktopManager"),
|
2022-03-23 10:13:38 +00:00
|
|
|
QStringLiteral("org.kde.KWin.VirtualDesktopManager"),
|
|
|
|
this);
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_manager, &VirtualDesktopManager::currentChanged, this, [this](uint previousDesktop, uint newDesktop) {
|
|
|
|
Q_EMIT currentChanged(m_manager->currentDesktop()->id());
|
|
|
|
});
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_manager, &VirtualDesktopManager::countChanged, this, [this](uint previousCount, uint newCount) {
|
|
|
|
Q_EMIT countChanged(newCount);
|
|
|
|
Q_EMIT desktopsChanged(desktops());
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(m_manager, &VirtualDesktopManager::navigationWrappingAroundChanged, this, [this]() {
|
|
|
|
Q_EMIT navigationWrappingAroundChanged(isNavigationWrappingAround());
|
|
|
|
});
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
|
|
|
|
connect(m_manager, &VirtualDesktopManager::rowsChanged, this, &VirtualDesktopManagerDBusInterface::rowsChanged);
|
|
|
|
|
2021-08-22 11:59:17 +00:00
|
|
|
const QVector<VirtualDesktop *> allDesks = m_manager->desktops();
|
|
|
|
for (auto *vd : allDesks) {
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, [this, vd]() {
|
|
|
|
DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};
|
|
|
|
Q_EMIT desktopDataChanged(vd->id(), data);
|
|
|
|
Q_EMIT desktopsChanged(desktops());
|
|
|
|
});
|
|
|
|
connect(vd, &VirtualDesktop::nameChanged, this, [this, vd]() {
|
|
|
|
DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};
|
|
|
|
Q_EMIT desktopDataChanged(vd->id(), data);
|
|
|
|
Q_EMIT desktopsChanged(desktops());
|
|
|
|
});
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_manager, &VirtualDesktopManager::desktopCreated, this, [this](VirtualDesktop *vd) {
|
|
|
|
connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, [this, vd]() {
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT desktopDataChanged(vd->id(), data);
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT desktopsChanged(desktops());
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
|
|
|
connect(vd, &VirtualDesktop::nameChanged, this, [this, vd]() {
|
|
|
|
DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};
|
|
|
|
Q_EMIT desktopDataChanged(vd->id(), data);
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT desktopsChanged(desktops());
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
|
|
|
DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};
|
|
|
|
Q_EMIT desktopCreated(vd->id(), data);
|
|
|
|
Q_EMIT desktopsChanged(desktops());
|
|
|
|
});
|
|
|
|
connect(m_manager, &VirtualDesktopManager::desktopRemoved, this, [this](VirtualDesktop *vd) {
|
|
|
|
Q_EMIT desktopRemoved(vd->id());
|
|
|
|
Q_EMIT desktopsChanged(desktops());
|
|
|
|
});
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint VirtualDesktopManagerDBusInterface::count() const
|
|
|
|
{
|
|
|
|
return m_manager->count();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktopManagerDBusInterface::setRows(uint rows)
|
|
|
|
{
|
|
|
|
if (static_cast<uint>(m_manager->grid().height()) == rows) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_manager->setRows(rows);
|
|
|
|
m_manager->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint VirtualDesktopManagerDBusInterface::rows() const
|
|
|
|
{
|
|
|
|
return m_manager->rows();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktopManagerDBusInterface::setCurrent(const QString &id)
|
|
|
|
{
|
|
|
|
if (m_manager->currentDesktop()->id() == id) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-16 13:12:56 +00:00
|
|
|
auto *vd = m_manager->desktopForId(id);
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
if (vd) {
|
|
|
|
m_manager->setCurrent(vd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString VirtualDesktopManagerDBusInterface::current() const
|
|
|
|
{
|
|
|
|
return m_manager->currentDesktop()->id();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktopManagerDBusInterface::setNavigationWrappingAround(bool wraps)
|
|
|
|
{
|
|
|
|
if (m_manager->isNavigationWrappingAround() == wraps) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_manager->setNavigationWrappingAround(wraps);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VirtualDesktopManagerDBusInterface::isNavigationWrappingAround() const
|
|
|
|
{
|
|
|
|
return m_manager->isNavigationWrappingAround();
|
|
|
|
}
|
|
|
|
|
|
|
|
DBusDesktopDataVector VirtualDesktopManagerDBusInterface::desktops() const
|
|
|
|
{
|
|
|
|
const auto desks = m_manager->desktops();
|
|
|
|
DBusDesktopDataVector desktopVect;
|
|
|
|
desktopVect.reserve(m_manager->count());
|
|
|
|
|
|
|
|
std::transform(desks.constBegin(), desks.constEnd(),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(desktopVect),
|
|
|
|
[](const VirtualDesktop *vd) {
|
|
|
|
return DBusDesktopDataStruct{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()};
|
|
|
|
});
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
|
|
|
|
return desktopVect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktopManagerDBusInterface::createDesktop(uint position, const QString &name)
|
|
|
|
{
|
2019-01-17 21:12:11 +00:00
|
|
|
m_manager->createVirtualDesktop(position, name);
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktopManagerDBusInterface::setDesktopName(const QString &id, const QString &name)
|
|
|
|
{
|
2021-08-16 13:12:56 +00:00
|
|
|
VirtualDesktop *vd = m_manager->desktopForId(id);
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
if (!vd) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (vd->name() == name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vd->setName(name);
|
|
|
|
m_manager->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktopManagerDBusInterface::removeDesktop(const QString &id)
|
|
|
|
{
|
2021-08-16 13:12:56 +00:00
|
|
|
m_manager->removeVirtualDesktop(id);
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:34:55 +00:00
|
|
|
PluginManagerDBusInterface::PluginManagerDBusInterface(PluginManager *manager)
|
|
|
|
: QObject(manager)
|
|
|
|
, m_manager(manager)
|
|
|
|
{
|
|
|
|
new PluginsAdaptor(this);
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Plugins"),
|
|
|
|
QStringLiteral("org.kde.KWin.Plugins"),
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList PluginManagerDBusInterface::loadedPlugins() const
|
|
|
|
{
|
|
|
|
return m_manager->loadedPlugins();
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList PluginManagerDBusInterface::availablePlugins() const
|
|
|
|
{
|
|
|
|
return m_manager->availablePlugins();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginManagerDBusInterface::LoadPlugin(const QString &name)
|
|
|
|
{
|
|
|
|
return m_manager->loadPlugin(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginManagerDBusInterface::UnloadPlugin(const QString &name)
|
|
|
|
{
|
|
|
|
m_manager->unloadPlugin(name);
|
|
|
|
}
|
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
} // namespace
|