diff --git a/CMakeLists.txt b/CMakeLists.txt index cfa92dfc2d..2a0f94010a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,6 +207,11 @@ if (Wayland_VERSION VERSION_GREATER_EQUAL 1.23) else() set(HAVE_WL_DISPLAY_SET_DEFAULT_MAX_BUFFER_SIZE 0) endif() +if (Wayland_VERSION VERSION_GREATER_EQUAL 1.23.90) + set(HAVE_WL_FIXES 1) +else() + set(HAVE_WL_FIXES 0) +endif() find_package(WaylandProtocols 1.38) set_package_properties(WaylandProtocols PROPERTIES diff --git a/src/config-kwin.h.cmake b/src/config-kwin.h.cmake index c3f72fc2b0..8b68b6c1b8 100644 --- a/src/config-kwin.h.cmake +++ b/src/config-kwin.h.cmake @@ -31,5 +31,6 @@ constexpr QLatin1String BREEZE_KDECORATION_PLUGIN_ID("${BREEZE_KDECORATION_PLUGI #cmakedefine01 HAVE_GLX #cmakedefine01 HAVE_DL_LIBRARY #cmakedefine01 HAVE_WL_DISPLAY_SET_DEFAULT_MAX_BUFFER_SIZE +#cmakedefine01 HAVE_WL_FIXES constexpr QLatin1String XWAYLAND_SESSION_SCRIPTS("${XWAYLAND_SESSION_SCRIPTS}"); diff --git a/src/wayland/CMakeLists.txt b/src/wayland/CMakeLists.txt index 8ec625d40b..e82ae898a8 100644 --- a/src/wayland/CMakeLists.txt +++ b/src/wayland/CMakeLists.txt @@ -339,6 +339,7 @@ target_sources(kwin PRIVATE drmlease_v1.cpp externalbrightness_v1.cpp filtered_display.cpp + fixes.cpp fractionalscale_v1.cpp frog_colormanagement_v1.cpp idle.cpp diff --git a/src/wayland/fixes.cpp b/src/wayland/fixes.cpp new file mode 100644 index 0000000000..162054fbbd --- /dev/null +++ b/src/wayland/fixes.cpp @@ -0,0 +1,56 @@ +/* + SPDX-FileCopyrightText: 2024 Joaquim Monteiro + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "fixes.h" + +#include "config-kwin.h" +#if HAVE_WL_FIXES + +#include "display.h" +#include "qwayland-server-wayland.h" + +namespace KWin +{ +static constexpr int s_version = 1; + +class FixesInterfacePrivate : public QtWaylandServer::wl_fixes +{ +public: + FixesInterfacePrivate(Display *display); + +protected: + void fixes_destroy(Resource *resource) override; + void fixes_destroy_registry(Resource *resource, struct ::wl_resource *registry) override; +}; + +FixesInterfacePrivate::FixesInterfacePrivate(Display *display) + : QtWaylandServer::wl_fixes(*display, s_version) +{ +} + +void FixesInterfacePrivate::fixes_destroy(Resource *resource) +{ + wl_resource_destroy(resource->handle); +} + +void FixesInterfacePrivate::fixes_destroy_registry(Resource *resource, struct ::wl_resource *registry) +{ + wl_resource_destroy(registry); +} + +FixesInterface::FixesInterface(Display *display, QObject *parent) + : QObject(parent) + , d{std::make_unique(display)} +{ +} + +FixesInterface::~FixesInterface() +{ +} + +} // namespace KWin + +#endif // HAVE_WL_FIXES diff --git a/src/wayland/fixes.h b/src/wayland/fixes.h new file mode 100644 index 0000000000..0c6d513689 --- /dev/null +++ b/src/wayland/fixes.h @@ -0,0 +1,36 @@ +/* + SPDX-FileCopyrightText: 2024 Joaquim Monteiro + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include "config-kwin.h" +#if HAVE_WL_FIXES + +#include "kwin_export.h" + +#include + +namespace KWin +{ + +class Display; +class FixesInterfacePrivate; + +class KWIN_EXPORT FixesInterface : public QObject +{ + Q_OBJECT + +public: + explicit FixesInterface(Display *display, QObject *parent = nullptr); + ~FixesInterface() override; + +private: + std::unique_ptr d; +}; + +} // namespace KWin + +#endif // HAVE_WL_FIXES diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index 9f07051cea..920f48a957 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -38,6 +38,7 @@ #include "wayland/drmlease_v1.h" #include "wayland/externalbrightness_v1.h" #include "wayland/filtered_display.h" +#include "wayland/fixes.h" #include "wayland/fractionalscale_v1.h" #include "wayland/frog_colormanagement_v1.h" #include "wayland/idle.h" @@ -506,6 +507,9 @@ bool WaylandServer::init() m_externalBrightness = new ExternalBrightnessV1(m_display, m_display); m_alphaModifierManager = new AlphaModifierManagerV1(m_display, m_display); +#if HAVE_WL_FIXES + new FixesInterface(m_display, m_display); +#endif return true; }