Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.cpp
Show All 24 Lines | |||||
25 | #include "screens.h" | 25 | #include "screens.h" | ||
26 | #include "shell_client.h" | 26 | #include "shell_client.h" | ||
27 | #include "workspace.h" | 27 | #include "workspace.h" | ||
28 | 28 | | |||
29 | // Client | 29 | // Client | ||
30 | #include <KWayland/Client/connection_thread.h> | 30 | #include <KWayland/Client/connection_thread.h> | ||
31 | #include <KWayland/Client/event_queue.h> | 31 | #include <KWayland/Client/event_queue.h> | ||
32 | #include <KWayland/Client/registry.h> | 32 | #include <KWayland/Client/registry.h> | ||
33 | #include <KWayland/Client/seat.h> | ||||
34 | #include <KWayland/Client/datadevicemanager.h> | ||||
33 | #include <KWayland/Client/shm_pool.h> | 35 | #include <KWayland/Client/shm_pool.h> | ||
34 | #include <KWayland/Client/surface.h> | 36 | #include <KWayland/Client/surface.h> | ||
35 | // Server | 37 | // Server | ||
36 | #include <KWayland/Server/appmenu_interface.h> | 38 | #include <KWayland/Server/appmenu_interface.h> | ||
37 | #include <KWayland/Server/compositor_interface.h> | 39 | #include <KWayland/Server/compositor_interface.h> | ||
38 | #include <KWayland/Server/datadevicemanager_interface.h> | 40 | #include <KWayland/Server/datadevicemanager_interface.h> | ||
39 | #include <KWayland/Server/datasource_interface.h> | 41 | #include <KWayland/Server/datasource_interface.h> | ||
40 | #include <KWayland/Server/display.h> | 42 | #include <KWayland/Server/display.h> | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
85 | KWIN_SINGLETON_FACTORY(WaylandServer) | 87 | KWIN_SINGLETON_FACTORY(WaylandServer) | ||
86 | 88 | | |||
87 | WaylandServer::WaylandServer(QObject *parent) | 89 | WaylandServer::WaylandServer(QObject *parent) | ||
88 | : QObject(parent) | 90 | : QObject(parent) | ||
89 | { | 91 | { | ||
90 | qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>(); | 92 | qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>(); | ||
91 | 93 | | |||
92 | connect(kwinApp(), &Application::screensCreated, this, &WaylandServer::initOutputs); | 94 | connect(kwinApp(), &Application::screensCreated, this, &WaylandServer::initOutputs); | ||
93 | connect(kwinApp(), &Application::x11ConnectionChanged, this, &WaylandServer::setupX11ClipboardSync); | 95 | // connect(kwinApp(), &Application::x11ConnectionChanged, this, &WaylandServer::setupX11ClipboardSync); | ||
94 | } | 96 | } | ||
95 | 97 | | |||
96 | WaylandServer::~WaylandServer() | 98 | WaylandServer::~WaylandServer() | ||
97 | { | 99 | { | ||
98 | destroyInputMethodConnection(); | 100 | destroyInputMethodConnection(); | ||
99 | } | 101 | } | ||
100 | 102 | | |||
101 | void WaylandServer::destroyInternalConnection() | 103 | void WaylandServer::destroyInternalConnection() | ||
102 | { | 104 | { | ||
103 | emit terminatingInternalClientConnection(); | 105 | emit terminatingInternalClientConnection(); | ||
104 | if (m_internalConnection.client) { | 106 | if (m_internalConnection.client) { | ||
105 | // delete all connections hold by plugins like e.g. widget style | 107 | // delete all connections hold by plugins like e.g. widget style | ||
106 | const auto connections = KWayland::Client::ConnectionThread::connections(); | 108 | const auto connections = KWayland::Client::ConnectionThread::connections(); | ||
107 | for (auto c : connections) { | 109 | for (auto c : connections) { | ||
108 | if (c == m_internalConnection.client) { | 110 | if (c == m_internalConnection.client) { | ||
109 | continue; | 111 | continue; | ||
110 | } | 112 | } | ||
111 | emit c->connectionDied(); | 113 | emit c->connectionDied(); | ||
112 | } | 114 | } | ||
113 | 115 | | |||
114 | delete m_internalConnection.registry; | 116 | delete m_internalConnection.registry; | ||
117 | delete m_internalConnection.seat; | ||||
118 | delete m_internalConnection.ddm; | ||||
115 | delete m_internalConnection.shm; | 119 | delete m_internalConnection.shm; | ||
116 | dispatch(); | 120 | dispatch(); | ||
117 | m_internalConnection.client->deleteLater(); | 121 | m_internalConnection.client->deleteLater(); | ||
118 | m_internalConnection.clientThread->quit(); | 122 | m_internalConnection.clientThread->quit(); | ||
119 | m_internalConnection.clientThread->wait(); | 123 | m_internalConnection.clientThread->wait(); | ||
120 | delete m_internalConnection.clientThread; | 124 | delete m_internalConnection.clientThread; | ||
121 | m_internalConnection.client = nullptr; | 125 | m_internalConnection.client = nullptr; | ||
122 | m_internalConnection.server->destroy(); | 126 | m_internalConnection.server->destroy(); | ||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 245 | connect(m_xdgDecorationManager, &XdgDecorationManagerInterface::xdgDecorationInterfaceCreated, this, [this] (XdgDecorationInterface *deco) { | |||
244 | } | 248 | } | ||
245 | }); | 249 | }); | ||
246 | 250 | | |||
247 | m_display->createShm(); | 251 | m_display->createShm(); | ||
248 | m_seat = m_display->createSeat(m_display); | 252 | m_seat = m_display->createSeat(m_display); | ||
249 | m_seat->create(); | 253 | m_seat->create(); | ||
250 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | 254 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | ||
251 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | 255 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | ||
252 | auto ddm = m_display->createDataDeviceManager(m_display); | 256 | m_dataDeviceManager = m_display->createDataDeviceManager(m_display); | ||
253 | ddm->create(); | 257 | m_dataDeviceManager->create(); | ||
254 | connect(ddm, &DataDeviceManagerInterface::dataDeviceCreated, this, | 258 | connect(m_dataDeviceManager, &DataDeviceManagerInterface::dataDeviceCreated, this, | ||
255 | [this] (DataDeviceInterface *ddi) { | 259 | [this] (DataDeviceInterface *ddi) { | ||
256 | if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { | 260 | if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { | ||
257 | m_xclipbaordSync.ddi = QPointer<DataDeviceInterface>(ddi); | 261 | m_xclipbaordSync.ddi = QPointer<DataDeviceInterface>(ddi); | ||
258 | emit xclipboardSyncDataDeviceCreated(); | 262 | emit xclipboardSyncDataDeviceCreated(); | ||
259 | connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, | 263 | connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, | ||
260 | [this] { | 264 | [this] { | ||
261 | // testing whether the active client inherits Client | 265 | // testing whether the active client inherits Client | ||
262 | // it would be better to test for the keyboard focus, but we might get a clipboard update | 266 | // it would be better to test for the keyboard focus, but we might get a clipboard update | ||
▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Line(s) | 639 | [this] { | |||
640 | registry->create(m_internalConnection.client); | 644 | registry->create(m_internalConnection.client); | ||
641 | m_internalConnection.registry = registry; | 645 | m_internalConnection.registry = registry; | ||
642 | connect(registry, &Registry::shmAnnounced, this, | 646 | connect(registry, &Registry::shmAnnounced, this, | ||
643 | [this] (quint32 name, quint32 version) { | 647 | [this] (quint32 name, quint32 version) { | ||
644 | m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this); | 648 | m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this); | ||
645 | } | 649 | } | ||
646 | ); | 650 | ); | ||
647 | connect(registry, &Registry::interfacesAnnounced, this, | 651 | connect(registry, &Registry::interfacesAnnounced, this, | ||
648 | [this] { | 652 | [this, registry] { | ||
649 | m_internalConnection.interfacesAnnounced = true; | 653 | m_internalConnection.interfacesAnnounced = true; | ||
654 | | ||||
655 | const auto seatInterface = registry->interface(Registry::Interface::Seat); | ||||
656 | if (seatInterface.name != 0) { | ||||
657 | m_internalConnection.seat = registry->createSeat(seatInterface.name, seatInterface.version, this); | ||||
658 | } | ||||
659 | const auto ddmInterface = registry->interface(Registry::Interface::DataDeviceManager); | ||||
660 | if (ddmInterface.name != 0) { | ||||
661 | m_internalConnection.ddm = registry->createDataDeviceManager(ddmInterface.name, ddmInterface.version, this); | ||||
662 | } | ||||
650 | } | 663 | } | ||
651 | ); | 664 | ); | ||
652 | registry->setup(); | 665 | registry->setup(); | ||
653 | } | 666 | } | ||
654 | ); | 667 | ); | ||
655 | m_internalConnection.client->initConnection(); | 668 | m_internalConnection.client->initConnection(); | ||
656 | } | 669 | } | ||
657 | 670 | | |||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |