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"
|
2020-08-07 13:28:49 +00:00
|
|
|
#include "abstract_wayland_output.h"
|
2019-09-24 08:48:08 +00:00
|
|
|
#include "x11client.h"
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.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"
|
2015-02-20 13:54:21 +00:00
|
|
|
#include "screens.h"
|
2020-08-07 19:01:42 +00:00
|
|
|
#include "layershellv1integration.h"
|
2020-09-03 19:26:04 +00:00
|
|
|
#include "xdgshellintegration.h"
|
2015-02-09 15:08:53 +00:00
|
|
|
#include "workspace.h"
|
2020-02-17 18:39:17 +00:00
|
|
|
#include "xdgshellclient.h"
|
2020-06-16 16:59:59 +00:00
|
|
|
#include "service_utils.h"
|
2020-11-04 13:35:37 +00:00
|
|
|
#include "unmanaged.h"
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2015-04-02 12:37:23 +00:00
|
|
|
// Client
|
|
|
|
#include <KWayland/Client/connection_thread.h>
|
2015-08-17 07:42:12 +00:00
|
|
|
#include <KWayland/Client/event_queue.h>
|
2015-04-02 12:37:23 +00:00
|
|
|
#include <KWayland/Client/registry.h>
|
2018-08-22 12:56:48 +00:00
|
|
|
#include <KWayland/Client/compositor.h>
|
2018-08-21 20:06:42 +00:00
|
|
|
#include <KWayland/Client/seat.h>
|
|
|
|
#include <KWayland/Client/datadevicemanager.h>
|
2015-05-18 09:23:45 +00:00
|
|
|
#include <KWayland/Client/surface.h>
|
2015-04-02 12:37:23 +00:00
|
|
|
// Server
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/appmenu_interface.h>
|
|
|
|
#include <KWaylandServer/compositor_interface.h>
|
|
|
|
#include <KWaylandServer/datadevicemanager_interface.h>
|
|
|
|
#include <KWaylandServer/datasource_interface.h>
|
|
|
|
#include <KWaylandServer/display.h>
|
|
|
|
#include <KWaylandServer/dpms_interface.h>
|
|
|
|
#include <KWaylandServer/idle_interface.h>
|
2020-07-22 20:21:12 +00:00
|
|
|
#include <KWaylandServer/idleinhibit_v1_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/linuxdmabuf_v1_interface.h>
|
|
|
|
#include <KWaylandServer/output_interface.h>
|
|
|
|
#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>
|
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>
|
|
|
|
#include <KWaylandServer/blur_interface.h>
|
|
|
|
#include <KWaylandServer/outputmanagement_interface.h>
|
|
|
|
#include <KWaylandServer/outputconfiguration_interface.h>
|
2020-02-17 18:39:17 +00:00
|
|
|
#include <KWaylandServer/xdgdecoration_v1_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/xdgshell_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>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/keystate_interface.h>
|
|
|
|
#include <KWaylandServer/filtered_display.h>
|
2020-05-29 09:18:47 +00:00
|
|
|
#include <KWaylandServer/keyboard_shortcuts_inhibit_v1_interface.h>
|
2020-07-11 16:40:28 +00:00
|
|
|
#include <KWaylandServer/inputmethod_v1_interface.h>
|
2020-12-09 21:24:41 +00:00
|
|
|
#include <KWaylandServer/tablet_v2_interface.h>
|
|
|
|
#include <KWaylandServer/viewporter_interface.h>
|
|
|
|
#include <KWaylandServer/datacontroldevicemanager_v1_interface.h>
|
|
|
|
#include <KWaylandServer/primaryselectiondevicemanager_v1_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/types.h>
|
|
|
|
#include <sys/socket.h>
|
2016-06-20 09:21:16 +00:00
|
|
|
#include <unistd.h>
|
2015-02-25 13:15:32 +00:00
|
|
|
|
2015-11-05 13:09:23 +00:00
|
|
|
//screenlocker
|
|
|
|
#include <KScreenLocker/KsldApp>
|
|
|
|
|
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)
|
|
|
|
{}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isTrustedOrigin(KWaylandServer::ClientConnection *client) const {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList fetchRequestedInterfaces(KWaylandServer::ClientConnection *client) const {
|
|
|
|
return KWin::fetchRequestedInterfaces(client->executablePath());
|
|
|
|
}
|
|
|
|
|
|
|
|
const QSet<QByteArray> interfacesBlackList = {"org_kde_kwin_remote_access_manager", "org_kde_plasma_window_management", "org_kde_kwin_fake_input", "org_kde_kwin_keystate", "zkde_screencast_unstable_v1"};
|
|
|
|
|
|
|
|
const QSet<QByteArray> inputmethodInterfaces = { "zwp_input_panel_v1", "zwp_input_method_v1" };
|
|
|
|
|
|
|
|
QSet<QString> m_reported;
|
|
|
|
|
|
|
|
bool allowInterface(KWaylandServer::ClientConnection *client, const QByteArray &interfaceName) override {
|
|
|
|
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()) {
|
|
|
|
qCWarning(KWIN_CORE) << "Could not identify process with pid" << client->processId();
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
destroyInputMethodConnection();
|
|
|
|
}
|
2015-11-10 07:52:40 +00:00
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
KWaylandServer::ClientConnection *WaylandServer::xWaylandConnection() const
|
|
|
|
{
|
|
|
|
return m_xwaylandConnection;
|
|
|
|
}
|
|
|
|
|
2015-11-10 07:52:40 +00:00
|
|
|
void WaylandServer::destroyInternalConnection()
|
2015-08-17 07:42:12 +00:00
|
|
|
{
|
2016-02-02 11:00:12 +00:00
|
|
|
emit terminatingInternalClientConnection();
|
2015-08-17 07:42:12 +00:00
|
|
|
if (m_internalConnection.client) {
|
2017-07-08 13:21:16 +00:00
|
|
|
// delete all connections hold by plugins like e.g. widget style
|
|
|
|
const auto connections = KWayland::Client::ConnectionThread::connections();
|
|
|
|
for (auto c : connections) {
|
|
|
|
if (c == m_internalConnection.client) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
emit c->connectionDied();
|
|
|
|
}
|
|
|
|
|
2015-11-10 10:35:00 +00:00
|
|
|
delete m_internalConnection.registry;
|
2018-08-22 12:56:48 +00:00
|
|
|
delete m_internalConnection.compositor;
|
2018-08-21 20:06:42 +00:00
|
|
|
delete m_internalConnection.seat;
|
|
|
|
delete m_internalConnection.ddm;
|
2015-10-22 08:07:02 +00:00
|
|
|
dispatch();
|
2015-08-17 07:42:12 +00:00
|
|
|
m_internalConnection.client->deleteLater();
|
|
|
|
m_internalConnection.clientThread->quit();
|
|
|
|
m_internalConnection.clientThread->wait();
|
2015-11-10 10:43:30 +00:00
|
|
|
delete m_internalConnection.clientThread;
|
2015-11-10 07:52:40 +00:00
|
|
|
m_internalConnection.client = nullptr;
|
2015-11-10 13:27:43 +00:00
|
|
|
m_internalConnection.server->destroy();
|
2016-06-14 14:42:52 +00:00
|
|
|
m_internalConnection.server = nullptr;
|
2015-08-17 07:42:12 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2015-11-18 09:29:10 +00:00
|
|
|
void WaylandServer::terminateClientConnections()
|
|
|
|
{
|
|
|
|
destroyInternalConnection();
|
|
|
|
destroyInputMethodConnection();
|
2020-11-18 16:41:16 +00:00
|
|
|
const auto connections = m_display->connections();
|
|
|
|
for (auto it = connections.begin(); it != connections.end(); ++it) {
|
|
|
|
(*it)->destroy();
|
2015-11-18 09:29:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()) {
|
|
|
|
emit shellClientAdded(client);
|
|
|
|
} 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
|
|
|
|
2016-04-22 12:13:37 +00:00
|
|
|
if (surface->client() == m_screenLockerClientConnection) {
|
|
|
|
ScreenLocker::KSldApp::self()->lockScreenShown();
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
registerShellClient(client);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2017-02-07 18:18:18 +00:00
|
|
|
auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(),
|
2020-02-17 18:39:17 +00:00
|
|
|
[surface] (PlasmaShellSurfaceInterface *plasmaSurface) {
|
|
|
|
return plasmaSurface->surface() == surface;
|
2017-02-07 18:18:18 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
if (it != m_plasmaShellSurfaces.end()) {
|
|
|
|
client->installPlasmaShellSurface(*it);
|
|
|
|
m_plasmaShellSurfaces.erase(it);
|
|
|
|
}
|
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) {
|
2017-10-13 09:32:02 +00:00
|
|
|
emit foreignTransientChanged(child);
|
|
|
|
});
|
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);
|
2020-08-04 01:15:59 +00:00
|
|
|
|
|
|
|
SurfaceInterface *surface = client->surface();
|
|
|
|
auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(),
|
|
|
|
[surface] (PlasmaShellSurfaceInterface *plasmaSurface) {
|
|
|
|
return plasmaSurface->surface() == surface;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
if (it != m_plasmaShellSurfaces.end()) {
|
|
|
|
popupClient->installPlasmaShellSurface(*it);
|
|
|
|
m_plasmaShellSurfaces.erase(it);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-08-07 13:28:49 +00:00
|
|
|
AbstractWaylandOutput *WaylandServer::findOutput(KWaylandServer::OutputInterface *outputIface) const
|
|
|
|
{
|
|
|
|
AbstractWaylandOutput *outputFound = nullptr;
|
|
|
|
const auto outputs = kwinApp()->platform()->enabledOutputs();
|
|
|
|
for (auto output : outputs) {
|
|
|
|
if (static_cast<AbstractWaylandOutput *>(output)->waylandOutput() == outputIface) {
|
|
|
|
outputFound = static_cast<AbstractWaylandOutput *>(output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return outputFound;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-11-05 13:09:23 +00:00
|
|
|
m_initFlags = flags;
|
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
|
|
|
m_display = new KWinDisplay(this);
|
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-12-09 21:24:41 +00:00
|
|
|
m_compositor = new CompositorInterface(m_display, m_display);
|
2015-02-09 15:08:53 +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;
|
|
|
|
}
|
2015-04-30 07:23:27 +00:00
|
|
|
if (surface->client() != xWaylandConnection()) {
|
|
|
|
// setting surface is only relevat for Xwayland clients
|
|
|
|
return;
|
|
|
|
}
|
2020-11-04 13:35:37 +00:00
|
|
|
|
|
|
|
X11Client *client = ws->findClient([surface](const X11Client *client) {
|
|
|
|
return client->surfaceId() == surface->id();
|
|
|
|
});
|
|
|
|
if (client) {
|
|
|
|
client->setSurface(surface);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Unmanaged *unmanaged = ws->findUnmanaged([surface](const Unmanaged *unmanaged) {
|
|
|
|
return unmanaged->surfaceId() == surface->id();
|
|
|
|
});
|
|
|
|
if (unmanaged) {
|
|
|
|
unmanaged->setSurface(surface);
|
|
|
|
return;
|
2015-02-09 15:08:53 +00:00
|
|
|
}
|
2020-11-04 13:35:37 +00:00
|
|
|
|
|
|
|
// The surface will be bound later when a WL_SURFACE_ID message is received.
|
2015-02-09 15:08:53 +00:00
|
|
|
}
|
|
|
|
);
|
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);
|
2020-02-17 18:39:17 +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
|
|
|
}
|
2020-02-17 18:39:17 +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);
|
2015-02-25 08:35:42 +00:00
|
|
|
m_seat->create();
|
2020-12-09 21:24:41 +00:00
|
|
|
new PointerGesturesV1Interface(m_display, m_display);
|
|
|
|
new PointerConstraintsV1Interface(m_display, m_display);
|
|
|
|
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);
|
2015-06-09 17:10:56 +00:00
|
|
|
connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated,
|
|
|
|
[this] (PlasmaShellSurfaceInterface *surface) {
|
2020-08-04 01:15:59 +00:00
|
|
|
if (XdgSurfaceClient *client = findXdgSurfaceClient(surface->surface())) {
|
2015-06-09 17:10:56 +00:00
|
|
|
client->installPlasmaShellSurface(surface);
|
2020-02-17 18:39:17 +00:00
|
|
|
return;
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
2020-08-04 01:15:59 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
m_plasmaShellSurfaces.append(surface);
|
|
|
|
connect(surface, &QObject::destroyed, this, [this, surface] {
|
|
|
|
m_plasmaShellSurfaces.removeOne(surface);
|
|
|
|
});
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
|
|
|
);
|
2020-12-09 21:24:41 +00:00
|
|
|
m_appMenuManager = new AppMenuManagerInterface(m_display, m_display);
|
2017-12-22 14:22:24 +00:00
|
|
|
connect(m_appMenuManager, &AppMenuManagerInterface::appMenuCreated,
|
|
|
|
[this] (AppMenuInterface *appMenu) {
|
2020-02-17 18:39:17 +00:00
|
|
|
if (XdgToplevelClient *client = findXdgToplevelClient(appMenu->surface())) {
|
2017-12-22 14:22:24 +00:00
|
|
|
client->installAppMenu(appMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2020-12-09 21:24:41 +00:00
|
|
|
m_paletteManager = new ServerSideDecorationPaletteManagerInterface(m_display, m_display);
|
2018-01-04 18:32:18 +00:00
|
|
|
connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated,
|
|
|
|
[this] (ServerSideDecorationPaletteInterface *palette) {
|
2020-02-17 18:39:17 +00:00
|
|
|
if (XdgToplevelClient *client = findXdgToplevelClient(palette->surface())) {
|
2018-01-04 18:32:18 +00:00
|
|
|
client->installPalette(palette);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
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);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
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);
|
2015-12-17 10:14:54 +00:00
|
|
|
connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this,
|
2020-02-17 18:39:17 +00:00
|
|
|
[this] (ServerSideDecorationInterface *decoration) {
|
|
|
|
if (XdgToplevelClient *client = findXdgToplevelClient(decoration->surface())) {
|
|
|
|
client->installServerDecoration(decoration);
|
2015-12-17 10:14:54 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(decoration, &ServerSideDecorationInterface::modeRequested, this,
|
|
|
|
[decoration] (ServerSideDecorationManagerInterface::Mode mode) {
|
2018-01-18 20:17:15 +00:00
|
|
|
// always acknowledge the requested mode
|
2020-02-17 18:39:17 +00:00
|
|
|
decoration->setMode(mode);
|
2018-01-18 20:17:15 +00:00
|
|
|
}
|
|
|
|
);
|
2015-12-17 10:14:54 +00:00
|
|
|
}
|
|
|
|
);
|
2016-03-10 18:57:07 +00:00
|
|
|
|
2020-12-09 21:24:41 +00:00
|
|
|
m_outputManagement = new OutputManagementInterface(m_display, m_display);
|
2016-03-10 18:57:07 +00:00
|
|
|
connect(m_outputManagement, &OutputManagementInterface::configurationChangeRequested,
|
2020-04-29 15:18:41 +00:00
|
|
|
this, [](KWaylandServer::OutputConfigurationInterface *config) {
|
2019-08-28 18:54:37 +00:00
|
|
|
kwinApp()->platform()->requestOutputsChange(config);
|
2016-03-10 18:57:07 +00:00
|
|
|
});
|
2016-04-27 19:03:47 +00:00
|
|
|
m_outputManagement->create();
|
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
|
|
|
|
2016-07-04 07:09:03 +00:00
|
|
|
return true;
|
2015-06-12 23:48:11 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
KWaylandServer::LinuxDmabufUnstableV1Interface *WaylandServer::linuxDmabuf()
|
2019-10-26 03:40:01 +00:00
|
|
|
{
|
|
|
|
if (!m_linuxDmabuf) {
|
2020-12-09 21:24:41 +00:00
|
|
|
m_linuxDmabuf = new LinuxDmabufUnstableV1Interface(m_display, m_display);
|
2019-10-26 03:40:01 +00:00
|
|
|
m_linuxDmabuf->create();
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
emit shellClientAdded(client);
|
2016-06-07 09:43:56 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 23:48:11 +00:00
|
|
|
void WaylandServer::initWorkspace()
|
|
|
|
{
|
[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) {
|
|
|
|
connect(workspace(), &Workspace::showingDesktopChanged, this,
|
|
|
|
[this] (bool set) {
|
2020-04-29 15:18:41 +00:00
|
|
|
using namespace KWaylandServer;
|
2015-06-12 23:48:11 +00:00
|
|
|
m_windowManagement->setShowingDesktopState(set ?
|
|
|
|
PlasmaWindowManagementInterface::ShowingDesktopState::Enabled :
|
|
|
|
PlasmaWindowManagementInterface::ShowingDesktopState::Disabled
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2020-04-21 14:52:20 +00:00
|
|
|
|
|
|
|
connect(workspace(), &Workspace::workspaceInitialized, this, [this] {
|
|
|
|
auto f = [this] () {
|
|
|
|
QVector<quint32> ids;
|
|
|
|
for (Toplevel *toplevel : workspace()->stackingOrder()) {
|
|
|
|
auto *client = qobject_cast<AbstractClient *>(toplevel);
|
|
|
|
if (client && client->windowManagementInterface()) {
|
|
|
|
ids << client->windowManagementInterface()->internalId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_windowManagement->setStackingOrder(ids);
|
|
|
|
};
|
|
|
|
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()) {
|
2017-09-30 14:33:45 +00:00
|
|
|
if (m_internalConnection.interfacesAnnounced) {
|
|
|
|
initScreenLocker();
|
|
|
|
} else {
|
|
|
|
connect(m_internalConnection.registry, &KWayland::Client::Registry::interfacesAnnounced, this, &WaylandServer::initScreenLocker);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
emit initialized();
|
|
|
|
}
|
|
|
|
}
|
2015-11-06 14:08:13 +00:00
|
|
|
|
2017-09-30 14:33:45 +00:00
|
|
|
void WaylandServer::initScreenLocker()
|
|
|
|
{
|
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());
|
|
|
|
ScreenLocker::KSldApp::self()->initialize();
|
|
|
|
|
2020-03-15 21:40:56 +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);
|
|
|
|
|
|
|
|
for (auto *seat : m_display->seats()) {
|
2020-04-29 15:18:41 +00:00
|
|
|
connect(seat, &KWaylandServer::SeatInterface::timestampChanged,
|
2020-03-15 21:40:56 +00:00
|
|
|
screenLockerApp, &ScreenLocker::KSldApp::userActivity);
|
|
|
|
}
|
2017-09-30 14:33:45 +00:00
|
|
|
}
|
|
|
|
);
|
2015-11-06 14:08:13 +00:00
|
|
|
|
2017-09-30 14:33:45 +00:00
|
|
|
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
|
2020-03-15 21:40:56 +00:00
|
|
|
[this, screenLockerApp] () {
|
|
|
|
if (m_screenLockerClientConnection) {
|
|
|
|
m_screenLockerClientConnection->destroy();
|
|
|
|
delete m_screenLockerClientConnection;
|
|
|
|
m_screenLockerClientConnection = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto *seat : m_display->seats()) {
|
2020-04-29 15:18:41 +00:00
|
|
|
disconnect(seat, &KWaylandServer::SeatInterface::timestampChanged,
|
2020-03-15 21:40:56 +00:00
|
|
|
screenLockerApp, &ScreenLocker::KSldApp::userActivity);
|
|
|
|
}
|
|
|
|
ScreenLocker::KSldApp::self()->setWaylandFd(-1);
|
2016-04-25 06:51:33 +00:00
|
|
|
}
|
2017-09-30 14:33:45 +00:00
|
|
|
);
|
|
|
|
|
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
|
|
|
}
|
2016-08-16 07:26:17 +00:00
|
|
|
emit initialized();
|
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;
|
2020-04-29 15:18:41 +00:00
|
|
|
connect(m_screenLockerClientConnection, &KWaylandServer::ClientConnection::disconnected,
|
2020-03-15 21:40:56 +00:00
|
|
|
this, [this] { m_screenLockerClientConnection = nullptr; });
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-04-02 12:37:23 +00:00
|
|
|
void WaylandServer::createInternalConnection()
|
|
|
|
{
|
2016-12-03 13:54:32 +00:00
|
|
|
const auto socket = createConnection();
|
|
|
|
if (!socket.connection) {
|
2015-04-02 12:37:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-12-03 13:54:32 +00:00
|
|
|
m_internalConnection.server = socket.connection;
|
2015-04-02 12:37:23 +00:00
|
|
|
using namespace KWayland::Client;
|
2015-08-17 07:42:12 +00:00
|
|
|
m_internalConnection.client = new ConnectionThread();
|
2016-12-03 13:54:32 +00:00
|
|
|
m_internalConnection.client->setSocketFd(socket.fd);
|
2015-08-17 07:42:12 +00:00
|
|
|
m_internalConnection.clientThread = new QThread;
|
|
|
|
m_internalConnection.client->moveToThread(m_internalConnection.clientThread);
|
|
|
|
m_internalConnection.clientThread->start();
|
|
|
|
|
2015-04-02 12:37:23 +00:00
|
|
|
connect(m_internalConnection.client, &ConnectionThread::connected, this,
|
|
|
|
[this] {
|
2015-08-17 07:42:12 +00:00
|
|
|
Registry *registry = new Registry(this);
|
2020-04-15 23:58:05 +00:00
|
|
|
EventQueue *eventQueue = new EventQueue(registry);
|
2015-08-17 07:42:12 +00:00
|
|
|
eventQueue->setup(m_internalConnection.client);
|
|
|
|
registry->setEventQueue(eventQueue);
|
2015-04-02 12:37:23 +00:00
|
|
|
registry->create(m_internalConnection.client);
|
2015-08-14 07:28:46 +00:00
|
|
|
m_internalConnection.registry = registry;
|
2017-09-30 14:33:45 +00:00
|
|
|
connect(registry, &Registry::interfacesAnnounced, this,
|
2018-08-21 20:06:42 +00:00
|
|
|
[this, registry] {
|
2017-09-30 14:33:45 +00:00
|
|
|
m_internalConnection.interfacesAnnounced = true;
|
2018-08-21 20:06:42 +00:00
|
|
|
|
2018-08-22 12:56:48 +00:00
|
|
|
const auto compInterface = registry->interface(Registry::Interface::Compositor);
|
|
|
|
if (compInterface.name != 0) {
|
|
|
|
m_internalConnection.compositor = registry->createCompositor(compInterface.name, compInterface.version, this);
|
|
|
|
}
|
2018-08-21 20:06:42 +00:00
|
|
|
const auto seatInterface = registry->interface(Registry::Interface::Seat);
|
|
|
|
if (seatInterface.name != 0) {
|
|
|
|
m_internalConnection.seat = registry->createSeat(seatInterface.name, seatInterface.version, this);
|
|
|
|
}
|
|
|
|
const auto ddmInterface = registry->interface(Registry::Interface::DataDeviceManager);
|
|
|
|
if (ddmInterface.name != 0) {
|
|
|
|
m_internalConnection.ddm = registry->createDataDeviceManager(ddmInterface.name, ddmInterface.version, this);
|
|
|
|
}
|
2017-09-30 14:33:45 +00:00
|
|
|
}
|
|
|
|
);
|
2015-04-02 12:37:23 +00:00
|
|
|
registry->setup();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
m_internalConnection.client->initConnection();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
emit shellClientRemoved(c);
|
|
|
|
}
|
|
|
|
|
2015-05-18 09:33:00 +00:00
|
|
|
void WaylandServer::dispatch()
|
|
|
|
{
|
|
|
|
if (!m_display) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-18 06:15:00 +00:00
|
|
|
if (m_internalConnection.server) {
|
|
|
|
m_internalConnection.server->flush();
|
2015-05-18 09:33:00 +00:00
|
|
|
}
|
2020-11-17 13:26:01 +00:00
|
|
|
m_display->dispatchEvents();
|
2015-05-18 09:33:00 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
static AbstractClient *findClientInList(const QList<AbstractClient *> &clients, KWaylandServer::SurfaceInterface *surface)
|
2015-06-09 17:10:56 +00:00
|
|
|
{
|
|
|
|
auto it = std::find_if(clients.begin(), clients.end(),
|
2020-03-04 07:55:26 +00:00
|
|
|
[surface] (AbstractClient *c) {
|
2015-06-09 17:10:56 +00:00
|
|
|
return c->surface() == surface;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (it == clients.end()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *WaylandServer::findClient(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
|
|
|
|
{
|
2016-04-25 06:51:33 +00:00
|
|
|
if (!hasScreenLockerIntegration()) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-02 09:19:46 +00:00
|
|
|
return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked ||
|
|
|
|
ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock;
|
2015-11-16 10:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 06:51:33 +00:00
|
|
|
bool WaylandServer::hasScreenLockerIntegration() const
|
|
|
|
{
|
2020-03-17 05:48:05 +00:00
|
|
|
return !m_initFlags.testFlag(InitializationFlag::NoLockScreenIntegration);
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-21 14:02:50 +00:00
|
|
|
void WaylandServer::updateKeyState(KWin::Xkb::LEDs leds)
|
|
|
|
{
|
|
|
|
if (!m_keyState)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_keyState->setState(KeyStateInterface::Key::CapsLock, leds & KWin::Xkb::LED::CapsLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
|
|
|
m_keyState->setState(KeyStateInterface::Key::NumLock, leds & KWin::Xkb::LED::NumLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
|
|
|
m_keyState->setState(KeyStateInterface::Key::ScrollLock, leds & KWin::Xkb::LED::ScrollLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|