wayland: Simplify plasmashell surface installation code

This commit is contained in:
Vlad Zahorodnii 2021-05-13 09:19:44 +03:00
parent 7475385c82
commit 0e63b4e8cc
2 changed files with 4 additions and 28 deletions

View file

@ -260,14 +260,8 @@ void WaylandServer::registerXdgToplevelClient(XdgToplevelClient *client)
registerShellClient(client); registerShellClient(client);
auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(), if (auto shellSurface = PlasmaShellSurfaceInterface::get(surface)) {
[surface] (PlasmaShellSurfaceInterface *plasmaSurface) { client->installPlasmaShellSurface(shellSurface);
return plasmaSurface->surface() == surface;
}
);
if (it != m_plasmaShellSurfaces.end()) {
client->installPlasmaShellSurface(*it);
m_plasmaShellSurfaces.erase(it);
} }
if (auto decoration = ServerSideDecorationInterface::get(surface)) { if (auto decoration = ServerSideDecorationInterface::get(surface)) {
client->installServerDecoration(decoration); client->installServerDecoration(decoration);
@ -297,19 +291,9 @@ void WaylandServer::registerXdgGenericClient(AbstractClient *client)
XdgPopupClient *popupClient = qobject_cast<XdgPopupClient *>(client); XdgPopupClient *popupClient = qobject_cast<XdgPopupClient *>(client);
if (popupClient) { if (popupClient) {
registerShellClient(popupClient); registerShellClient(popupClient);
if (auto shellSurface = PlasmaShellSurfaceInterface::get(client->surface())) {
SurfaceInterface *surface = client->surface(); popupClient->installPlasmaShellSurface(shellSurface);
auto it = std::find_if(m_plasmaShellSurfaces.begin(), m_plasmaShellSurfaces.end(),
[surface] (PlasmaShellSurfaceInterface *plasmaSurface) {
return plasmaSurface->surface() == surface;
}
);
if (it != m_plasmaShellSurfaces.end()) {
popupClient->installPlasmaShellSurface(*it);
m_plasmaShellSurfaces.erase(it);
} }
return; return;
} }
qCDebug(KWIN_CORE) << "Received invalid xdg client:" << client->surface(); qCDebug(KWIN_CORE) << "Received invalid xdg client:" << client->surface();
@ -457,13 +441,7 @@ bool WaylandServer::init(InitializationFlags flags)
[this] (PlasmaShellSurfaceInterface *surface) { [this] (PlasmaShellSurfaceInterface *surface) {
if (XdgSurfaceClient *client = findXdgSurfaceClient(surface->surface())) { if (XdgSurfaceClient *client = findXdgSurfaceClient(surface->surface())) {
client->installPlasmaShellSurface(surface); client->installPlasmaShellSurface(surface);
return;
} }
m_plasmaShellSurfaces.append(surface);
connect(surface, &QObject::destroyed, this, [this, surface] {
m_plasmaShellSurfaces.removeOne(surface);
});
} }
); );
m_appMenuManager = new AppMenuManagerInterface(m_display, m_display); m_appMenuManager = new AppMenuManagerInterface(m_display, m_display);

View file

@ -46,7 +46,6 @@ class ServerSideDecorationPaletteManagerInterface;
class SurfaceInterface; class SurfaceInterface;
class OutputInterface; class OutputInterface;
class PlasmaShellInterface; class PlasmaShellInterface;
class PlasmaShellSurfaceInterface;
class PlasmaVirtualDesktopManagementInterface; class PlasmaVirtualDesktopManagementInterface;
class PlasmaWindowManagementInterface; class PlasmaWindowManagementInterface;
class OutputManagementInterface; class OutputManagementInterface;
@ -310,7 +309,6 @@ private:
KWaylandServer::KeyStateInterface *m_keyState = nullptr; KWaylandServer::KeyStateInterface *m_keyState = nullptr;
QList<AbstractClient *> m_clients; QList<AbstractClient *> m_clients;
InitializationFlags m_initFlags; InitializationFlags m_initFlags;
QVector<KWaylandServer::PlasmaShellSurfaceInterface*> m_plasmaShellSurfaces;
QHash<AbstractWaylandOutput *, WaylandOutput *> m_waylandOutputs; QHash<AbstractWaylandOutput *, WaylandOutput *> m_waylandOutputs;
QHash<AbstractWaylandOutput *, WaylandOutputDevice *> m_waylandOutputDevices; QHash<AbstractWaylandOutput *, WaylandOutputDevice *> m_waylandOutputDevices;
KWIN_SINGLETON(WaylandServer) KWIN_SINGLETON(WaylandServer)