2015-02-09 15:28:37 +03: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 12:21:16 +03:00
|
|
|
#include <QPointer>
|
2015-02-09 15:28:37 +03:00
|
|
|
|
2015-08-17 10:42:12 +03:00
|
|
|
class QThread;
|
2016-06-20 12:21:16 +03:00
|
|
|
class QProcess;
|
2015-05-18 12:23:45 +03:00
|
|
|
class QWindow;
|
|
|
|
|
2015-02-09 15:28:37 +03:00
|
|
|
namespace KWayland
|
|
|
|
{
|
2015-04-02 15:37:23 +03:00
|
|
|
namespace Client
|
|
|
|
{
|
|
|
|
class ConnectionThread;
|
2015-08-14 10:28:46 +03:00
|
|
|
class Registry;
|
2015-04-02 15:37:23 +03:00
|
|
|
class ShmPool;
|
2015-05-18 12:23:45 +03:00
|
|
|
class Surface;
|
2015-04-02 15:37:23 +03:00
|
|
|
}
|
2015-02-09 15:28:37 +03:00
|
|
|
namespace Server
|
|
|
|
{
|
2015-02-25 16:15:32 +03:00
|
|
|
class ClientConnection;
|
2015-02-09 15:28:37 +03:00
|
|
|
class CompositorInterface;
|
|
|
|
class Display;
|
2016-06-20 12:21:16 +03:00
|
|
|
class DataDeviceInterface;
|
2015-02-09 15:28:37 +03:00
|
|
|
class ShellInterface;
|
|
|
|
class SeatInterface;
|
2015-12-17 13:14:54 +03:00
|
|
|
class ServerSideDecorationManagerInterface;
|
2015-05-21 10:59:45 +03:00
|
|
|
class SurfaceInterface;
|
2015-02-09 15:28:37 +03:00
|
|
|
class OutputInterface;
|
2015-06-09 20:10:56 +03:00
|
|
|
class PlasmaShellInterface;
|
2017-02-07 21:18:18 +03:00
|
|
|
class PlasmaShellSurfaceInterface;
|
2015-06-13 02:48:11 +03:00
|
|
|
class PlasmaWindowManagementInterface;
|
2015-06-10 01:59:53 +03:00
|
|
|
class QtSurfaceExtensionInterface;
|
2016-03-10 21:57:07 +03:00
|
|
|
class OutputManagementInterface;
|
|
|
|
class OutputConfigurationInterface;
|
2016-04-22 15:13:37 +03:00
|
|
|
class XdgShellInterface;
|
2017-10-13 12:32:02 +03:00
|
|
|
class XdgForeignInterface;
|
2015-02-09 15:28:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
2015-03-04 11:21:10 +03:00
|
|
|
class ShellClient;
|
2015-02-09 15:28:37 +03:00
|
|
|
|
2015-06-16 07:50:22 +03:00
|
|
|
class AbstractClient;
|
2016-06-07 12:43:56 +03:00
|
|
|
class Toplevel;
|
2015-03-20 16:41:03 +03:00
|
|
|
|
2015-02-09 15:28:37 +03:00
|
|
|
class KWIN_EXPORT WaylandServer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-11-05 16:09:23 +03:00
|
|
|
enum class InitalizationFlag {
|
|
|
|
NoOptions = 0x0,
|
2016-04-25 09:51:33 +03:00
|
|
|
LockScreen = 0x1,
|
|
|
|
NoLockScreenIntegration = 0x2
|
2015-11-05 16:09:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag)
|
|
|
|
|
2015-02-09 15:28:37 +03:00
|
|
|
virtual ~WaylandServer();
|
2016-07-04 10:09:03 +03:00
|
|
|
bool init(const QByteArray &socketName = QByteArray(), InitalizationFlags flags = InitalizationFlag::NoOptions);
|
2015-11-18 12:29:10 +03:00
|
|
|
void terminateClientConnections();
|
2015-02-09 15:28:37 +03: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 10:10:33 +03:00
|
|
|
KWayland::Server::PlasmaWindowManagementInterface *windowManagement() {
|
|
|
|
return m_windowManagement;
|
|
|
|
}
|
2015-12-17 13:14:54 +03:00
|
|
|
KWayland::Server::ServerSideDecorationManagerInterface *decorationManager() const {
|
|
|
|
return m_decorationManager;
|
|
|
|
}
|
2015-03-04 11:21:10 +03:00
|
|
|
QList<ShellClient*> clients() const {
|
|
|
|
return m_clients;
|
|
|
|
}
|
2015-05-21 11:35:03 +03:00
|
|
|
QList<ShellClient*> internalClients() const {
|
|
|
|
return m_internalClients;
|
|
|
|
}
|
2015-03-04 11:21:10 +03:00
|
|
|
void removeClient(ShellClient *c);
|
2015-05-18 15:51:40 +03:00
|
|
|
ShellClient *findClient(quint32 id) const;
|
2015-06-09 20:10:56 +03:00
|
|
|
ShellClient *findClient(KWayland::Server::SurfaceInterface *surface) const;
|
2016-08-22 17:55:48 +03:00
|
|
|
AbstractClient *findAbstractClient(KWayland::Server::SurfaceInterface *surface) const;
|
2015-08-17 15:56:15 +03:00
|
|
|
ShellClient *findClient(QWindow *w) const;
|
2015-02-09 15:28:37 +03:00
|
|
|
|
2017-10-13 12:32:02 +03: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 16:15:32 +03:00
|
|
|
/**
|
|
|
|
* @returns file descriptor for Xwayland to connect to.
|
|
|
|
**/
|
|
|
|
int createXWaylandConnection();
|
2015-11-10 16:21:48 +03:00
|
|
|
void destroyXWaylandConnection();
|
2015-02-25 16:15:32 +03:00
|
|
|
|
2015-06-13 05:06:12 +03:00
|
|
|
/**
|
|
|
|
* @returns file descriptor to the input method server's socket.
|
|
|
|
**/
|
|
|
|
int createInputMethodConnection();
|
2015-11-10 16:38:45 +03:00
|
|
|
void destroyInputMethodConnection();
|
2015-06-13 05:06:12 +03:00
|
|
|
|
2016-06-20 12:21:16 +03:00
|
|
|
int createXclipboardSyncConnection();
|
|
|
|
|
2015-11-16 13:19:38 +03:00
|
|
|
/**
|
|
|
|
* @returns true if screen is locked.
|
|
|
|
**/
|
|
|
|
bool isScreenLocked() const;
|
2016-04-25 09:51:33 +03:00
|
|
|
/**
|
|
|
|
* @returns whether integration with KScreenLocker is available.
|
|
|
|
**/
|
|
|
|
bool hasScreenLockerIntegration() const;
|
2015-11-16 13:19:38 +03:00
|
|
|
|
2015-04-02 15:37:23 +03:00
|
|
|
void createInternalConnection();
|
2015-06-13 02:48:11 +03:00
|
|
|
void initWorkspace();
|
2015-02-25 16:46:30 +03:00
|
|
|
|
2015-04-02 10:49:39 +03:00
|
|
|
KWayland::Server::ClientConnection *xWaylandConnection() const {
|
2015-11-10 16:21:48 +03:00
|
|
|
return m_xwayland.client;
|
2015-04-02 10:49:39 +03:00
|
|
|
}
|
2015-06-13 05:06:12 +03:00
|
|
|
KWayland::Server::ClientConnection *inputMethodConnection() const {
|
|
|
|
return m_inputMethodServerConnection;
|
|
|
|
}
|
2015-04-02 15:37:23 +03:00
|
|
|
KWayland::Server::ClientConnection *internalConnection() const {
|
|
|
|
return m_internalConnection.server;
|
|
|
|
}
|
2015-11-06 17:08:13 +03:00
|
|
|
KWayland::Server::ClientConnection *screenLockerClientConnection() const {
|
|
|
|
return m_screenLockerClientConnection;
|
|
|
|
}
|
2016-06-20 12:21:16 +03:00
|
|
|
QPointer<KWayland::Server::DataDeviceInterface> xclipboardSyncDataDevice() const {
|
|
|
|
return m_xclipbaordSync.ddi;
|
|
|
|
}
|
2015-04-02 15:37:23 +03:00
|
|
|
KWayland::Client::ShmPool *internalShmPool() {
|
|
|
|
return m_internalConnection.shm;
|
|
|
|
}
|
|
|
|
KWayland::Client::ConnectionThread *internalClientConection() {
|
|
|
|
return m_internalConnection.client;
|
|
|
|
}
|
2015-08-14 10:28:46 +03:00
|
|
|
KWayland::Client::Registry *internalClientRegistry() {
|
|
|
|
return m_internalConnection.registry;
|
|
|
|
}
|
2015-05-18 12:33:00 +03:00
|
|
|
void dispatch();
|
2015-05-21 10:59:45 +03:00
|
|
|
quint32 createWindowId(KWayland::Server::SurfaceInterface *surface);
|
2015-04-02 10:49:39 +03:00
|
|
|
|
2016-12-03 16:54:32 +03: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();
|
|
|
|
|
2015-03-04 11:21:10 +03:00
|
|
|
Q_SIGNALS:
|
2015-10-05 18:35:53 +03:00
|
|
|
void shellClientAdded(KWin::ShellClient*);
|
|
|
|
void shellClientRemoved(KWin::ShellClient*);
|
2016-02-02 14:00:12 +03:00
|
|
|
void terminatingInternalClientConnection();
|
2016-08-16 10:26:17 +03:00
|
|
|
void initialized();
|
2017-10-13 12:32:02 +03:00
|
|
|
void foreignTransientChanged(KWayland::Server::SurfaceInterface *child);
|
2015-03-04 11:21:10 +03:00
|
|
|
|
2015-02-09 15:28:37 +03:00
|
|
|
private:
|
2016-06-20 12:21:16 +03:00
|
|
|
void setupX11ClipboardSync();
|
2016-06-07 12:43:56 +03:00
|
|
|
void shellClientShown(Toplevel *t);
|
2016-04-25 10:45:04 +03:00
|
|
|
void initOutputs();
|
2016-07-20 12:42:52 +03:00
|
|
|
void syncOutputsToWayland();
|
2015-05-21 10:59:45 +03:00
|
|
|
quint16 createClientId(KWayland::Server::ClientConnection *c);
|
2015-11-18 12:29:10 +03:00
|
|
|
void destroyInternalConnection();
|
2016-03-10 21:57:07 +03:00
|
|
|
void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config);
|
2016-04-22 15:13:37 +03:00
|
|
|
template <class T>
|
|
|
|
void createSurface(T *surface);
|
2017-09-30 17:33:45 +03:00
|
|
|
void initScreenLocker();
|
2015-02-09 15:28:37 +03: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 15:13:37 +03: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 18:37:59 +03:00
|
|
|
KWayland::Server::XdgShellInterface *m_xdgShell6 = nullptr;
|
2015-06-09 20:10:56 +03:00
|
|
|
KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr;
|
2015-06-13 02:48:11 +03:00
|
|
|
KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr;
|
2015-06-10 01:59:53 +03:00
|
|
|
KWayland::Server::QtSurfaceExtensionInterface *m_qtExtendedSurface = nullptr;
|
2015-12-17 13:14:54 +03:00
|
|
|
KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr;
|
2016-03-10 21:57:07 +03:00
|
|
|
KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr;
|
2015-11-10 16:21:48 +03:00
|
|
|
struct {
|
|
|
|
KWayland::Server::ClientConnection *client = nullptr;
|
|
|
|
QMetaObject::Connection destroyConnection;
|
|
|
|
} m_xwayland;
|
2015-06-13 05:06:12 +03:00
|
|
|
KWayland::Server::ClientConnection *m_inputMethodServerConnection = nullptr;
|
2015-11-06 17:08:13 +03:00
|
|
|
KWayland::Server::ClientConnection *m_screenLockerClientConnection = nullptr;
|
2015-04-02 15:37:23 +03:00
|
|
|
struct {
|
|
|
|
KWayland::Server::ClientConnection *server = nullptr;
|
|
|
|
KWayland::Client::ConnectionThread *client = nullptr;
|
2015-08-17 10:42:12 +03:00
|
|
|
QThread *clientThread = nullptr;
|
2015-08-14 10:28:46 +03:00
|
|
|
KWayland::Client::Registry *registry = nullptr;
|
2015-04-02 15:37:23 +03:00
|
|
|
KWayland::Client::ShmPool *shm = nullptr;
|
2017-09-30 17:33:45 +03:00
|
|
|
bool interfacesAnnounced = false;
|
2015-04-02 15:37:23 +03:00
|
|
|
|
|
|
|
} m_internalConnection;
|
2016-06-20 12:21:16 +03:00
|
|
|
struct {
|
|
|
|
QProcess *process = nullptr;
|
|
|
|
KWayland::Server::ClientConnection *client = nullptr;
|
|
|
|
QPointer<KWayland::Server::DataDeviceInterface> ddi;
|
|
|
|
} m_xclipbaordSync;
|
2017-10-13 12:32:02 +03:00
|
|
|
KWayland::Server::XdgForeignInterface *m_XdgForeign = nullptr;
|
2015-03-04 11:21:10 +03:00
|
|
|
QList<ShellClient*> m_clients;
|
2015-05-21 11:35:03 +03:00
|
|
|
QList<ShellClient*> m_internalClients;
|
2015-05-21 10:59:45 +03:00
|
|
|
QHash<KWayland::Server::ClientConnection*, quint16> m_clientIds;
|
2015-11-05 16:09:23 +03:00
|
|
|
InitalizationFlags m_initFlags;
|
2017-02-07 21:18:18 +03:00
|
|
|
QVector<KWayland::Server::PlasmaShellSurfaceInterface*> m_plasmaShellSurfaces;
|
2015-02-09 15:28:37 +03:00
|
|
|
KWIN_SINGLETON(WaylandServer)
|
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
WaylandServer *waylandServer() {
|
|
|
|
return WaylandServer::self();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|