C++ify wl_registry
This commit is contained in:
parent
ff1d5fce29
commit
627abc6728
2 changed files with 18 additions and 29 deletions
|
|
@ -301,6 +301,7 @@ elseif(LINUX)
|
|||
|
||||
qt_generate_wayland_protocol_client_sources(lib_ui
|
||||
FILES
|
||||
${third_party_loc}/wayland/protocol/wayland.xml
|
||||
${third_party_loc}/wayland-protocols/stable/xdg-shell/xdg-shell.xml
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/linux/base_linux_wayland_utilities.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/qt_signal_producer.h"
|
||||
|
||||
#include "qwayland-wayland.h"
|
||||
#include "qwayland-xdg-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;
|
||||
|
|
@ -25,36 +26,28 @@ using namespace base::Platform::Wayland;
|
|||
namespace Ui {
|
||||
namespace Platform {
|
||||
|
||||
struct WaylandIntegration::Private {
|
||||
std::unique_ptr<wl_registry, RegistryDeleter> registry;
|
||||
struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> {
|
||||
bool xdgDecorationSupported = false;
|
||||
uint32_t xdgDecorationName = 0;
|
||||
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("zxdg_decoration_manager_v1")) {
|
||||
data->xdgDecorationSupported = true;
|
||||
data->xdgDecorationName = name;
|
||||
xdgDecorationSupported = true;
|
||||
xdgDecorationName = name;
|
||||
}
|
||||
}
|
||||
|
||||
void registry_global_remove(uint32_t name) override {
|
||||
if (name == xdgDecorationName) {
|
||||
xdgDecorationSupported = false;
|
||||
xdgDecorationName = 0;
|
||||
}
|
||||
}),
|
||||
decltype(wl_registry_listener::global_remove)(+[](
|
||||
Private *data,
|
||||
wl_registry *registry,
|
||||
uint32_t name) {
|
||||
if (name == data->xdgDecorationName) {
|
||||
data->xdgDecorationSupported = false;
|
||||
data->xdgDecorationName = 0;
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
WaylandIntegration::WaylandIntegration()
|
||||
|
|
@ -69,12 +62,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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue