mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
C++ify wl_registry
This commit is contained in:
parent
c8407e5bde
commit
8c38d31950
4 changed files with 22 additions and 29 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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 <QtGui/QGuiApplication>
|
||||
#include <QtGui/QWindow>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <qpa/qplatformwindow_p.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
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::wl_registry> {
|
||||
QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window);
|
||||
|
||||
std::unique_ptr<wl_registry, RegistryDeleter> registry;
|
||||
AutoDestroyer<QtWayland::org_kde_plasma_shell> 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);
|
||||
}
|
||||
|
||||
|
|
1
Telegram/ThirdParty/wayland
vendored
Submodule
1
Telegram/ThirdParty/wayland
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit b2649cb3ee6bd70828a17e50beb16591e6066288
|
Loading…
Add table
Reference in a new issue