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>
|
|
|
|
|
2015-08-17 07:42:12 +00:00
|
|
|
class QThread;
|
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
|
|
|
|
{
|
2015-02-25 13:15:32 +00:00
|
|
|
class ClientConnection;
|
2015-02-09 12:28:37 +00:00
|
|
|
class CompositorInterface;
|
|
|
|
class Display;
|
|
|
|
class ShellInterface;
|
|
|
|
class SeatInterface;
|
2015-12-17 10:14:54 +00:00
|
|
|
class ServerSideDecorationManagerInterface;
|
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;
|
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;
|
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;
|
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();
|
2015-11-05 13:09:23 +00:00
|
|
|
void 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;
|
2015-08-17 12:56:15 +00:00
|
|
|
ShellClient *findClient(QWindow *w) const;
|
2015-02-09 12:28:37 +00:00
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
}
|
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
|
|
|
|
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();
|
2015-03-04 08:21:10 +00:00
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
private:
|
2016-04-25 07:45:04 +00:00
|
|
|
void initOutputs();
|
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);
|
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;
|
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;
|
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;
|
|
|
|
|
|
|
|
} m_internalConnection;
|
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;
|
2015-02-09 12:28:37 +00:00
|
|
|
KWIN_SINGLETON(WaylandServer)
|
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
WaylandServer *waylandServer() {
|
|
|
|
return WaylandServer::self();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|