Commit d91da41c authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

wayland: Fix binding of xwayland surfaces to windows

Surface ids are not unique across clients. If the underlying surface of
an XdgToplevelClient is replaced with an Xwayland's surface, you may see
weird results such as a desktop window having the contents of an X11
window or even worse a crash.

BUG: 428680
parent 59262615
......@@ -19,6 +19,7 @@
#include "workspace.h"
#include "xdgshellclient.h"
#include "service_utils.h"
#include "unmanaged.h"
// Client
#include <KWayland/Client/connection_thread.h>
......@@ -348,12 +349,24 @@ bool WaylandServer::init(const QByteArray &socketName, InitializationFlags flags
// setting surface is only relevat for Xwayland clients
auto check = [surface] (const Toplevel *t) {
return t->surfaceId() == surface->id();
if (Toplevel *t = ws->findToplevel(check)) {
X11Client *client = ws->findClient([surface](const X11Client *client) {
return client->surfaceId() == surface->id();
if (client) {
Unmanaged *unmanaged = ws->findUnmanaged([surface](const Unmanaged *unmanaged) {
return unmanaged->surfaceId() == surface->id();
if (unmanaged) {
// The surface will be bound later when a WL_SURFACE_ID message is received.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment