2015-02-09 12:28:37 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_WAYLAND_SERVER_H
|
|
|
|
#define KWIN_WAYLAND_SERVER_H
|
|
|
|
|
|
|
|
#include <kwinglobals.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
2016-06-20 09:21:16 +00:00
|
|
|
#include <QPointer>
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2015-08-17 07:42:12 +00:00
|
|
|
class QThread;
|
2016-06-20 09:21:16 +00:00
|
|
|
class QProcess;
|
2015-05-18 09:23:45 +00:00
|
|
|
class QWindow;
|
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
namespace KWayland
|
|
|
|
{
|
2015-04-02 12:37:23 +00:00
|
|
|
namespace Client
|
|
|
|
{
|
|
|
|
class ConnectionThread;
|
2015-08-14 07:28:46 +00:00
|
|
|
class Registry;
|
2015-04-02 12:37:23 +00:00
|
|
|
class ShmPool;
|
2015-05-18 09:23:45 +00:00
|
|
|
class Surface;
|
2015-04-02 12:37:23 +00:00
|
|
|
}
|
2015-02-09 12:28:37 +00:00
|
|
|
namespace Server
|
|
|
|
{
|
2017-12-22 14:22:24 +00:00
|
|
|
class AppMenuManagerInterface;
|
2015-02-25 13:15:32 +00:00
|
|
|
class ClientConnection;
|
2015-02-09 12:28:37 +00:00
|
|
|
class CompositorInterface;
|
|
|
|
class Display;
|
2016-06-20 09:21:16 +00:00
|
|
|
class DataDeviceInterface;
|
2017-12-29 17:29:19 +00:00
|
|
|
class IdleInterface;
|
2015-02-09 12:28:37 +00:00
|
|
|
class ShellInterface;
|
|
|
|
class SeatInterface;
|
2015-12-17 10:14:54 +00:00
|
|
|
class ServerSideDecorationManagerInterface;
|
2018-01-04 18:32:18 +00:00
|
|
|
class ServerSideDecorationPaletteManagerInterface;
|
2015-05-21 07:59:45 +00:00
|
|
|
class SurfaceInterface;
|
2015-02-09 12:28:37 +00:00
|
|
|
class OutputInterface;
|
2015-06-09 17:10:56 +00:00
|
|
|
class PlasmaShellInterface;
|
2017-02-07 18:18:18 +00:00
|
|
|
class PlasmaShellSurfaceInterface;
|
2015-06-12 23:48:11 +00:00
|
|
|
class PlasmaWindowManagementInterface;
|
2015-06-09 22:59:53 +00:00
|
|
|
class QtSurfaceExtensionInterface;
|
2016-03-10 18:57:07 +00:00
|
|
|
class OutputManagementInterface;
|
|
|
|
class OutputConfigurationInterface;
|
2016-04-22 12:13:37 +00:00
|
|
|
class XdgShellInterface;
|
2017-10-13 09:32:02 +00:00
|
|
|
class XdgForeignInterface;
|
2015-02-09 12:28:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
2015-03-04 08:21:10 +00:00
|
|
|
class ShellClient;
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2015-06-16 04:50:22 +00:00
|
|
|
class AbstractClient;
|
2016-06-07 09:43:56 +00:00
|
|
|
class Toplevel;
|
2015-03-20 13:41:03 +00:00
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
class KWIN_EXPORT WaylandServer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-11-05 13:09:23 +00:00
|
|
|
enum class InitalizationFlag {
|
|
|
|
NoOptions = 0x0,
|
2016-04-25 06:51:33 +00:00
|
|
|
LockScreen = 0x1,
|
|
|
|
NoLockScreenIntegration = 0x2
|
2015-11-05 13:09:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag)
|
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
virtual ~WaylandServer();
|
2016-07-04 07:09:03 +00:00
|
|
|
bool init(const QByteArray &socketName = QByteArray(), InitalizationFlags flags = InitalizationFlag::NoOptions);
|
2015-11-18 09:29:10 +00:00
|
|
|
void terminateClientConnections();
|
2015-02-09 12:28:37 +00:00
|
|
|
|
|
|
|
KWayland::Server::Display *display() {
|
|
|
|
return m_display;
|
|
|
|
}
|
|
|
|
KWayland::Server::CompositorInterface *compositor() {
|
|
|
|
return m_compositor;
|
|
|
|
}
|
|
|
|
KWayland::Server::SeatInterface *seat() {
|
|
|
|
return m_seat;
|
|
|
|
}
|
|
|
|
KWayland::Server::ShellInterface *shell() {
|
|
|
|
return m_shell;
|
|
|
|
}
|
2015-07-09 07:10:33 +00:00
|
|
|
KWayland::Server::PlasmaWindowManagementInterface *windowManagement() {
|
|
|
|
return m_windowManagement;
|
|
|
|
}
|
2015-12-17 10:14:54 +00:00
|
|
|
KWayland::Server::ServerSideDecorationManagerInterface *decorationManager() const {
|
|
|
|
return m_decorationManager;
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
QList<ShellClient*> clients() const {
|
|
|
|
return m_clients;
|
|
|
|
}
|
2015-05-21 08:35:03 +00:00
|
|
|
QList<ShellClient*> internalClients() const {
|
|
|
|
return m_internalClients;
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
void removeClient(ShellClient *c);
|
2015-05-18 12:51:40 +00:00
|
|
|
ShellClient *findClient(quint32 id) const;
|
2015-06-09 17:10:56 +00:00
|
|
|
ShellClient *findClient(KWayland::Server::SurfaceInterface *surface) const;
|
2016-08-22 14:55:48 +00:00
|
|
|
AbstractClient *findAbstractClient(KWayland::Server::SurfaceInterface *surface) const;
|
2015-08-17 12:56:15 +00:00
|
|
|
ShellClient *findClient(QWindow *w) const;
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2017-10-13 09:32:02 +00:00
|
|
|
/**
|
|
|
|
* return a transient parent of a surface imported with the foreign protocol, if any
|
|
|
|
*/
|
|
|
|
KWayland::Server::SurfaceInterface *findForeignTransientForSurface(KWayland::Server::SurfaceInterface *surface);
|
|
|
|
|
2015-02-25 13:15:32 +00:00
|
|
|
/**
|
|
|
|
* @returns file descriptor for Xwayland to connect to.
|
|
|
|
**/
|
|
|
|
int createXWaylandConnection();
|
2015-11-10 13:21:48 +00:00
|
|
|
void destroyXWaylandConnection();
|
2015-02-25 13:15:32 +00:00
|
|
|
|
2015-06-13 02:06:12 +00:00
|
|
|
/**
|
|
|
|
* @returns file descriptor to the input method server's socket.
|
|
|
|
**/
|
|
|
|
int createInputMethodConnection();
|
2015-11-10 13:38:45 +00:00
|
|
|
void destroyInputMethodConnection();
|
2015-06-13 02:06:12 +00:00
|
|
|
|
2016-06-20 09:21:16 +00:00
|
|
|
int createXclipboardSyncConnection();
|
|
|
|
|
2015-11-16 10:19:38 +00:00
|
|
|
/**
|
|
|
|
* @returns true if screen is locked.
|
|
|
|
**/
|
|
|
|
bool isScreenLocked() const;
|
2016-04-25 06:51:33 +00:00
|
|
|
/**
|
|
|
|
* @returns whether integration with KScreenLocker is available.
|
|
|
|
**/
|
|
|
|
bool hasScreenLockerIntegration() const;
|
2015-11-16 10:19:38 +00:00
|
|
|
|
2015-04-02 12:37:23 +00:00
|
|
|
void createInternalConnection();
|
2015-06-12 23:48:11 +00:00
|
|
|
void initWorkspace();
|
2015-02-25 13:46:30 +00:00
|
|
|
|
2015-04-02 07:49:39 +00:00
|
|
|
KWayland::Server::ClientConnection *xWaylandConnection() const {
|
2015-11-10 13:21:48 +00:00
|
|
|
return m_xwayland.client;
|
2015-04-02 07:49:39 +00:00
|
|
|
}
|
2015-06-13 02:06:12 +00:00
|
|
|
KWayland::Server::ClientConnection *inputMethodConnection() const {
|
|
|
|
return m_inputMethodServerConnection;
|
|
|
|
}
|
2015-04-02 12:37:23 +00:00
|
|
|
KWayland::Server::ClientConnection *internalConnection() const {
|
|
|
|
return m_internalConnection.server;
|
|
|
|
}
|
2015-11-06 14:08:13 +00:00
|
|
|
KWayland::Server::ClientConnection *screenLockerClientConnection() const {
|
|
|
|
return m_screenLockerClientConnection;
|
|
|
|
}
|
2016-06-20 09:21:16 +00:00
|
|
|
QPointer<KWayland::Server::DataDeviceInterface> xclipboardSyncDataDevice() const {
|
|
|
|
return m_xclipbaordSync.ddi;
|
|
|
|
}
|
2015-04-02 12:37:23 +00:00
|
|
|
KWayland::Client::ShmPool *internalShmPool() {
|
|
|
|
return m_internalConnection.shm;
|
|
|
|
}
|
|
|
|
KWayland::Client::ConnectionThread *internalClientConection() {
|
|
|
|
return m_internalConnection.client;
|
|
|
|
}
|
2015-08-14 07:28:46 +00:00
|
|
|
KWayland::Client::Registry *internalClientRegistry() {
|
|
|
|
return m_internalConnection.registry;
|
|
|
|
}
|
2015-05-18 09:33:00 +00:00
|
|
|
void dispatch();
|
2015-05-21 07:59:45 +00:00
|
|
|
quint32 createWindowId(KWayland::Server::SurfaceInterface *surface);
|
2015-04-02 07:49:39 +00:00
|
|
|
|
2016-12-03 13:54:32 +00:00
|
|
|
/**
|
|
|
|
* Struct containing information for a created Wayland connection through a
|
|
|
|
* socketpair.
|
|
|
|
**/
|
|
|
|
struct SocketPairConnection {
|
|
|
|
/**
|
|
|
|
* ServerSide Connection
|
|
|
|
**/
|
|
|
|
KWayland::Server::ClientConnection *connection = nullptr;
|
|
|
|
/**
|
|
|
|
* client-side file descriptor for the socket
|
|
|
|
**/
|
|
|
|
int fd = -1;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Creates a Wayland connection using a socket pair.
|
|
|
|
**/
|
|
|
|
SocketPairConnection createConnection();
|
|
|
|
|
2017-12-29 17:29:19 +00:00
|
|
|
void simulateUserActivity();
|
|
|
|
|
2015-03-04 08:21:10 +00:00
|
|
|
Q_SIGNALS:
|
2015-10-05 15:35:53 +00:00
|
|
|
void shellClientAdded(KWin::ShellClient*);
|
|
|
|
void shellClientRemoved(KWin::ShellClient*);
|
2016-02-02 11:00:12 +00:00
|
|
|
void terminatingInternalClientConnection();
|
2016-08-16 07:26:17 +00:00
|
|
|
void initialized();
|
2017-10-13 09:32:02 +00:00
|
|
|
void foreignTransientChanged(KWayland::Server::SurfaceInterface *child);
|
2015-03-04 08:21:10 +00:00
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
private:
|
2016-06-20 09:21:16 +00:00
|
|
|
void setupX11ClipboardSync();
|
2016-06-07 09:43:56 +00:00
|
|
|
void shellClientShown(Toplevel *t);
|
2016-04-25 07:45:04 +00:00
|
|
|
void initOutputs();
|
2016-07-20 09:42:52 +00:00
|
|
|
void syncOutputsToWayland();
|
2015-05-21 07:59:45 +00:00
|
|
|
quint16 createClientId(KWayland::Server::ClientConnection *c);
|
2015-11-18 09:29:10 +00:00
|
|
|
void destroyInternalConnection();
|
2016-03-10 18:57:07 +00:00
|
|
|
void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config);
|
2016-04-22 12:13:37 +00:00
|
|
|
template <class T>
|
|
|
|
void createSurface(T *surface);
|
2017-09-30 14:33:45 +00:00
|
|
|
void initScreenLocker();
|
2015-02-09 12:28:37 +00:00
|
|
|
KWayland::Server::Display *m_display = nullptr;
|
|
|
|
KWayland::Server::CompositorInterface *m_compositor = nullptr;
|
|
|
|
KWayland::Server::SeatInterface *m_seat = nullptr;
|
|
|
|
KWayland::Server::ShellInterface *m_shell = nullptr;
|
2016-04-22 12:13:37 +00:00
|
|
|
KWayland::Server::XdgShellInterface *m_xdgShell = nullptr;
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
KWayland::Server::XdgShellInterface *m_xdgShell6 = nullptr;
|
2015-06-09 17:10:56 +00:00
|
|
|
KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr;
|
2015-06-12 23:48:11 +00:00
|
|
|
KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr;
|
2015-06-09 22:59:53 +00:00
|
|
|
KWayland::Server::QtSurfaceExtensionInterface *m_qtExtendedSurface = nullptr;
|
2015-12-17 10:14:54 +00:00
|
|
|
KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr;
|
2016-03-10 18:57:07 +00:00
|
|
|
KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr;
|
2017-12-22 14:22:24 +00:00
|
|
|
KWayland::Server::AppMenuManagerInterface *m_appMenuManager = nullptr;
|
2018-01-04 18:32:18 +00:00
|
|
|
KWayland::Server::ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr;
|
2017-12-29 17:29:19 +00:00
|
|
|
KWayland::Server::IdleInterface *m_idle = nullptr;
|
2015-11-10 13:21:48 +00:00
|
|
|
struct {
|
|
|
|
KWayland::Server::ClientConnection *client = nullptr;
|
|
|
|
QMetaObject::Connection destroyConnection;
|
|
|
|
} m_xwayland;
|
2015-06-13 02:06:12 +00:00
|
|
|
KWayland::Server::ClientConnection *m_inputMethodServerConnection = nullptr;
|
2015-11-06 14:08:13 +00:00
|
|
|
KWayland::Server::ClientConnection *m_screenLockerClientConnection = nullptr;
|
2015-04-02 12:37:23 +00:00
|
|
|
struct {
|
|
|
|
KWayland::Server::ClientConnection *server = nullptr;
|
|
|
|
KWayland::Client::ConnectionThread *client = nullptr;
|
2015-08-17 07:42:12 +00:00
|
|
|
QThread *clientThread = nullptr;
|
2015-08-14 07:28:46 +00:00
|
|
|
KWayland::Client::Registry *registry = nullptr;
|
2015-04-02 12:37:23 +00:00
|
|
|
KWayland::Client::ShmPool *shm = nullptr;
|
2017-09-30 14:33:45 +00:00
|
|
|
bool interfacesAnnounced = false;
|
2015-04-02 12:37:23 +00:00
|
|
|
|
|
|
|
} m_internalConnection;
|
2016-06-20 09:21:16 +00:00
|
|
|
struct {
|
|
|
|
QProcess *process = nullptr;
|
|
|
|
KWayland::Server::ClientConnection *client = nullptr;
|
|
|
|
QPointer<KWayland::Server::DataDeviceInterface> ddi;
|
|
|
|
} m_xclipbaordSync;
|
2017-10-13 09:32:02 +00:00
|
|
|
KWayland::Server::XdgForeignInterface *m_XdgForeign = nullptr;
|
2015-03-04 08:21:10 +00:00
|
|
|
QList<ShellClient*> m_clients;
|
2015-05-21 08:35:03 +00:00
|
|
|
QList<ShellClient*> m_internalClients;
|
2015-05-21 07:59:45 +00:00
|
|
|
QHash<KWayland::Server::ClientConnection*, quint16> m_clientIds;
|
2015-11-05 13:09:23 +00:00
|
|
|
InitalizationFlags m_initFlags;
|
2017-02-07 18:18:18 +00:00
|
|
|
QVector<KWayland::Server::PlasmaShellSurfaceInterface*> m_plasmaShellSurfaces;
|
2015-02-09 12:28:37 +00:00
|
|
|
KWIN_SINGLETON(WaylandServer)
|
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
WaylandServer *waylandServer() {
|
|
|
|
return WaylandServer::self();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|