kwin/src/wayland/xwaylandshell_v1_interface.h
Vlad Zahorodnii fdea693da5 wayland: Implement xwayland-shell-v1
As explained in [1], WL_SURFACE_ID is racy because wayland aggressively
reuses object ids. The xwayland-shell-v1 protocol intends to fix that by
two things:

* associating a serial number with each X11 window. This is to avoid
  potential XID reuse
* referring to the wayland surface by the wl_surface rather than
  specifying an object id

Unfortunately, we will have to maintain both legacy WL_SURFACE_ID and
WL_SURFACE_SERIAL for quiet some time until most instances of Xwayland
support the xwayland-shell-v1 protocol [2].

[1] https://gitlab.freedesktop.org/xorg/xserver/-/issues/1157
[2] https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/163
2022-12-05 17:09:01 +02:00

59 lines
1.3 KiB
C++

/*
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <kwin_export.h>
#include <QObject>
#include <memory>
#include <optional>
struct wl_client;
namespace KWaylandServer
{
class Display;
class SurfaceInterface;
class XwaylandShellV1Interface;
class XwaylandShellV1InterfacePrivate;
class XwaylandSurfaceV1InterfacePrivate;
class KWIN_EXPORT XwaylandSurfaceV1Interface : public QObject
{
Q_OBJECT
public:
XwaylandSurfaceV1Interface(XwaylandShellV1Interface *shell, SurfaceInterface *surface, wl_client *client, uint32_t id, int version);
~XwaylandSurfaceV1Interface() override;
SurfaceInterface *surface() const;
std::optional<uint64_t> serial() const;
private:
std::unique_ptr<XwaylandSurfaceV1InterfacePrivate> d;
};
class KWIN_EXPORT XwaylandShellV1Interface : public QObject
{
Q_OBJECT
public:
explicit XwaylandShellV1Interface(Display *display, QObject *parent = nullptr);
~XwaylandShellV1Interface() override;
XwaylandSurfaceV1Interface *findSurface(uint64_t serial) const;
Q_SIGNALS:
void surfaceAssociated(XwaylandSurfaceV1Interface *surface);
private:
std::unique_ptr<XwaylandShellV1InterfacePrivate> d;
};
} // namespace KWaylandServer