2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2015-02-09 12:28:37 +00:00
|
|
|
#include "wayland_server.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
|
|
|
|
#include <config-kwin.h>
|
|
|
|
|
2020-08-07 13:28:49 +00:00
|
|
|
#include "abstract_wayland_output.h"
|
2015-03-04 08:21:10 +00:00
|
|
|
#include "composite.h"
|
2017-11-16 20:48:19 +00:00
|
|
|
#include "idle_inhibition.h"
|
2020-09-04 07:03:04 +00:00
|
|
|
#include "inputpanelv1integration.h"
|
2021-10-02 08:26:51 +00:00
|
|
|
#include "keyboard_input.h"
|
2020-08-07 19:01:42 +00:00
|
|
|
#include "layershellv1integration.h"
|
2020-11-07 02:03:57 +00:00
|
|
|
#include "main.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "platform.h"
|
|
|
|
#include "screens.h"
|
2020-11-04 13:35:37 +00:00
|
|
|
#include "unmanaged.h"
|
2022-01-13 14:02:41 +00:00
|
|
|
#include "utils/serviceutils.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "virtualdesktops.h"
|
2021-04-04 14:11:13 +00:00
|
|
|
#include "waylandoutput.h"
|
2021-07-21 10:11:21 +00:00
|
|
|
#include "waylandoutputdevicev2.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "x11client.h"
|
|
|
|
#include "xdgactivationv1.h"
|
|
|
|
#include "xdgshellclient.h"
|
|
|
|
#include "xdgshellintegration.h"
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2015-04-02 12:37:23 +00:00
|
|
|
// Server
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/appmenu_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/blur_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/compositor_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/datacontroldevicemanager_v1_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/datadevicemanager_interface.h>
|
|
|
|
#include <KWaylandServer/datasource_interface.h>
|
|
|
|
#include <KWaylandServer/display.h>
|
|
|
|
#include <KWaylandServer/dpms_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/filtered_display.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/idle_interface.h>
|
2020-07-22 20:21:12 +00:00
|
|
|
#include <KWaylandServer/idleinhibit_v1_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/inputmethod_v1_interface.h>
|
|
|
|
#include <KWaylandServer/keyboard_shortcuts_inhibit_v1_interface.h>
|
|
|
|
#include <KWaylandServer/keystate_interface.h>
|
2021-07-20 19:37:03 +00:00
|
|
|
#include <KWaylandServer/linuxdmabufv1clientbuffer.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/output_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/outputconfiguration_v2_interface.h>
|
|
|
|
#include <KWaylandServer/outputmanagement_v2_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/plasmashell_interface.h>
|
|
|
|
#include <KWaylandServer/plasmavirtualdesktop_interface.h>
|
|
|
|
#include <KWaylandServer/plasmawindowmanagement_interface.h>
|
2020-11-03 19:54:49 +00:00
|
|
|
#include <KWaylandServer/pointerconstraints_v1_interface.h>
|
2020-11-03 17:32:29 +00:00
|
|
|
#include <KWaylandServer/pointergestures_v1_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/primaryoutput_v1_interface.h>
|
|
|
|
#include <KWaylandServer/primaryselectiondevicemanager_v1_interface.h>
|
|
|
|
#include <KWaylandServer/relativepointer_v1_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/seat_interface.h>
|
|
|
|
#include <KWaylandServer/server_decoration_interface.h>
|
|
|
|
#include <KWaylandServer/server_decoration_palette_interface.h>
|
|
|
|
#include <KWaylandServer/shadow_interface.h>
|
|
|
|
#include <KWaylandServer/subcompositor_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/tablet_v2_interface.h>
|
|
|
|
#include <KWaylandServer/viewporter_interface.h>
|
2020-11-07 02:03:57 +00:00
|
|
|
#include <KWaylandServer/xdgactivation_v1_interface.h>
|
2020-02-17 18:39:17 +00:00
|
|
|
#include <KWaylandServer/xdgdecoration_v1_interface.h>
|
2020-07-22 20:27:29 +00:00
|
|
|
#include <KWaylandServer/xdgforeign_v2_interface.h>
|
2020-08-20 14:53:10 +00:00
|
|
|
#include <KWaylandServer/xdgoutput_v1_interface.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWaylandServer/xdgshell_interface.h>
|
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
|
|
|
|
2015-05-18 09:23:45 +00:00
|
|
|
// Qt
|
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
|
|
|
#include <QCryptographicHash>
|
2018-11-07 11:49:09 +00:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFileInfo>
|
2015-08-17 07:42:12 +00:00
|
|
|
#include <QThread>
|
2015-05-18 09:23:45 +00:00
|
|
|
#include <QWindow>
|
|
|
|
|
2015-02-25 13:15:32 +00:00
|
|
|
// system
|
|
|
|
#include <sys/socket.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <sys/types.h>
|
2016-06-20 09:21:16 +00:00
|
|
|
#include <unistd.h>
|
2015-02-25 13:15:32 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
// screenlocker
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2015-11-05 13:09:23 +00:00
|
|
|
#include <KScreenLocker/KsldApp>
|
2022-02-23 13:27:05 +00:00
|
|
|
#endif
|
2015-11-05 13:09:23 +00:00
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
using namespace KWaylandServer;
|
2015-02-09 12:28:37 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
KWIN_SINGLETON_FACTORY(WaylandServer)
|
|
|
|
|
2020-11-18 16:41:16 +00:00
|
|
|
class KWinDisplay : public KWaylandServer::FilteredDisplay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KWinDisplay(QObject *parent)
|
|
|
|
: KWaylandServer::FilteredDisplay(parent)
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
|
|
|
}
|
2020-11-18 16:41:16 +00:00
|
|
|
|
|
|
|
static QByteArray sha256(const QString &fileName)
|
|
|
|
{
|
|
|
|
QFile f(fileName);
|
|
|
|
if (f.open(QFile::ReadOnly)) {
|
|
|
|
QCryptographicHash hash(QCryptographicHash::Sha256);
|
|
|
|
if (hash.addData(&f)) {
|
|
|
|
return hash.result();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isTrustedOrigin(KWaylandServer::ClientConnection *client) const
|
|
|
|
{
|
2020-11-18 16:41:16 +00:00
|
|
|
const auto fullPathSha = sha256(client->executablePath());
|
|
|
|
const auto localSha = sha256(QLatin1String("/proc/") + QString::number(client->processId()) + QLatin1String("/exe"));
|
|
|
|
const bool trusted = !localSha.isEmpty() && fullPathSha == localSha;
|
|
|
|
|
|
|
|
if (!trusted) {
|
|
|
|
qCWarning(KWIN_CORE) << "Could not trust" << client->executablePath() << "sha" << localSha << fullPathSha;
|
|
|
|
}
|
|
|
|
|
|
|
|
return trusted;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QStringList fetchRequestedInterfaces(KWaylandServer::ClientConnection *client) const
|
|
|
|
{
|
2020-11-18 16:41:16 +00:00
|
|
|
return KWin::fetchRequestedInterfaces(client->executablePath());
|
|
|
|
}
|
|
|
|
|
2021-08-22 09:49:57 +00:00
|
|
|
const QSet<QByteArray> interfacesBlackList = {
|
|
|
|
QByteArrayLiteral("org_kde_kwin_remote_access_manager"),
|
|
|
|
QByteArrayLiteral("org_kde_plasma_window_management"),
|
|
|
|
QByteArrayLiteral("org_kde_kwin_fake_input"),
|
|
|
|
QByteArrayLiteral("org_kde_kwin_keystate"),
|
|
|
|
QByteArrayLiteral("zkde_screencast_unstable_v1"),
|
|
|
|
QByteArrayLiteral("org_kde_plasma_activation_feedback"),
|
|
|
|
};
|
2020-11-18 16:41:16 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QSet<QByteArray> inputmethodInterfaces = {"zwp_input_panel_v1", "zwp_input_method_v1"};
|
2020-11-18 16:41:16 +00:00
|
|
|
|
|
|
|
QSet<QString> m_reported;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool allowInterface(KWaylandServer::ClientConnection *client, const QByteArray &interfaceName) override
|
|
|
|
{
|
2020-11-18 16:41:16 +00:00
|
|
|
if (client->processId() == getpid()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client != waylandServer()->inputMethodConnection() && inputmethodInterfaces.contains(interfaceName)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!interfacesBlackList.contains(interfaceName)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client->executablePath().isEmpty()) {
|
2021-04-01 11:48:44 +00:00
|
|
|
qCDebug(KWIN_CORE) << "Could not identify process with pid" << client->processId();
|
2020-11-18 16:41:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
auto requestedInterfaces = client->property("requestedInterfaces");
|
|
|
|
if (requestedInterfaces.isNull()) {
|
|
|
|
requestedInterfaces = fetchRequestedInterfaces(client);
|
|
|
|
client->setProperty("requestedInterfaces", requestedInterfaces);
|
|
|
|
}
|
|
|
|
if (!requestedInterfaces.toStringList().contains(QString::fromUtf8(interfaceName))) {
|
|
|
|
if (KWIN_CORE().isDebugEnabled()) {
|
|
|
|
const QString id = client->executablePath() + QLatin1Char('|') + QString::fromUtf8(interfaceName);
|
|
|
|
if (!m_reported.contains({id})) {
|
|
|
|
m_reported.insert(id);
|
|
|
|
qCDebug(KWIN_CORE) << "Interface" << interfaceName << "not in X-KDE-Wayland-Interfaces of" << client->executablePath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
auto trustedOrigin = client->property("isPrivileged");
|
|
|
|
if (trustedOrigin.isNull()) {
|
|
|
|
trustedOrigin = isTrustedOrigin(client);
|
|
|
|
client->setProperty("isPrivileged", trustedOrigin);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!trustedOrigin.toBool()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qCDebug(KWIN_CORE) << "authorized" << client->executablePath() << interfaceName;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
WaylandServer::WaylandServer(QObject *parent)
|
|
|
|
: QObject(parent)
|
2020-11-18 16:41:16 +00:00
|
|
|
, m_display(new KWinDisplay(this))
|
2015-02-09 12:28:37 +00:00
|
|
|
{
|
2020-04-29 15:18:41 +00:00
|
|
|
qRegisterMetaType<KWaylandServer::OutputInterface::DpmsMode>();
|
2015-02-09 12:28:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-10 13:38:45 +00:00
|
|
|
WaylandServer::~WaylandServer()
|
|
|
|
{
|
2021-10-07 15:26:43 +00:00
|
|
|
s_self = nullptr;
|
2015-11-10 13:38:45 +00:00
|
|
|
}
|
2015-11-10 07:52:40 +00:00
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
KWaylandServer::ClientConnection *WaylandServer::xWaylandConnection() const
|
|
|
|
{
|
|
|
|
return m_xwaylandConnection;
|
|
|
|
}
|
|
|
|
|
2021-12-13 17:29:16 +00:00
|
|
|
KWaylandServer::ClientConnection *WaylandServer::inputMethodConnection() const
|
|
|
|
{
|
|
|
|
return m_inputMethodServerConnection;
|
|
|
|
}
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
void WaylandServer::registerShellClient(AbstractClient *client)
|
2016-04-22 12:13:37 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (client->readyForPainting()) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT shellClientAdded(client);
|
2020-02-17 18:39:17 +00:00
|
|
|
} else {
|
|
|
|
connect(client, &AbstractClient::windowShown, this, &WaylandServer::shellClientShown);
|
|
|
|
}
|
|
|
|
m_clients << client;
|
|
|
|
}
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
void WaylandServer::registerXdgToplevelClient(XdgToplevelClient *client)
|
2020-02-17 18:39:17 +00:00
|
|
|
{
|
2020-05-07 14:29:41 +00:00
|
|
|
// TODO: Find a better way and more generic to install extensions.
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
SurfaceInterface *surface = client->surface();
|
2020-07-13 11:38:12 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
registerShellClient(client);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2021-05-13 06:19:44 +00:00
|
|
|
if (auto shellSurface = PlasmaShellSurfaceInterface::get(surface)) {
|
|
|
|
client->installPlasmaShellSurface(shellSurface);
|
2017-02-07 18:18:18 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (auto decoration = ServerSideDecorationInterface::get(surface)) {
|
|
|
|
client->installServerDecoration(decoration);
|
|
|
|
}
|
2020-05-07 14:29:41 +00:00
|
|
|
if (auto decoration = XdgToplevelDecorationV1Interface::get(client->shellSurface())) {
|
|
|
|
client->installXdgDecoration(decoration);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (auto menu = m_appMenuManager->appMenuForSurface(surface)) {
|
2017-12-22 14:22:24 +00:00
|
|
|
client->installAppMenu(menu);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (auto palette = m_paletteManager->paletteForSurface(surface)) {
|
2018-01-04 18:32:18 +00:00
|
|
|
client->installPalette(palette);
|
|
|
|
}
|
2017-10-13 09:32:02 +00:00
|
|
|
|
2020-07-22 20:27:29 +00:00
|
|
|
connect(m_XdgForeign, &XdgForeignV2Interface::transientChanged, client, [this](SurfaceInterface *child) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT foreignTransientChanged(child);
|
2017-10-13 09:32:02 +00:00
|
|
|
});
|
2016-04-22 12:13:37 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
void WaylandServer::registerXdgGenericClient(AbstractClient *client)
|
2020-02-17 18:39:17 +00:00
|
|
|
{
|
2020-05-07 14:29:41 +00:00
|
|
|
XdgToplevelClient *toplevelClient = qobject_cast<XdgToplevelClient *>(client);
|
|
|
|
if (toplevelClient) {
|
|
|
|
registerXdgToplevelClient(toplevelClient);
|
2020-02-17 18:39:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-07 14:29:41 +00:00
|
|
|
XdgPopupClient *popupClient = qobject_cast<XdgPopupClient *>(client);
|
|
|
|
if (popupClient) {
|
|
|
|
registerShellClient(popupClient);
|
2021-05-13 06:19:44 +00:00
|
|
|
if (auto shellSurface = PlasmaShellSurfaceInterface::get(client->surface())) {
|
|
|
|
popupClient->installPlasmaShellSurface(shellSurface);
|
2020-08-04 01:15:59 +00:00
|
|
|
}
|
2020-05-07 14:29:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
qCDebug(KWIN_CORE) << "Received invalid xdg client:" << client->surface();
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-13 10:28:20 +00:00
|
|
|
void WaylandServer::initPlatform()
|
2021-04-04 14:11:13 +00:00
|
|
|
{
|
|
|
|
connect(kwinApp()->platform(), &Platform::outputAdded, this, &WaylandServer::handleOutputAdded);
|
|
|
|
connect(kwinApp()->platform(), &Platform::outputRemoved, this, &WaylandServer::handleOutputRemoved);
|
|
|
|
|
|
|
|
connect(kwinApp()->platform(), &Platform::outputEnabled, this, &WaylandServer::handleOutputEnabled);
|
|
|
|
connect(kwinApp()->platform(), &Platform::outputDisabled, this, &WaylandServer::handleOutputDisabled);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(kwinApp()->platform(), &Platform::primaryOutputChanged, this, [this](AbstractOutput *primaryOutput) {
|
2021-11-09 22:00:00 +00:00
|
|
|
m_primary->setPrimaryOutput(primaryOutput ? primaryOutput->name() : QString());
|
2021-10-25 00:05:23 +00:00
|
|
|
});
|
|
|
|
if (auto primaryOutput = kwinApp()->platform()->primaryOutput()) {
|
|
|
|
m_primary->setPrimaryOutput(primaryOutput->name());
|
|
|
|
}
|
|
|
|
|
2021-04-04 14:11:13 +00:00
|
|
|
const QVector<AbstractOutput *> outputs = kwinApp()->platform()->outputs();
|
|
|
|
for (AbstractOutput *output : outputs) {
|
|
|
|
handleOutputAdded(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QVector<AbstractOutput *> enabledOutputs = kwinApp()->platform()->enabledOutputs();
|
|
|
|
for (AbstractOutput *output : enabledOutputs) {
|
|
|
|
handleOutputEnabled(output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaylandServer::handleOutputAdded(AbstractOutput *output)
|
|
|
|
{
|
|
|
|
auto o = static_cast<AbstractWaylandOutput *>(output);
|
2021-07-26 23:11:50 +00:00
|
|
|
if (!o->isPlaceholder()) {
|
|
|
|
m_waylandOutputDevices.insert(o, new WaylandOutputDevice(o));
|
|
|
|
}
|
2021-04-04 14:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WaylandServer::handleOutputRemoved(AbstractOutput *output)
|
|
|
|
{
|
2021-07-26 23:11:50 +00:00
|
|
|
auto o = static_cast<AbstractWaylandOutput *>(output);
|
|
|
|
if (!o->isPlaceholder()) {
|
|
|
|
delete m_waylandOutputDevices.take(o);
|
|
|
|
}
|
2021-04-04 14:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WaylandServer::handleOutputEnabled(AbstractOutput *output)
|
|
|
|
{
|
|
|
|
auto o = static_cast<AbstractWaylandOutput *>(output);
|
2021-07-26 23:11:50 +00:00
|
|
|
if (!o->isPlaceholder()) {
|
|
|
|
m_waylandOutputs.insert(o, new WaylandOutput(o));
|
|
|
|
}
|
2021-04-04 14:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WaylandServer::handleOutputDisabled(AbstractOutput *output)
|
|
|
|
{
|
2021-07-26 23:11:50 +00:00
|
|
|
auto o = static_cast<AbstractWaylandOutput *>(output);
|
|
|
|
if (!o->isPlaceholder()) {
|
|
|
|
delete m_waylandOutputs.take(o);
|
|
|
|
}
|
2021-04-04 14:11:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 13:28:49 +00:00
|
|
|
AbstractWaylandOutput *WaylandServer::findOutput(KWaylandServer::OutputInterface *outputIface) const
|
|
|
|
{
|
2021-04-04 14:11:13 +00:00
|
|
|
for (auto it = m_waylandOutputs.constBegin(); it != m_waylandOutputs.constEnd(); ++it) {
|
|
|
|
if ((*it)->waylandOutput() == outputIface) {
|
|
|
|
return it.key();
|
2020-08-07 13:28:49 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-04 14:11:13 +00:00
|
|
|
return nullptr;
|
2020-08-07 13:28:49 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 09:45:55 +00:00
|
|
|
bool WaylandServer::start()
|
|
|
|
{
|
|
|
|
return m_display->start();
|
|
|
|
}
|
|
|
|
|
2020-12-09 13:06:15 +00:00
|
|
|
bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
|
2015-02-09 12:28:37 +00:00
|
|
|
{
|
2020-12-09 13:06:15 +00:00
|
|
|
if (!m_display->addSocketName(socketName)) {
|
2020-11-17 13:26:01 +00:00
|
|
|
return false;
|
2015-02-09 12:28:37 +00:00
|
|
|
}
|
2020-11-17 18:09:28 +00:00
|
|
|
return init(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WaylandServer::init(InitializationFlags flags)
|
|
|
|
{
|
|
|
|
m_initFlags = flags;
|
2020-12-09 21:24:41 +00:00
|
|
|
m_compositor = new CompositorInterface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_compositor, &CompositorInterface::surfaceCreated, this, [this](SurfaceInterface *surface) {
|
|
|
|
// check whether we have a Toplevel with the Surface's id
|
|
|
|
Workspace *ws = Workspace::self();
|
|
|
|
if (!ws) {
|
|
|
|
// it's possible that a Surface gets created before Workspace is created
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (surface->client() != xWaylandConnection()) {
|
|
|
|
// setting surface is only relevant for Xwayland clients
|
|
|
|
return;
|
|
|
|
}
|
2020-11-04 13:35:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
X11Client *client = ws->findClient([surface](const X11Client *client) {
|
|
|
|
return client->pendingSurfaceId() == surface->id();
|
|
|
|
});
|
|
|
|
if (client) {
|
|
|
|
client->setSurface(surface);
|
|
|
|
return;
|
|
|
|
}
|
2020-11-04 13:35:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Unmanaged *unmanaged = ws->findUnmanaged([surface](const Unmanaged *unmanaged) {
|
|
|
|
return unmanaged->pendingSurfaceId() == surface->id();
|
|
|
|
});
|
|
|
|
if (unmanaged) {
|
|
|
|
unmanaged->setSurface(surface);
|
|
|
|
return;
|
2015-02-09 15:08:53 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
|
|
|
|
// The surface will be bound later when a WL_SURFACE_ID message is received.
|
|
|
|
});
|
2018-09-14 11:04:33 +00:00
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
m_tabletManagerV2 = new TabletManagerV2Interface(m_display, m_display);
|
|
|
|
m_keyboardShortcutsInhibitManager = new KeyboardShortcutsInhibitManagerV1Interface(m_display, m_display);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2020-09-04 07:03:04 +00:00
|
|
|
auto inputPanelV1Integration = new InputPanelV1Integration(this);
|
|
|
|
connect(inputPanelV1Integration, &InputPanelV1Integration::clientCreated,
|
|
|
|
this, &WaylandServer::registerShellClient);
|
|
|
|
|
2020-09-03 19:26:04 +00:00
|
|
|
auto xdgShellIntegration = new XdgShellIntegration(this);
|
|
|
|
connect(xdgShellIntegration, &XdgShellIntegration::clientCreated,
|
2020-05-07 14:29:41 +00:00
|
|
|
this, &WaylandServer::registerXdgGenericClient);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2020-08-07 19:01:42 +00:00
|
|
|
auto layerShellV1Integration = new LayerShellV1Integration(this);
|
|
|
|
connect(layerShellV1Integration, &LayerShellV1Integration::clientCreated,
|
|
|
|
this, &WaylandServer::registerShellClient);
|
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
m_xdgDecorationManagerV1 = new XdgDecorationManagerV1Interface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_xdgDecorationManagerV1, &XdgDecorationManagerV1Interface::decorationCreated, this, [this](XdgToplevelDecorationV1Interface *decoration) {
|
|
|
|
if (XdgToplevelClient *toplevel = findXdgToplevelClient(decoration->toplevel()->surface())) {
|
|
|
|
toplevel->installXdgDecoration(decoration);
|
2019-01-01 17:37:18 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2019-01-01 17:37:18 +00:00
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
new ViewporterInterface(m_display, m_display);
|
2015-02-09 12:28:37 +00:00
|
|
|
m_display->createShm();
|
2020-12-09 21:24:41 +00:00
|
|
|
m_seat = new SeatInterface(m_display, m_display);
|
|
|
|
new PointerGesturesV1Interface(m_display, m_display);
|
|
|
|
new PointerConstraintsV1Interface(m_display, m_display);
|
2021-10-05 18:37:58 +00:00
|
|
|
new RelativePointerManagerV1Interface(m_display, m_display);
|
2020-12-09 21:24:41 +00:00
|
|
|
m_dataDeviceManager = new DataDeviceManagerInterface(m_display, m_display);
|
|
|
|
new DataControlDeviceManagerV1Interface(m_display, m_display);
|
|
|
|
new PrimarySelectionDeviceManagerV1Interface(m_display, m_display);
|
|
|
|
m_idle = new IdleInterface(m_display, m_display);
|
2017-12-29 17:29:19 +00:00
|
|
|
auto idleInhibition = new IdleInhibition(m_idle);
|
2020-03-04 07:55:26 +00:00
|
|
|
connect(this, &WaylandServer::shellClientAdded, idleInhibition, &IdleInhibition::registerClient);
|
2020-12-09 21:24:41 +00:00
|
|
|
new IdleInhibitManagerV1Interface(m_display, m_display);
|
|
|
|
m_plasmaShell = new PlasmaShellInterface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated, this, [this](PlasmaShellSurfaceInterface *surface) {
|
|
|
|
if (XdgSurfaceClient *client = findXdgSurfaceClient(surface->surface())) {
|
|
|
|
client->installPlasmaShellSurface(surface);
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2020-12-09 21:24:41 +00:00
|
|
|
m_appMenuManager = new AppMenuManagerInterface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_appMenuManager, &AppMenuManagerInterface::appMenuCreated, this, [this](AppMenuInterface *appMenu) {
|
|
|
|
if (XdgToplevelClient *client = findXdgToplevelClient(appMenu->surface())) {
|
|
|
|
client->installAppMenu(appMenu);
|
2017-12-22 14:22:24 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2020-12-09 21:24:41 +00:00
|
|
|
m_paletteManager = new ServerSideDecorationPaletteManagerInterface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated, this, [this](ServerSideDecorationPaletteInterface *palette) {
|
|
|
|
if (XdgToplevelClient *client = findXdgToplevelClient(palette->surface())) {
|
|
|
|
client->installPalette(palette);
|
2018-01-04 18:32:18 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2017-12-22 14:22:24 +00:00
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
m_windowManagement = new PlasmaWindowManagementInterface(m_display, m_display);
|
2015-06-12 23:48:11 +00:00
|
|
|
m_windowManagement->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_windowManagement, &PlasmaWindowManagementInterface::requestChangeShowingDesktop, this, [](PlasmaWindowManagementInterface::ShowingDesktopState state) {
|
|
|
|
if (!workspace()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool set = false;
|
|
|
|
switch (state) {
|
|
|
|
case PlasmaWindowManagementInterface::ShowingDesktopState::Disabled:
|
|
|
|
set = false;
|
|
|
|
break;
|
|
|
|
case PlasmaWindowManagementInterface::ShowingDesktopState::Enabled:
|
|
|
|
set = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (set == workspace()->showingDesktop()) {
|
|
|
|
return;
|
2015-06-12 23:48:11 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
workspace()->setShowingDesktop(set);
|
|
|
|
});
|
[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-12-09 21:24:41 +00:00
|
|
|
m_virtualDesktopManagement = new PlasmaVirtualDesktopManagementInterface(m_display, m_display);
|
[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
|
|
|
m_windowManagement->setPlasmaVirtualDesktopManagementInterface(m_virtualDesktopManagement);
|
|
|
|
|
2021-08-22 09:49:57 +00:00
|
|
|
m_plasmaActivationFeedback = new PlasmaWindowActivationFeedbackInterface(m_display, m_display);
|
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
new ShadowManagerInterface(m_display, m_display);
|
|
|
|
new DpmsManagerInterface(m_display, m_display);
|
2015-09-01 09:30:30 +00:00
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
m_decorationManager = new ServerSideDecorationManagerInterface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this, [this](ServerSideDecorationInterface *decoration) {
|
|
|
|
if (XdgToplevelClient *client = findXdgToplevelClient(decoration->surface())) {
|
|
|
|
client->installServerDecoration(decoration);
|
2015-12-17 10:14:54 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2016-03-10 18:57:07 +00:00
|
|
|
|
2021-07-21 10:11:21 +00:00
|
|
|
m_outputManagement = new OutputManagementV2Interface(m_display, m_display);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_outputManagement, &OutputManagementV2Interface::configurationChangeRequested, this, [](KWaylandServer::OutputConfigurationV2Interface *config) {
|
|
|
|
kwinApp()->platform()->requestOutputsChange(config);
|
2016-03-10 18:57:07 +00:00
|
|
|
});
|
2021-10-25 00:05:23 +00:00
|
|
|
m_primary = new PrimaryOutputV1Interface(m_display, m_display);
|
2016-03-21 15:44:07 +00:00
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
m_xdgOutputManagerV1 = new XdgOutputManagerV1Interface(m_display, m_display);
|
|
|
|
new SubCompositorInterface(m_display, m_display);
|
|
|
|
m_XdgForeign = new XdgForeignV2Interface(m_display, m_display);
|
|
|
|
m_keyState = new KeyStateInterface(m_display, m_display);
|
|
|
|
m_inputMethod = new InputMethodV1Interface(m_display, m_display);
|
2020-07-11 16:40:28 +00:00
|
|
|
|
2020-11-07 02:03:57 +00:00
|
|
|
auto activation = new KWaylandServer::XdgActivationV1Interface(m_display, this);
|
|
|
|
auto init = [this, activation] {
|
|
|
|
new XdgActivationV1Integration(activation, this);
|
|
|
|
};
|
|
|
|
if (Workspace::self()) {
|
|
|
|
init();
|
|
|
|
} else {
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(static_cast<Application *>(qApp), &Application::workspaceCreated, this, init);
|
2020-11-07 02:03:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-04 07:09:03 +00:00
|
|
|
return true;
|
2015-06-12 23:48:11 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 19:37:03 +00:00
|
|
|
KWaylandServer::LinuxDmaBufV1ClientBufferIntegration *WaylandServer::linuxDmabuf()
|
2019-10-26 03:40:01 +00:00
|
|
|
{
|
|
|
|
if (!m_linuxDmabuf) {
|
2021-07-20 19:37:03 +00:00
|
|
|
m_linuxDmabuf = new LinuxDmaBufV1ClientBufferIntegration(m_display);
|
2019-10-26 03:40:01 +00:00
|
|
|
}
|
|
|
|
return m_linuxDmabuf;
|
|
|
|
}
|
|
|
|
|
2017-10-13 09:32:02 +00:00
|
|
|
SurfaceInterface *WaylandServer::findForeignTransientForSurface(SurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
return m_XdgForeign->transientFor(surface);
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void WaylandServer::shellClientShown(Toplevel *toplevel)
|
2016-06-07 09:43:56 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
AbstractClient *client = qobject_cast<AbstractClient *>(toplevel);
|
|
|
|
if (!client) {
|
|
|
|
qCWarning(KWIN_CORE) << "Failed to cast a Toplevel which is supposed to be an AbstractClient to AbstractClient";
|
2016-06-07 09:43:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
disconnect(client, &AbstractClient::windowShown, this, &WaylandServer::shellClientShown);
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT shellClientAdded(client);
|
2016-06-07 09:43:56 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 23:48:11 +00:00
|
|
|
void WaylandServer::initWorkspace()
|
|
|
|
{
|
2021-10-02 08:26:51 +00:00
|
|
|
// TODO: Moe the keyboard leds somewhere else.
|
|
|
|
updateKeyState(input()->keyboard()->xkb()->leds());
|
|
|
|
connect(input()->keyboard(), &KeyboardInputRedirection::ledsChanged, this, &WaylandServer::updateKeyState);
|
|
|
|
|
[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
|
|
|
VirtualDesktopManager::self()->setVirtualDesktopManagement(m_virtualDesktopManagement);
|
|
|
|
|
2015-06-12 23:48:11 +00:00
|
|
|
if (m_windowManagement) {
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(workspace(), &Workspace::showingDesktopChanged, this, [this](bool set) {
|
|
|
|
using namespace KWaylandServer;
|
|
|
|
m_windowManagement->setShowingDesktopState(set ? PlasmaWindowManagementInterface::ShowingDesktopState::Enabled : PlasmaWindowManagementInterface::ShowingDesktopState::Disabled);
|
|
|
|
});
|
2020-04-21 14:52:20 +00:00
|
|
|
|
|
|
|
connect(workspace(), &Workspace::workspaceInitialized, this, [this] {
|
2022-03-23 10:13:38 +00:00
|
|
|
auto f = [this]() {
|
2020-04-21 14:52:20 +00:00
|
|
|
QVector<quint32> ids;
|
2021-03-16 11:13:03 +00:00
|
|
|
QVector<QString> uuids;
|
2020-04-21 14:52:20 +00:00
|
|
|
for (Toplevel *toplevel : workspace()->stackingOrder()) {
|
|
|
|
auto *client = qobject_cast<AbstractClient *>(toplevel);
|
|
|
|
if (client && client->windowManagementInterface()) {
|
|
|
|
ids << client->windowManagementInterface()->internalId();
|
2021-03-16 11:13:03 +00:00
|
|
|
uuids << client->windowManagementInterface()->uuid();
|
2020-04-21 14:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
m_windowManagement->setStackingOrder(ids);
|
2021-03-16 11:13:03 +00:00
|
|
|
m_windowManagement->setStackingOrderUuids(uuids);
|
2020-04-21 14:52:20 +00:00
|
|
|
};
|
|
|
|
f();
|
|
|
|
connect(workspace(), &Workspace::stackingOrderChanged, this, f);
|
|
|
|
});
|
2015-06-12 23:48:11 +00:00
|
|
|
}
|
2015-11-06 11:21:34 +00:00
|
|
|
|
2016-04-25 06:51:33 +00:00
|
|
|
if (hasScreenLockerIntegration()) {
|
2021-10-07 06:03:37 +00:00
|
|
|
initScreenLocker();
|
2017-09-30 14:33:45 +00:00
|
|
|
}
|
2021-10-10 15:22:40 +00:00
|
|
|
Q_EMIT initialized();
|
2017-09-30 14:33:45 +00:00
|
|
|
}
|
2015-11-06 14:08:13 +00:00
|
|
|
|
2017-09-30 14:33:45 +00:00
|
|
|
void WaylandServer::initScreenLocker()
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2020-03-15 21:40:56 +00:00
|
|
|
auto *screenLockerApp = ScreenLocker::KSldApp::self();
|
|
|
|
|
2017-09-30 14:33:45 +00:00
|
|
|
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
|
|
|
|
|
2022-01-20 22:26:17 +00:00
|
|
|
connect(this, &WaylandServer::shellClientAdded, this, [](AbstractClient *client) {
|
|
|
|
if (client->isLockScreen()) {
|
|
|
|
ScreenLocker::KSldApp::self()->lockScreenShown();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::aboutToLock, this, [this, screenLockerApp]() {
|
|
|
|
if (m_screenLockerClientConnection) {
|
|
|
|
// Already sent data to KScreenLocker.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int clientFd = createScreenLockerConnection();
|
|
|
|
if (clientFd < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ScreenLocker::KSldApp::self()->setWaylandFd(clientFd);
|
2020-03-15 21:40:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QVector<SeatInterface *> seatIfaces = m_display->seats();
|
|
|
|
for (auto *seat : seatIfaces) {
|
|
|
|
connect(seat, &KWaylandServer::SeatInterface::timestampChanged,
|
|
|
|
screenLockerApp, &ScreenLocker::KSldApp::userActivity);
|
2017-09-30 14:33:45 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2020-03-15 21:40:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this, [this, screenLockerApp]() {
|
|
|
|
if (m_screenLockerClientConnection) {
|
|
|
|
m_screenLockerClientConnection->destroy();
|
|
|
|
delete m_screenLockerClientConnection;
|
|
|
|
m_screenLockerClientConnection = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QVector<SeatInterface *> seatIfaces = m_display->seats();
|
|
|
|
for (auto *seat : seatIfaces) {
|
|
|
|
disconnect(seat, &KWaylandServer::SeatInterface::timestampChanged,
|
|
|
|
screenLockerApp, &ScreenLocker::KSldApp::userActivity);
|
2016-04-25 06:51:33 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
ScreenLocker::KSldApp::self()->setWaylandFd(-1);
|
|
|
|
});
|
2017-09-30 14:33:45 +00:00
|
|
|
|
2022-02-11 16:21:42 +00:00
|
|
|
ScreenLocker::KSldApp::self()->initialize();
|
|
|
|
|
2020-03-17 05:48:05 +00:00
|
|
|
if (m_initFlags.testFlag(InitializationFlag::LockScreen)) {
|
2017-09-30 14:33:45 +00:00
|
|
|
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
|
2015-11-05 13:09:23 +00:00
|
|
|
}
|
2022-02-23 13:27:05 +00:00
|
|
|
#endif
|
2015-02-20 13:54:21 +00:00
|
|
|
}
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2016-12-03 13:54:32 +00:00
|
|
|
WaylandServer::SocketPairConnection WaylandServer::createConnection()
|
2015-02-25 13:15:32 +00:00
|
|
|
{
|
2016-12-03 13:54:32 +00:00
|
|
|
SocketPairConnection ret;
|
2015-02-25 13:15:32 +00:00
|
|
|
int sx[2];
|
|
|
|
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) {
|
|
|
|
qCWarning(KWIN_CORE) << "Could not create socket";
|
2016-12-03 13:54:32 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret.connection = m_display->createClient(sx[0]);
|
|
|
|
ret.fd = sx[1];
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-15 21:40:56 +00:00
|
|
|
int WaylandServer::createScreenLockerConnection()
|
|
|
|
{
|
|
|
|
const auto socket = createConnection();
|
|
|
|
if (!socket.connection) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
m_screenLockerClientConnection = socket.connection;
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(m_screenLockerClientConnection, &KWaylandServer::ClientConnection::disconnected, this, [this]() {
|
|
|
|
m_screenLockerClientConnection = nullptr;
|
|
|
|
});
|
2020-03-15 21:40:56 +00:00
|
|
|
return socket.fd;
|
|
|
|
}
|
|
|
|
|
2016-12-03 13:54:32 +00:00
|
|
|
int WaylandServer::createXWaylandConnection()
|
|
|
|
{
|
|
|
|
const auto socket = createConnection();
|
|
|
|
if (!socket.connection) {
|
2015-02-25 13:15:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2020-07-20 08:07:08 +00:00
|
|
|
m_xwaylandConnection = socket.connection;
|
2016-12-03 13:54:32 +00:00
|
|
|
return socket.fd;
|
2015-02-25 13:15:32 +00:00
|
|
|
}
|
|
|
|
|
2015-11-10 13:21:48 +00:00
|
|
|
void WaylandServer::destroyXWaylandConnection()
|
|
|
|
{
|
2020-07-20 08:07:08 +00:00
|
|
|
if (!m_xwaylandConnection) {
|
2015-11-10 13:21:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-20 08:07:08 +00:00
|
|
|
m_xwaylandConnection->destroy();
|
|
|
|
m_xwaylandConnection = nullptr;
|
2015-11-10 13:21:48 +00:00
|
|
|
}
|
|
|
|
|
2015-06-13 02:06:12 +00:00
|
|
|
int WaylandServer::createInputMethodConnection()
|
|
|
|
{
|
2016-12-03 13:54:32 +00:00
|
|
|
const auto socket = createConnection();
|
|
|
|
if (!socket.connection) {
|
2015-06-13 02:06:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2016-12-03 13:54:32 +00:00
|
|
|
m_inputMethodServerConnection = socket.connection;
|
|
|
|
return socket.fd;
|
2015-06-13 02:06:12 +00:00
|
|
|
}
|
|
|
|
|
2015-11-10 13:38:45 +00:00
|
|
|
void WaylandServer::destroyInputMethodConnection()
|
|
|
|
{
|
|
|
|
if (!m_inputMethodServerConnection) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_inputMethodServerConnection->destroy();
|
|
|
|
m_inputMethodServerConnection = nullptr;
|
|
|
|
}
|
|
|
|
|
2020-03-04 07:55:26 +00:00
|
|
|
void WaylandServer::removeClient(AbstractClient *c)
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
|
|
|
m_clients.removeAll(c);
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT shellClientRemoved(c);
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 02:03:57 +00:00
|
|
|
static AbstractClient *findClientInList(const QList<AbstractClient *> &clients, const KWaylandServer::SurfaceInterface *surface)
|
2015-06-09 17:10:56 +00:00
|
|
|
{
|
|
|
|
auto it = std::find_if(clients.begin(), clients.end(),
|
2022-03-23 10:13:38 +00:00
|
|
|
[surface](AbstractClient *c) {
|
|
|
|
return c->surface() == surface;
|
|
|
|
});
|
2015-06-09 17:10:56 +00:00
|
|
|
if (it == clients.end()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
2020-11-07 02:03:57 +00:00
|
|
|
AbstractClient *WaylandServer::findClient(const KWaylandServer::SurfaceInterface *surface) const
|
2015-06-09 17:10:56 +00:00
|
|
|
{
|
|
|
|
if (!surface) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-03-04 07:55:26 +00:00
|
|
|
if (AbstractClient *c = findClientInList(m_clients, surface)) {
|
2015-06-09 17:10:56 +00:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgToplevelClient *WaylandServer::findXdgToplevelClient(SurfaceInterface *surface) const
|
2016-08-22 14:55:48 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return qobject_cast<XdgToplevelClient *>(findClient(surface));
|
2016-08-22 14:55:48 +00:00
|
|
|
}
|
|
|
|
|
2020-08-04 01:15:59 +00:00
|
|
|
XdgSurfaceClient *WaylandServer::findXdgSurfaceClient(SurfaceInterface *surface) const
|
|
|
|
{
|
|
|
|
return qobject_cast<XdgSurfaceClient *>(findClient(surface));
|
|
|
|
}
|
|
|
|
|
2015-11-16 10:19:38 +00:00
|
|
|
bool WaylandServer::isScreenLocked() const
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2016-04-25 06:51:33 +00:00
|
|
|
if (!hasScreenLockerIntegration()) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked || ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock;
|
2022-02-23 13:27:05 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2015-11-16 10:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 06:51:33 +00:00
|
|
|
bool WaylandServer::hasScreenLockerIntegration() const
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2020-03-17 05:48:05 +00:00
|
|
|
return !m_initFlags.testFlag(InitializationFlag::NoLockScreenIntegration);
|
2022-02-23 13:27:05 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2016-04-25 06:51:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-02 12:09:37 +00:00
|
|
|
bool WaylandServer::hasGlobalShortcutSupport() const
|
|
|
|
{
|
2020-03-17 05:48:05 +00:00
|
|
|
return !m_initFlags.testFlag(InitializationFlag::NoGlobalShortcuts);
|
2018-12-02 12:09:37 +00:00
|
|
|
}
|
|
|
|
|
2017-12-29 17:29:19 +00:00
|
|
|
void WaylandServer::simulateUserActivity()
|
|
|
|
{
|
|
|
|
if (m_idle) {
|
|
|
|
m_idle->simulateUserActivity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-04 16:36:32 +00:00
|
|
|
void WaylandServer::updateKeyState(KWin::LEDs leds)
|
2019-06-21 14:02:50 +00:00
|
|
|
{
|
|
|
|
if (!m_keyState)
|
|
|
|
return;
|
|
|
|
|
2021-10-04 16:36:32 +00:00
|
|
|
m_keyState->setState(KeyStateInterface::Key::CapsLock, leds & KWin::LED::CapsLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
|
|
|
m_keyState->setState(KeyStateInterface::Key::NumLock, leds & KWin::LED::NumLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
|
|
|
m_keyState->setState(KeyStateInterface::Key::ScrollLock, leds & KWin::LED::ScrollLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
2019-06-21 14:02:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 08:45:02 +00:00
|
|
|
bool WaylandServer::isKeyboardShortcutsInhibited() const
|
|
|
|
{
|
|
|
|
auto surface = seat()->focusedKeyboardSurface();
|
|
|
|
if (surface) {
|
|
|
|
auto inhibitor = keyboardShortcutsInhibitManager()->findInhibitor(surface, seat());
|
|
|
|
return inhibitor && inhibitor->isActive();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-11-17 13:26:01 +00:00
|
|
|
QString WaylandServer::socketName() const
|
|
|
|
{
|
|
|
|
const QStringList socketNames = display()->socketNames();
|
|
|
|
if (!socketNames.isEmpty()) {
|
|
|
|
return socketNames.first();
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
}
|