Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.cpp
Show All 19 Lines | |||||
20 | #include "wayland_server.h" | 20 | #include "wayland_server.h" | ||
21 | #include "x11client.h" | 21 | #include "x11client.h" | ||
22 | #include "platform.h" | 22 | #include "platform.h" | ||
23 | #include "composite.h" | 23 | #include "composite.h" | ||
24 | #include "idle_inhibition.h" | 24 | #include "idle_inhibition.h" | ||
25 | #include "screens.h" | 25 | #include "screens.h" | ||
26 | #include "xdgshellclient.h" | 26 | #include "xdgshellclient.h" | ||
27 | #include "workspace.h" | 27 | #include "workspace.h" | ||
28 | #include "internal_client.h" | ||||
29 | #include "deleted.h" | ||||
28 | 30 | | |||
29 | // Client | 31 | // Client | ||
30 | #include <KWayland/Client/connection_thread.h> | 32 | #include <KWayland/Client/connection_thread.h> | ||
31 | #include <KWayland/Client/event_queue.h> | 33 | #include <KWayland/Client/event_queue.h> | ||
32 | #include <KWayland/Client/registry.h> | 34 | #include <KWayland/Client/registry.h> | ||
33 | #include <KWayland/Client/compositor.h> | 35 | #include <KWayland/Client/compositor.h> | ||
34 | #include <KWayland/Client/seat.h> | 36 | #include <KWayland/Client/seat.h> | ||
35 | #include <KWayland/Client/datadevicemanager.h> | 37 | #include <KWayland/Client/datadevicemanager.h> | ||
Show All 25 Lines | |||||
61 | #include <KWayland/Server/outputmanagement_interface.h> | 63 | #include <KWayland/Server/outputmanagement_interface.h> | ||
62 | #include <KWayland/Server/outputconfiguration_interface.h> | 64 | #include <KWayland/Server/outputconfiguration_interface.h> | ||
63 | #include <KWayland/Server/xdgdecoration_interface.h> | 65 | #include <KWayland/Server/xdgdecoration_interface.h> | ||
64 | #include <KWayland/Server/xdgshell_interface.h> | 66 | #include <KWayland/Server/xdgshell_interface.h> | ||
65 | #include <KWayland/Server/xdgforeign_interface.h> | 67 | #include <KWayland/Server/xdgforeign_interface.h> | ||
66 | #include <KWayland/Server/xdgoutput_interface.h> | 68 | #include <KWayland/Server/xdgoutput_interface.h> | ||
67 | #include <KWayland/Server/keystate_interface.h> | 69 | #include <KWayland/Server/keystate_interface.h> | ||
68 | #include <KWayland/Server/filtered_display.h> | 70 | #include <KWayland/Server/filtered_display.h> | ||
71 | #include <KWayland/Server/inputmethod_interface.h> | ||||
69 | 72 | | |||
70 | // KF | 73 | // KF | ||
71 | #include <KServiceTypeTrader> | 74 | #include <KServiceTypeTrader> | ||
72 | 75 | | |||
73 | // Qt | 76 | // Qt | ||
74 | #include <QCryptographicHash> | 77 | #include <QCryptographicHash> | ||
75 | #include <QDir> | 78 | #include <QDir> | ||
76 | #include <QFileInfo> | 79 | #include <QFileInfo> | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 139 | { | |||
139 | if (m_display) { | 142 | if (m_display) { | ||
140 | const auto connections = m_display->connections(); | 143 | const auto connections = m_display->connections(); | ||
141 | for (auto it = connections.begin(); it != connections.end(); ++it) { | 144 | for (auto it = connections.begin(); it != connections.end(); ++it) { | ||
142 | (*it)->destroy(); | 145 | (*it)->destroy(); | ||
143 | } | 146 | } | ||
144 | } | 147 | } | ||
145 | } | 148 | } | ||
146 | 149 | | |||
150 | void WaylandServer::addClient(AbstractClient* client) | ||||
151 | { | ||||
152 | m_clients << client; | ||||
153 | if (client->readyForPainting()) { | ||||
154 | emit shellClientAdded(client); | ||||
155 | } else { | ||||
156 | connect(client, &AbstractClient::windowShown, this, &WaylandServer::shellClientShown); | ||||
157 | } | ||||
158 | | ||||
159 | //not directly connected as the connection is tied to client instead of this | ||||
160 | connect(m_XdgForeign, &KWayland::Server::XdgForeignInterface::transientChanged, client, [this](KWayland::Server::SurfaceInterface *child) { | ||||
161 | emit foreignTransientChanged(child); | ||||
162 | }); | ||||
zzag: Leave it in `createSurface()`. You can't use xdg-foreign with non xdg_toplevel equivalent… | |||||
163 | } | ||||
164 | | ||||
147 | template <class T> | 165 | template <class T> | ||
148 | void WaylandServer::createSurface(T *surface) | 166 | void WaylandServer::createSurface(T *surface) | ||
149 | { | 167 | { | ||
150 | if (!Workspace::self()) { | 168 | if (!Workspace::self()) { | ||
151 | // it's possible that a Surface gets created before Workspace is created | 169 | // it's possible that a Surface gets created before Workspace is created | ||
152 | return; | 170 | return; | ||
153 | } | 171 | } | ||
154 | if (surface->client() == m_xwayland.client) { | 172 | if (surface->client() == m_xwayland.client) { | ||
Show All 17 Lines | 188 | if (it != m_plasmaShellSurfaces.end()) { | |||
172 | m_plasmaShellSurfaces.erase(it); | 190 | m_plasmaShellSurfaces.erase(it); | ||
173 | } | 191 | } | ||
174 | if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) { | 192 | if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) { | ||
175 | client->installAppMenu(menu); | 193 | client->installAppMenu(menu); | ||
176 | } | 194 | } | ||
177 | if (auto palette = m_paletteManager->paletteForSurface(surface->surface())) { | 195 | if (auto palette = m_paletteManager->paletteForSurface(surface->surface())) { | ||
178 | client->installPalette(palette); | 196 | client->installPalette(palette); | ||
179 | } | 197 | } | ||
180 | m_clients << client; | 198 | addClient(client); | ||
181 | if (client->readyForPainting()) { | | |||
182 | emit shellClientAdded(client); | | |||
183 | } else { | | |||
184 | connect(client, &XdgShellClient::windowShown, this, &WaylandServer::shellClientShown); | | |||
185 | } | 199 | } | ||
186 | 200 | | |||
187 | //not directly connected as the connection is tied to client instead of this | 201 | class InputPanelClient : public WaylandClient | ||
188 | connect(m_XdgForeign, &KWayland::Server::XdgForeignInterface::transientChanged, client, [this](KWayland::Server::SurfaceInterface *child) { | 202 | { | ||
189 | emit foreignTransientChanged(child); | 203 | public: | ||
204 | InputPanelClient(KWayland::Server::InputPanelSurfaceInterface *panelSurface) | ||||
205 | : WaylandClient(panelSurface->surface()) | ||||
206 | { | ||||
207 | init(); | ||||
208 | setSkipPager(true); | ||||
209 | setSkipTaskbar(true); | ||||
210 | setKeepAbove(true); | ||||
211 | setNoBorder(true); | ||||
212 | | ||||
213 | setObjectName(QStringLiteral("Input Panel")); | ||||
214 | | ||||
215 | connect(panelSurface, &KWayland::Server::InputPanelSurfaceInterface::topLevel, this, [this, panelSurface] (OutputInterface *output, KWayland::Server::InputPanelSurfaceInterface::Position position) { | ||||
216 | const QSize panelSize = panelSurface->surface()->size(); | ||||
217 | QRect geo = {output->globalPosition(), panelSize}; | ||||
218 | if (position == KWayland::Server::InputPanelSurfaceInterface::CenterBottom) { | ||||
219 | geo.translate((output->pixelSize().width() - panelSize.width())/2, output->pixelSize().height() - panelSize.height()); | ||||
220 | } | ||||
221 | finishInit(); | ||||
222 | setFrameGeometry(geo); | ||||
190 | }); | 223 | }); | ||
224 | connect(panelSurface, &KWayland::Server::InputPanelSurfaceInterface::overlayPanel, this, [this, panelSurface] () { | ||||
225 | auto focusedField = waylandServer()->findClient(waylandServer()->seat()->focusedTextInputSurface()); | ||||
226 | if (focusedField) { | ||||
227 | finishInit(); | ||||
228 | setFrameGeometry({focusedField->pos(), panelSurface->surface()->size()}); | ||||
229 | } | ||||
230 | }); | ||||
231 | } | ||||
232 | | ||||
233 | bool isCloseable() const override { return false; } | ||||
234 | bool noBorder() const override { return true; } | ||||
235 | bool isResizable() const override { return false; } | ||||
236 | bool isMovable() const override { return false; } | ||||
237 | bool isMovableAcrossScreens() const override { return false; } | ||||
238 | bool userCanSetNoBorder() const override { return false; } | ||||
239 | bool acceptsFocus() const override { return false; } | ||||
240 | void showOnScreenEdge() override {} | ||||
241 | bool supportsWindowRules() const override { return false; } | ||||
242 | void closeWindow() override {} | ||||
243 | }; | ||||
244 | | ||||
245 | AbstractClient *WaylandServer::createInputPanelSurface(KWayland::Server::InputPanelSurfaceInterface *surface) | ||||
246 | { | ||||
247 | auto *client = new InputPanelClient(surface); | ||||
248 | addClient(client); | ||||
249 | return client; | ||||
191 | } | 250 | } | ||
192 | 251 | | |||
193 | class KWinDisplay : public KWayland::Server::FilteredDisplay | 252 | class KWinDisplay : public KWayland::Server::FilteredDisplay | ||
194 | { | 253 | { | ||
195 | public: | 254 | public: | ||
196 | KWinDisplay(QObject *parent) | 255 | KWinDisplay(QObject *parent) | ||
197 | : KWayland::Server::FilteredDisplay(parent) | 256 | : KWayland::Server::FilteredDisplay(parent) | ||
198 | {} | 257 | {} | ||
▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Line(s) | 342 | { | |||
443 | m_display->createSubCompositor(m_display)->create(); | 502 | m_display->createSubCompositor(m_display)->create(); | ||
444 | 503 | | |||
445 | m_XdgForeign = m_display->createXdgForeignInterface(m_display); | 504 | m_XdgForeign = m_display->createXdgForeignInterface(m_display); | ||
446 | m_XdgForeign->create(); | 505 | m_XdgForeign->create(); | ||
447 | 506 | | |||
448 | m_keyState = m_display->createKeyStateInterface(m_display); | 507 | m_keyState = m_display->createKeyStateInterface(m_display); | ||
449 | m_keyState->create(); | 508 | m_keyState->create(); | ||
450 | 509 | | |||
510 | m_inputMethod = m_display->createInputMethodInterface(m_display); | ||||
511 | m_inputPanel = m_display->createInputPanelInterface(m_display); | ||||
512 | | ||||
451 | return true; | 513 | return true; | ||
452 | } | 514 | } | ||
453 | 515 | | |||
454 | KWayland::Server::LinuxDmabufUnstableV1Interface *WaylandServer::linuxDmabuf() | 516 | KWayland::Server::LinuxDmabufUnstableV1Interface *WaylandServer::linuxDmabuf() | ||
455 | { | 517 | { | ||
456 | if (!m_linuxDmabuf) { | 518 | if (!m_linuxDmabuf) { | ||
457 | m_linuxDmabuf = m_display->createLinuxDmabufInterface(m_display); | 519 | m_linuxDmabuf = m_display->createLinuxDmabufInterface(m_display); | ||
458 | m_linuxDmabuf->create(); | 520 | m_linuxDmabuf->create(); | ||
459 | } | 521 | } | ||
460 | return m_linuxDmabuf; | 522 | return m_linuxDmabuf; | ||
461 | } | 523 | } | ||
462 | 524 | | |||
463 | SurfaceInterface *WaylandServer::findForeignTransientForSurface(SurfaceInterface *surface) | 525 | SurfaceInterface *WaylandServer::findForeignTransientForSurface(SurfaceInterface *surface) | ||
464 | { | 526 | { | ||
465 | return m_XdgForeign->transientFor(surface); | 527 | return m_XdgForeign->transientFor(surface); | ||
466 | } | 528 | } | ||
467 | 529 | | |||
468 | void WaylandServer::shellClientShown(Toplevel *t) | 530 | void WaylandServer::shellClientShown(Toplevel *t) | ||
469 | { | 531 | { | ||
470 | XdgShellClient *c = dynamic_cast<XdgShellClient *>(t); | 532 | WaylandClient *c = dynamic_cast<WaylandClient *>(t); | ||
471 | if (!c) { | 533 | if (!c) { | ||
472 | qCWarning(KWIN_CORE) << "Failed to cast a Toplevel which is supposed to be a XdgShellClient to XdgShellClient"; | 534 | qCWarning(KWIN_CORE) << "Failed to cast a Toplevel which is supposed to be a WaylandClient to WaylandClient"; | ||
473 | return; | 535 | return; | ||
474 | } | 536 | } | ||
475 | disconnect(c, &XdgShellClient::windowShown, this, &WaylandServer::shellClientShown); | 537 | disconnect(c, &WaylandClient::windowShown, this, &WaylandServer::shellClientShown); | ||
476 | emit shellClientAdded(c); | 538 | emit shellClientAdded(c); | ||
477 | } | 539 | } | ||
478 | 540 | | |||
479 | void WaylandServer::initWorkspace() | 541 | void WaylandServer::initWorkspace() | ||
480 | { | 542 | { | ||
481 | VirtualDesktopManager::self()->setVirtualDesktopManagement(m_virtualDesktopManagement); | 543 | VirtualDesktopManager::self()->setVirtualDesktopManagement(m_virtualDesktopManagement); | ||
482 | 544 | | |||
483 | if (m_windowManagement) { | 545 | if (m_windowManagement) { | ||
▲ Show 20 Lines • Show All 308 Lines • Show Last 20 Lines |
Leave it in createSurface(). You can't use xdg-foreign with non xdg_toplevel equivalent surfaces.