Replace custom waitForInterfaceAnnounce with wl_display_roundtrip
This commit is contained in:
parent
3752e158e4
commit
3f28dfa821
4 changed files with 4 additions and 46 deletions
|
|
@ -30,25 +30,15 @@ struct WlRegistryDeleter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WlCallbackDeleter {
|
|
||||||
void operator()(wl_callback *value) {
|
|
||||||
wl_callback_destroy(value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct WaylandIntegration::Private {
|
struct WaylandIntegration::Private {
|
||||||
std::unique_ptr<wl_registry, WlRegistryDeleter> registry;
|
std::unique_ptr<wl_registry, WlRegistryDeleter> registry;
|
||||||
std::unique_ptr<wl_callback, WlCallbackDeleter> callback;
|
|
||||||
QEventLoop interfacesLoop;
|
|
||||||
bool interfacesAnnounced = false;
|
|
||||||
bool xdgDecorationSupported = false;
|
bool xdgDecorationSupported = false;
|
||||||
uint32_t xdgDecorationName = 0;
|
uint32_t xdgDecorationName = 0;
|
||||||
rpl::lifetime lifetime;
|
rpl::lifetime lifetime;
|
||||||
|
|
||||||
static const struct wl_registry_listener RegistryListener;
|
static const struct wl_registry_listener RegistryListener;
|
||||||
static const struct wl_callback_listener CallbackListener;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct wl_registry_listener WaylandIntegration::Private::RegistryListener = {
|
const struct wl_registry_listener WaylandIntegration::Private::RegistryListener = {
|
||||||
|
|
@ -72,19 +62,6 @@ const struct wl_registry_listener WaylandIntegration::Private::RegistryListener
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct wl_callback_listener WaylandIntegration::Private::CallbackListener = {
|
|
||||||
decltype(wl_callback_listener::done)(+[](
|
|
||||||
Private *data,
|
|
||||||
wl_callback *callback,
|
|
||||||
uint32_t serial) {
|
|
||||||
data->interfacesAnnounced = true;
|
|
||||||
if (data->interfacesLoop.isRunning()) {
|
|
||||||
data->interfacesLoop.quit();
|
|
||||||
}
|
|
||||||
data->callback = nullptr;
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
WaylandIntegration::WaylandIntegration()
|
WaylandIntegration::WaylandIntegration()
|
||||||
: _private(std::make_unique<Private>()) {
|
: _private(std::make_unique<Private>()) {
|
||||||
const auto native = QGuiApplication::platformNativeInterface();
|
const auto native = QGuiApplication::platformNativeInterface();
|
||||||
|
|
@ -100,26 +77,20 @@ WaylandIntegration::WaylandIntegration()
|
||||||
}
|
}
|
||||||
|
|
||||||
_private->registry.reset(wl_display_get_registry(display));
|
_private->registry.reset(wl_display_get_registry(display));
|
||||||
_private->callback.reset(wl_display_sync(display));
|
|
||||||
|
|
||||||
wl_registry_add_listener(
|
wl_registry_add_listener(
|
||||||
_private->registry.get(),
|
_private->registry.get(),
|
||||||
&Private::RegistryListener,
|
&Private::RegistryListener,
|
||||||
_private.get());
|
_private.get());
|
||||||
|
|
||||||
wl_callback_add_listener(
|
|
||||||
_private->callback.get(),
|
|
||||||
&Private::CallbackListener,
|
|
||||||
_private.get());
|
|
||||||
|
|
||||||
base::qt_signal_producer(
|
base::qt_signal_producer(
|
||||||
native,
|
native,
|
||||||
&QObject::destroyed
|
&QObject::destroyed
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
// too late for standard destructors, just free
|
// too late for standard destructors, just free
|
||||||
free(_private->callback.release());
|
|
||||||
free(_private->registry.release());
|
free(_private->registry.release());
|
||||||
}, _private->lifetime);
|
}, _private->lifetime);
|
||||||
|
|
||||||
|
wl_display_roundtrip(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaylandIntegration::~WaylandIntegration() = default;
|
WaylandIntegration::~WaylandIntegration() = default;
|
||||||
|
|
@ -130,13 +101,6 @@ WaylandIntegration *WaylandIntegration::Instance() {
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandIntegration::waitForInterfaceAnnounce() {
|
|
||||||
Expects(!_private->interfacesLoop.isRunning());
|
|
||||||
if (!_private->interfacesAnnounced) {
|
|
||||||
_private->interfacesLoop.exec();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaylandIntegration::xdgDecorationSupported() {
|
bool WaylandIntegration::xdgDecorationSupported() {
|
||||||
return _private->xdgDecorationSupported;
|
return _private->xdgDecorationSupported;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ class WaylandIntegration {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static WaylandIntegration *Instance();
|
[[nodiscard]] static WaylandIntegration *Instance();
|
||||||
|
|
||||||
void waitForInterfaceAnnounce();
|
|
||||||
[[nodiscard]] bool xdgDecorationSupported();
|
[[nodiscard]] bool xdgDecorationSupported();
|
||||||
[[nodiscard]] bool windowExtentsSupported();
|
[[nodiscard]] bool windowExtentsSupported();
|
||||||
void setWindowExtents(not_null<QWidget*> widget, const QMargins &extents);
|
void setWindowExtents(not_null<QWidget*> widget, const QMargins &extents);
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,6 @@ WaylandIntegration *WaylandIntegration::Instance() {
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandIntegration::waitForInterfaceAnnounce() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaylandIntegration::xdgDecorationSupported() {
|
bool WaylandIntegration::xdgDecorationSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,8 @@ std::unique_ptr<BasicWindowHelper> CreateSpecialWindowHelper(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowFrameSupported() {
|
bool NativeWindowFrameSupported() {
|
||||||
const auto waylandIntegration = WaylandIntegration::Instance();
|
if (const auto integration = WaylandIntegration::Instance()) {
|
||||||
if (waylandIntegration) {
|
return integration->xdgDecorationSupported();
|
||||||
waylandIntegration->waitForInterfaceAnnounce();
|
|
||||||
return waylandIntegration->xdgDecorationSupported();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue