Store xdg-decoration support with std::optional

This commit is contained in:
Ilya Fedin 2023-05-30 18:57:43 +04:00 committed by John Preston
parent 627abc6728
commit cf906f14bd

View file

@ -27,8 +27,7 @@ namespace Ui {
namespace Platform { namespace Platform {
struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> { struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> {
bool xdgDecorationSupported = false; std::optional<uint32_t> xdgDecoration;
uint32_t xdgDecorationName = 0;
rpl::lifetime lifetime; rpl::lifetime lifetime;
protected: protected:
@ -37,15 +36,13 @@ protected:
const QString &interface, const QString &interface,
uint32_t version) override { uint32_t version) override {
if (interface == qstr("zxdg_decoration_manager_v1")) { if (interface == qstr("zxdg_decoration_manager_v1")) {
xdgDecorationSupported = true; xdgDecoration = name;
xdgDecorationName = name;
} }
} }
void registry_global_remove(uint32_t name) override { void registry_global_remove(uint32_t name) override {
if (name == xdgDecorationName) { if (xdgDecoration && name == *xdgDecoration) {
xdgDecorationSupported = false; xdgDecoration = std::nullopt;
xdgDecorationName = 0;
} }
} }
}; };
@ -82,7 +79,7 @@ WaylandIntegration *WaylandIntegration::Instance() {
} }
bool WaylandIntegration::xdgDecorationSupported() { bool WaylandIntegration::xdgDecorationSupported() {
return _private->xdgDecorationSupported; return _private->xdgDecoration.has_value();
} }
bool WaylandIntegration::windowExtentsSupported() { bool WaylandIntegration::windowExtentsSupported() {