From 8c38d319507f4c313970abaeea802e0c7e949214 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 30 May 2023 04:37:05 +0400 Subject: [PATCH] C++ify wl_registry --- .gitmodules | 3 ++ Telegram/CMakeLists.txt | 1 + .../linux/linux_wayland_integration.cpp | 46 +++++++------------ Telegram/ThirdParty/wayland | 1 + 4 files changed, 22 insertions(+), 29 deletions(-) create mode 160000 Telegram/ThirdParty/wayland diff --git a/.gitmodules b/.gitmodules index 052fbbe91..2de5f5b1f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -100,3 +100,6 @@ [submodule "Telegram/ThirdParty/cld3"] path = Telegram/ThirdParty/cld3 url = https://github.com/google/cld3.git +[submodule "Telegram/ThirdParty/wayland"] + path = Telegram/ThirdParty/wayland + url = https://github.com/gitlab-freedesktop-mirrors/wayland.git diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index b84d103d2..d61a678dd 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1529,6 +1529,7 @@ else() if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) qt_generate_wayland_protocol_client_sources(Telegram FILES + ${third_party_loc}/wayland/protocol/wayland.xml ${third_party_loc}/plasma-wayland-protocols/src/protocols/plasma-shell.xml ) diff --git a/Telegram/SourceFiles/platform/linux/linux_wayland_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_wayland_integration.cpp index c6193869f..050b27528 100644 --- a/Telegram/SourceFiles/platform/linux/linux_wayland_integration.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_wayland_integration.cpp @@ -11,13 +11,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_info.h" #include "base/qt_signal_producer.h" #include "base/flat_map.h" + +#include "qwayland-wayland.h" #include "qwayland-plasma-shell.h" #include #include #include #include -#include using namespace QNativeInterface; using namespace QNativeInterface::Private; @@ -26,10 +27,9 @@ using namespace base::Platform::Wayland; namespace Platform { namespace internal { -struct WaylandIntegration::Private { +struct WaylandIntegration::Private : public AutoDestroyer { QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window); - std::unique_ptr registry; AutoDestroyer plasmaShell; uint32_t plasmaShellName = 0; base::flat_map< @@ -38,30 +38,23 @@ struct WaylandIntegration::Private { > plasmaSurfaces; rpl::lifetime lifetime; - static const wl_registry_listener RegistryListener; -}; - -const wl_registry_listener WaylandIntegration::Private::RegistryListener = { - decltype(wl_registry_listener::global)(+[]( - Private *data, - wl_registry *registry, +protected: + void registry_global( uint32_t name, - const char *interface, - uint32_t version) { + const QString &interface, + uint32_t version) override { if (interface == qstr("org_kde_plasma_shell")) { - data->plasmaShell.init(registry, name, version); - data->plasmaShellName = name; + plasmaShell.init(object(), name, version); + plasmaShellName = name; } - }), - decltype(wl_registry_listener::global_remove)(+[]( - Private *data, - wl_registry *registry, - uint32_t name) { - if (name == data->plasmaShellName) { - data->plasmaShell = {}; - data->plasmaShellName = 0; + } + + void registry_global_remove(uint32_t name) override { + if (name == plasmaShellName) { + plasmaShell = {}; + plasmaShellName = 0; } - }), + } }; QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface( @@ -117,12 +110,7 @@ WaylandIntegration::WaylandIntegration() return; } - _private->registry.reset(wl_display_get_registry(display)); - wl_registry_add_listener( - _private->registry.get(), - &Private::RegistryListener, - _private.get()); - + _private->init(wl_display_get_registry(display)); wl_display_roundtrip(display); } diff --git a/Telegram/ThirdParty/wayland b/Telegram/ThirdParty/wayland new file mode 160000 index 000000000..b2649cb3e --- /dev/null +++ b/Telegram/ThirdParty/wayland @@ -0,0 +1 @@ +Subproject commit b2649cb3ee6bd70828a17e50beb16591e6066288