C++ify wl_registry
This commit is contained in:
parent
c8407e5bde
commit
8c38d31950
|
@ -100,3 +100,6 @@
|
||||||
[submodule "Telegram/ThirdParty/cld3"]
|
[submodule "Telegram/ThirdParty/cld3"]
|
||||||
path = Telegram/ThirdParty/cld3
|
path = Telegram/ThirdParty/cld3
|
||||||
url = https://github.com/google/cld3.git
|
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)
|
if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
|
||||||
qt_generate_wayland_protocol_client_sources(Telegram
|
qt_generate_wayland_protocol_client_sources(Telegram
|
||||||
FILES
|
FILES
|
||||||
|
${third_party_loc}/wayland/protocol/wayland.xml
|
||||||
${third_party_loc}/plasma-wayland-protocols/src/protocols/plasma-shell.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/platform/base_platform_info.h"
|
||||||
#include "base/qt_signal_producer.h"
|
#include "base/qt_signal_producer.h"
|
||||||
#include "base/flat_map.h"
|
#include "base/flat_map.h"
|
||||||
|
|
||||||
|
#include "qwayland-wayland.h"
|
||||||
#include "qwayland-plasma-shell.h"
|
#include "qwayland-plasma-shell.h"
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
#include <qpa/qplatformwindow_p.h>
|
#include <qpa/qplatformwindow_p.h>
|
||||||
#include <wayland-client.h>
|
|
||||||
|
|
||||||
using namespace QNativeInterface;
|
using namespace QNativeInterface;
|
||||||
using namespace QNativeInterface::Private;
|
using namespace QNativeInterface::Private;
|
||||||
|
@ -26,10 +27,9 @@ using namespace base::Platform::Wayland;
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
struct WaylandIntegration::Private {
|
struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> {
|
||||||
QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window);
|
QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window);
|
||||||
|
|
||||||
std::unique_ptr<wl_registry, RegistryDeleter> registry;
|
|
||||||
AutoDestroyer<QtWayland::org_kde_plasma_shell> plasmaShell;
|
AutoDestroyer<QtWayland::org_kde_plasma_shell> plasmaShell;
|
||||||
uint32_t plasmaShellName = 0;
|
uint32_t plasmaShellName = 0;
|
||||||
base::flat_map<
|
base::flat_map<
|
||||||
|
@ -38,30 +38,23 @@ struct WaylandIntegration::Private {
|
||||||
> plasmaSurfaces;
|
> plasmaSurfaces;
|
||||||
rpl::lifetime lifetime;
|
rpl::lifetime lifetime;
|
||||||
|
|
||||||
static const wl_registry_listener RegistryListener;
|
protected:
|
||||||
};
|
void registry_global(
|
||||||
|
|
||||||
const wl_registry_listener WaylandIntegration::Private::RegistryListener = {
|
|
||||||
decltype(wl_registry_listener::global)(+[](
|
|
||||||
Private *data,
|
|
||||||
wl_registry *registry,
|
|
||||||
uint32_t name,
|
uint32_t name,
|
||||||
const char *interface,
|
const QString &interface,
|
||||||
uint32_t version) {
|
uint32_t version) override {
|
||||||
if (interface == qstr("org_kde_plasma_shell")) {
|
if (interface == qstr("org_kde_plasma_shell")) {
|
||||||
data->plasmaShell.init(registry, name, version);
|
plasmaShell.init(object(), name, version);
|
||||||
data->plasmaShellName = name;
|
plasmaShellName = name;
|
||||||
}
|
}
|
||||||
}),
|
}
|
||||||
decltype(wl_registry_listener::global_remove)(+[](
|
|
||||||
Private *data,
|
void registry_global_remove(uint32_t name) override {
|
||||||
wl_registry *registry,
|
if (name == plasmaShellName) {
|
||||||
uint32_t name) {
|
plasmaShell = {};
|
||||||
if (name == data->plasmaShellName) {
|
plasmaShellName = 0;
|
||||||
data->plasmaShell = {};
|
|
||||||
data->plasmaShellName = 0;
|
|
||||||
}
|
}
|
||||||
}),
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface(
|
QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface(
|
||||||
|
@ -117,12 +110,7 @@ WaylandIntegration::WaylandIntegration()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_private->registry.reset(wl_display_get_registry(display));
|
_private->init(wl_display_get_registry(display));
|
||||||
wl_registry_add_listener(
|
|
||||||
_private->registry.get(),
|
|
||||||
&Private::RegistryListener,
|
|
||||||
_private.get());
|
|
||||||
|
|
||||||
wl_display_roundtrip(display);
|
wl_display_roundtrip(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit b2649cb3ee6bd70828a17e50beb16591e6066288
|
Loading…
Reference in New Issue