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 All 40 Lines | |||||
81 | KWIN_SINGLETON_FACTORY(WaylandServer) | 83 | KWIN_SINGLETON_FACTORY(WaylandServer) | ||
82 | 84 | | |||
83 | WaylandServer::WaylandServer(QObject *parent) | 85 | WaylandServer::WaylandServer(QObject *parent) | ||
84 | : QObject(parent) | 86 | : QObject(parent) | ||
85 | { | 87 | { | ||
86 | qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>(); | 88 | qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>(); | ||
87 | 89 | | |||
88 | connect(kwinApp(), &Application::screensCreated, this, &WaylandServer::initOutputs); | 90 | connect(kwinApp(), &Application::screensCreated, this, &WaylandServer::initOutputs); | ||
89 | connect(kwinApp(), &Application::x11ConnectionChanged, this, &WaylandServer::setupX11ClipboardSync); | 91 | // connect(kwinApp(), &Application::x11ConnectionChanged, this, &WaylandServer::setupX11ClipboardSync); | ||
90 | } | 92 | } | ||
91 | 93 | | |||
92 | WaylandServer::~WaylandServer() | 94 | WaylandServer::~WaylandServer() | ||
93 | { | 95 | { | ||
94 | destroyInputMethodConnection(); | 96 | destroyInputMethodConnection(); | ||
95 | } | 97 | } | ||
96 | 98 | | |||
97 | void WaylandServer::destroyInternalConnection() | 99 | void WaylandServer::destroyInternalConnection() | ||
98 | { | 100 | { | ||
99 | emit terminatingInternalClientConnection(); | 101 | emit terminatingInternalClientConnection(); | ||
100 | if (m_internalConnection.client) { | 102 | if (m_internalConnection.client) { | ||
101 | // delete all connections hold by plugins like e.g. widget style | 103 | // delete all connections hold by plugins like e.g. widget style | ||
102 | const auto connections = KWayland::Client::ConnectionThread::connections(); | 104 | const auto connections = KWayland::Client::ConnectionThread::connections(); | ||
103 | for (auto c : connections) { | 105 | for (auto c : connections) { | ||
104 | if (c == m_internalConnection.client) { | 106 | if (c == m_internalConnection.client) { | ||
105 | continue; | 107 | continue; | ||
106 | } | 108 | } | ||
107 | emit c->connectionDied(); | 109 | emit c->connectionDied(); | ||
108 | } | 110 | } | ||
109 | 111 | | |||
110 | delete m_internalConnection.registry; | 112 | delete m_internalConnection.registry; | ||
113 | delete m_internalConnection.seat; | ||||
114 | delete m_internalConnection.ddm; | ||||
111 | delete m_internalConnection.shm; | 115 | delete m_internalConnection.shm; | ||
112 | dispatch(); | 116 | dispatch(); | ||
113 | m_internalConnection.client->deleteLater(); | 117 | m_internalConnection.client->deleteLater(); | ||
114 | m_internalConnection.clientThread->quit(); | 118 | m_internalConnection.clientThread->quit(); | ||
115 | m_internalConnection.clientThread->wait(); | 119 | m_internalConnection.clientThread->wait(); | ||
116 | delete m_internalConnection.clientThread; | 120 | delete m_internalConnection.clientThread; | ||
117 | m_internalConnection.client = nullptr; | 121 | m_internalConnection.client = nullptr; | ||
118 | m_internalConnection.server->destroy(); | 122 | m_internalConnection.server->destroy(); | ||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 187 | { | |||
227 | connect(m_xdgShell6, &XdgShellInterface::xdgPopupCreated, this, &WaylandServer::createSurface<XdgShellPopupInterface>); | 231 | connect(m_xdgShell6, &XdgShellInterface::xdgPopupCreated, this, &WaylandServer::createSurface<XdgShellPopupInterface>); | ||
228 | 232 | | |||
229 | 233 | | |||
230 | m_display->createShm(); | 234 | m_display->createShm(); | ||
231 | m_seat = m_display->createSeat(m_display); | 235 | m_seat = m_display->createSeat(m_display); | ||
232 | m_seat->create(); | 236 | m_seat->create(); | ||
233 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | 237 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | ||
234 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | 238 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | ||
235 | auto ddm = m_display->createDataDeviceManager(m_display); | 239 | m_dataDeviceManager = m_display->createDataDeviceManager(m_display); | ||
236 | ddm->create(); | 240 | m_dataDeviceManager->create(); | ||
237 | connect(ddm, &DataDeviceManagerInterface::dataDeviceCreated, this, | 241 | connect(m_dataDeviceManager, &DataDeviceManagerInterface::dataDeviceCreated, this, | ||
238 | [this] (DataDeviceInterface *ddi) { | 242 | [this] (DataDeviceInterface *ddi) { | ||
239 | if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { | 243 | if (ddi->client() == m_xclipbaordSync.client && m_xclipbaordSync.client != nullptr) { | ||
240 | m_xclipbaordSync.ddi = QPointer<DataDeviceInterface>(ddi); | 244 | m_xclipbaordSync.ddi = QPointer<DataDeviceInterface>(ddi); | ||
241 | connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, | 245 | connect(m_xclipbaordSync.ddi.data(), &DataDeviceInterface::selectionChanged, this, | ||
242 | [this] { | 246 | [this] { | ||
243 | // testing whether the active client inherits Client | 247 | // testing whether the active client inherits Client | ||
244 | // it would be better to test for the keyboard focus, but we might get a clipboard update | 248 | // it would be better to test for the keyboard focus, but we might get a clipboard update | ||
245 | // when the Client is already active, but no Surface is created yet. | 249 | // when the Client is already active, but no Surface is created yet. | ||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Line(s) | 602 | [this] { | |||
603 | registry->create(m_internalConnection.client); | 607 | registry->create(m_internalConnection.client); | ||
604 | m_internalConnection.registry = registry; | 608 | m_internalConnection.registry = registry; | ||
605 | connect(registry, &Registry::shmAnnounced, this, | 609 | connect(registry, &Registry::shmAnnounced, this, | ||
606 | [this] (quint32 name, quint32 version) { | 610 | [this] (quint32 name, quint32 version) { | ||
607 | m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this); | 611 | m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this); | ||
608 | } | 612 | } | ||
609 | ); | 613 | ); | ||
610 | connect(registry, &Registry::interfacesAnnounced, this, | 614 | connect(registry, &Registry::interfacesAnnounced, this, | ||
611 | [this] { | 615 | [this, registry] { | ||
612 | m_internalConnection.interfacesAnnounced = true; | 616 | m_internalConnection.interfacesAnnounced = true; | ||
617 | | ||||
618 | const auto seatInterface = registry->interface(Registry::Interface::Seat); | ||||
619 | if (seatInterface.name != 0) { | ||||
620 | m_internalConnection.seat = registry->createSeat(seatInterface.name, seatInterface.version, this); | ||||
621 | } | ||||
622 | const auto ddmInterface = registry->interface(Registry::Interface::DataDeviceManager); | ||||
623 | if (ddmInterface.name != 0) { | ||||
624 | m_internalConnection.ddm = registry->createDataDeviceManager(ddmInterface.name, ddmInterface.version, this); | ||||
625 | } | ||||
613 | } | 626 | } | ||
614 | ); | 627 | ); | ||
615 | registry->setup(); | 628 | registry->setup(); | ||
616 | } | 629 | } | ||
617 | ); | 630 | ); | ||
618 | m_internalConnection.client->initConnection(); | 631 | m_internalConnection.client->initConnection(); | ||
619 | } | 632 | } | ||
620 | 633 | | |||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |