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 126 Lines • ▼ Show 20 Line(s) | 250 | connect(m_xdgDecorationManager, &XdgDecorationManagerInterface::xdgDecorationInterfaceCreated, this, [this] (XdgDecorationInterface *deco) { | |||
249 | } | 253 | } | ||
250 | }); | 254 | }); | ||
251 | 255 | | |||
252 | m_display->createShm(); | 256 | m_display->createShm(); | ||
253 | m_seat = m_display->createSeat(m_display); | 257 | m_seat = m_display->createSeat(m_display); | ||
254 | m_seat->create(); | 258 | m_seat->create(); | ||
255 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | 259 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | ||
256 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | 260 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | ||
257 | auto ddm = m_display->createDataDeviceManager(m_display); | 261 | m_dataDeviceManager = m_display->createDataDeviceManager(m_display); | ||
258 | ddm->create(); | 262 | m_dataDeviceManager->create(); | ||
259 | connect(ddm, &DataDeviceManagerInterface::dataDeviceCreated, this, | 263 | connect(m_dataDeviceManager, &DataDeviceManagerInterface::dataDeviceCreated, this, | ||
260 | [this] (DataDeviceInterface *ddi) { | 264 | [this] (DataDeviceInterface *ddi) { | ||
261 | if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { | 265 | if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { | ||
262 | m_xclipbaordSync.ddi = QPointer<DataDeviceInterface>(ddi); | 266 | m_xclipbaordSync.ddi = QPointer<DataDeviceInterface>(ddi); | ||
263 | emit xclipboardSyncDataDeviceCreated(); | 267 | emit xclipboardSyncDataDeviceCreated(); | ||
264 | connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, | 268 | connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, | ||
265 | [this] { | 269 | [this] { | ||
266 | // testing whether the active client inherits Client | 270 | // testing whether the active client inherits Client | ||
267 | // it would be better to test for the keyboard focus, but we might get a clipboard update | 271 | // it would be better to test for the keyboard focus, but we might get a clipboard update | ||
▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Line(s) | 633 | [this] { | |||
634 | registry->create(m_internalConnection.client); | 638 | registry->create(m_internalConnection.client); | ||
635 | m_internalConnection.registry = registry; | 639 | m_internalConnection.registry = registry; | ||
636 | connect(registry, &Registry::shmAnnounced, this, | 640 | connect(registry, &Registry::shmAnnounced, this, | ||
637 | [this] (quint32 name, quint32 version) { | 641 | [this] (quint32 name, quint32 version) { | ||
638 | m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this); | 642 | m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this); | ||
639 | } | 643 | } | ||
640 | ); | 644 | ); | ||
641 | connect(registry, &Registry::interfacesAnnounced, this, | 645 | connect(registry, &Registry::interfacesAnnounced, this, | ||
642 | [this] { | 646 | [this, registry] { | ||
643 | m_internalConnection.interfacesAnnounced = true; | 647 | m_internalConnection.interfacesAnnounced = true; | ||
648 | | ||||
649 | const auto seatInterface = registry->interface(Registry::Interface::Seat); | ||||
650 | if (seatInterface.name != 0) { | ||||
651 | m_internalConnection.seat = registry->createSeat(seatInterface.name, seatInterface.version, this); | ||||
652 | } | ||||
653 | const auto ddmInterface = registry->interface(Registry::Interface::DataDeviceManager); | ||||
654 | if (ddmInterface.name != 0) { | ||||
655 | m_internalConnection.ddm = registry->createDataDeviceManager(ddmInterface.name, ddmInterface.version, this); | ||||
656 | } | ||||
644 | } | 657 | } | ||
645 | ); | 658 | ); | ||
646 | registry->setup(); | 659 | registry->setup(); | ||
647 | } | 660 | } | ||
648 | ); | 661 | ); | ||
649 | m_internalConnection.client->initConnection(); | 662 | m_internalConnection.client->initConnection(); | ||
650 | } | 663 | } | ||
651 | 664 | | |||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |