Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.cpp
Show All 16 Lines | |||||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "wayland_server.h" | 20 | #include "wayland_server.h" | ||
21 | #include "client.h" | 21 | #include "client.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 "internal_client.h" | | |||
26 | #include "screens.h" | 25 | #include "screens.h" | ||
27 | #include "shell_client.h" | 26 | #include "shell_client.h" | ||
28 | #include "workspace.h" | 27 | #include "workspace.h" | ||
29 | 28 | | |||
30 | // Client | 29 | // Client | ||
31 | #include <KWayland/Client/connection_thread.h> | 30 | #include <KWayland/Client/connection_thread.h> | ||
32 | #include <KWayland/Client/event_queue.h> | 31 | #include <KWayland/Client/event_queue.h> | ||
33 | #include <KWayland/Client/registry.h> | 32 | #include <KWayland/Client/registry.h> | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 149 | { | |||
154 | } | 153 | } | ||
155 | if (surface->client() == m_xwayland.client) { | 154 | if (surface->client() == m_xwayland.client) { | ||
156 | // skip Xwayland clients, those are created using standard X11 way | 155 | // skip Xwayland clients, those are created using standard X11 way | ||
157 | return; | 156 | return; | ||
158 | } | 157 | } | ||
159 | if (surface->client() == m_screenLockerClientConnection) { | 158 | if (surface->client() == m_screenLockerClientConnection) { | ||
160 | ScreenLocker::KSldApp::self()->lockScreenShown(); | 159 | ScreenLocker::KSldApp::self()->lockScreenShown(); | ||
161 | } | 160 | } | ||
162 | ShellClient *client; | 161 | ShellClient *client = new ShellClient(surface); | ||
163 | if (surface->client() == waylandServer()->internalConnection()) { | | |||
164 | client = new InternalClient(surface); | | |||
165 | } else { | | |||
166 | client = new ShellClient(surface); | | |||
167 | } | | |||
168 | if (ServerSideDecorationInterface *deco = ServerSideDecorationInterface::get(surface->surface())) { | 162 | if (ServerSideDecorationInterface *deco = ServerSideDecorationInterface::get(surface->surface())) { | ||
169 | client->installServerSideDecoration(deco); | 163 | client->installServerSideDecoration(deco); | ||
170 | } | 164 | } | ||
171 | auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(), | 165 | auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(), | ||
172 | [client] (PlasmaShellSurfaceInterface *surface) { | 166 | [client] (PlasmaShellSurfaceInterface *surface) { | ||
173 | return client->surface() == surface->surface(); | 167 | return client->surface() == surface->surface(); | ||
174 | } | 168 | } | ||
175 | ); | 169 | ); | ||
176 | if (it != m_plasmaShellSurfaces.end()) { | 170 | if (it != m_plasmaShellSurfaces.end()) { | ||
177 | client->installPlasmaShellSurface(*it); | 171 | client->installPlasmaShellSurface(*it); | ||
178 | m_plasmaShellSurfaces.erase(it); | 172 | m_plasmaShellSurfaces.erase(it); | ||
179 | } | 173 | } | ||
180 | if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) { | 174 | if (auto menu = m_appMenuManager->appMenuForSurface(surface->surface())) { | ||
181 | client->installAppMenu(menu); | 175 | client->installAppMenu(menu); | ||
182 | } | 176 | } | ||
183 | if (auto palette = m_paletteManager->paletteForSurface(surface->surface())) { | 177 | if (auto palette = m_paletteManager->paletteForSurface(surface->surface())) { | ||
184 | client->installPalette(palette); | 178 | client->installPalette(palette); | ||
185 | } | 179 | } | ||
186 | if (client->isInternal()) { | | |||
187 | m_internalClients << client; | | |||
188 | } else { | | |||
189 | m_clients << client; | 180 | m_clients << client; | ||
190 | } | | |||
191 | if (client->readyForPainting()) { | 181 | if (client->readyForPainting()) { | ||
192 | emit shellClientAdded(client); | 182 | emit shellClientAdded(client); | ||
193 | } else { | 183 | } else { | ||
194 | connect(client, &ShellClient::windowShown, this, &WaylandServer::shellClientShown); | 184 | connect(client, &ShellClient::windowShown, this, &WaylandServer::shellClientShown); | ||
195 | } | 185 | } | ||
196 | 186 | | |||
197 | //not directly connected as the connection is tied to client instead of this | 187 | //not directly connected as the connection is tied to client instead of this | ||
198 | connect(m_XdgForeign, &KWayland::Server::XdgForeignInterface::transientChanged, client, [this](KWayland::Server::SurfaceInterface *child) { | 188 | connect(m_XdgForeign, &KWayland::Server::XdgForeignInterface::transientChanged, client, [this](KWayland::Server::SurfaceInterface *child) { | ||
▲ Show 20 Lines • Show All 446 Lines • ▼ Show 20 Line(s) | 603 | connect(m_internalConnection.client, &ConnectionThread::connected, this, | |||
645 | } | 635 | } | ||
646 | ); | 636 | ); | ||
647 | m_internalConnection.client->initConnection(); | 637 | m_internalConnection.client->initConnection(); | ||
648 | } | 638 | } | ||
649 | 639 | | |||
650 | void WaylandServer::removeClient(ShellClient *c) | 640 | void WaylandServer::removeClient(ShellClient *c) | ||
651 | { | 641 | { | ||
652 | m_clients.removeAll(c); | 642 | m_clients.removeAll(c); | ||
653 | m_internalClients.removeAll(c); | | |||
654 | emit shellClientRemoved(c); | 643 | emit shellClientRemoved(c); | ||
655 | } | 644 | } | ||
656 | 645 | | |||
657 | void WaylandServer::dispatch() | 646 | void WaylandServer::dispatch() | ||
658 | { | 647 | { | ||
659 | if (!m_display) { | 648 | if (!m_display) { | ||
660 | return; | 649 | return; | ||
661 | } | 650 | } | ||
Show All 32 Lines | |||||
694 | ShellClient *WaylandServer::findClient(quint32 id) const | 683 | ShellClient *WaylandServer::findClient(quint32 id) const | ||
695 | { | 684 | { | ||
696 | if (id == 0) { | 685 | if (id == 0) { | ||
697 | return nullptr; | 686 | return nullptr; | ||
698 | } | 687 | } | ||
699 | if (ShellClient *c = findClientInList(m_clients, id)) { | 688 | if (ShellClient *c = findClientInList(m_clients, id)) { | ||
700 | return c; | 689 | return c; | ||
701 | } | 690 | } | ||
702 | if (ShellClient *c = findClientInList(m_internalClients, id)) { | | |||
703 | return c; | | |||
704 | } | | |||
705 | return nullptr; | 691 | return nullptr; | ||
706 | } | 692 | } | ||
707 | 693 | | |||
708 | ShellClient *WaylandServer::findClient(SurfaceInterface *surface) const | 694 | ShellClient *WaylandServer::findClient(SurfaceInterface *surface) const | ||
709 | { | 695 | { | ||
710 | if (!surface) { | 696 | if (!surface) { | ||
711 | return nullptr; | 697 | return nullptr; | ||
712 | } | 698 | } | ||
713 | if (ShellClient *c = findClientInList(m_clients, surface)) { | 699 | if (ShellClient *c = findClientInList(m_clients, surface)) { | ||
714 | return c; | 700 | return c; | ||
715 | } | 701 | } | ||
716 | if (ShellClient *c = findClientInList(m_internalClients, surface)) { | | |||
717 | return c; | | |||
718 | } | | |||
719 | return nullptr; | 702 | return nullptr; | ||
720 | } | 703 | } | ||
721 | 704 | | |||
722 | AbstractClient *WaylandServer::findAbstractClient(SurfaceInterface *surface) const | 705 | AbstractClient *WaylandServer::findAbstractClient(SurfaceInterface *surface) const | ||
723 | { | 706 | { | ||
724 | return findClient(surface); | 707 | return findClient(surface); | ||
725 | } | 708 | } | ||
726 | 709 | | |||
727 | ShellClient *WaylandServer::findClient(QWindow *w) const | | |||
728 | { | | |||
729 | if (!w) { | | |||
730 | return nullptr; | | |||
731 | } | | |||
732 | auto it = std::find_if(m_internalClients.constBegin(), m_internalClients.constEnd(), | | |||
733 | [w] (const ShellClient *c) { | | |||
734 | return c->internalWindow() == w; | | |||
735 | } | | |||
736 | ); | | |||
737 | if (it != m_internalClients.constEnd()) { | | |||
738 | return *it; | | |||
739 | } | | |||
740 | return nullptr; | | |||
741 | } | | |||
742 | | ||||
743 | quint32 WaylandServer::createWindowId(SurfaceInterface *surface) | 710 | quint32 WaylandServer::createWindowId(SurfaceInterface *surface) | ||
744 | { | 711 | { | ||
745 | auto it = m_clientIds.constFind(surface->client()); | 712 | auto it = m_clientIds.constFind(surface->client()); | ||
746 | quint16 clientId = 0; | 713 | quint16 clientId = 0; | ||
747 | if (it != m_clientIds.constEnd()) { | 714 | if (it != m_clientIds.constEnd()) { | ||
748 | clientId = it.value(); | 715 | clientId = it.value(); | ||
749 | } else { | 716 | } else { | ||
750 | clientId = createClientId(surface->client()); | 717 | clientId = createClientId(surface->client()); | ||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |