Store managed objects inside managers
This commit is contained in:
parent
8c38d31950
commit
71570f5be1
|
@ -26,16 +26,22 @@ using namespace base::Platform::Wayland;
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class PlasmaShell : public Global<QtWayland::org_kde_plasma_shell> {
|
||||||
|
public:
|
||||||
|
using Global::Global;
|
||||||
|
|
||||||
|
using Surface = AutoDestroyer<QtWayland::org_kde_plasma_surface>;
|
||||||
|
base::flat_map<wl_surface*, Surface> surfaces;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> {
|
struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> {
|
||||||
QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window);
|
QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window);
|
||||||
|
|
||||||
AutoDestroyer<QtWayland::org_kde_plasma_shell> plasmaShell;
|
std::optional<PlasmaShell> plasmaShell;
|
||||||
uint32_t plasmaShellName = 0;
|
|
||||||
base::flat_map<
|
|
||||||
wl_surface*,
|
|
||||||
AutoDestroyer<QtWayland::org_kde_plasma_surface>
|
|
||||||
> plasmaSurfaces;
|
|
||||||
rpl::lifetime lifetime;
|
rpl::lifetime lifetime;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -44,22 +50,20 @@ protected:
|
||||||
const QString &interface,
|
const QString &interface,
|
||||||
uint32_t version) override {
|
uint32_t version) override {
|
||||||
if (interface == qstr("org_kde_plasma_shell")) {
|
if (interface == qstr("org_kde_plasma_shell")) {
|
||||||
plasmaShell.init(object(), name, version);
|
plasmaShell.emplace(object(), name, version);
|
||||||
plasmaShellName = name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void registry_global_remove(uint32_t name) override {
|
void registry_global_remove(uint32_t name) override {
|
||||||
if (name == plasmaShellName) {
|
if (plasmaShell && name == plasmaShell->id()) {
|
||||||
plasmaShell = {};
|
plasmaShell = std::nullopt;
|
||||||
plasmaShellName = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface(
|
QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface(
|
||||||
QWindow *window) {
|
QWindow *window) {
|
||||||
if (!plasmaShell.isInitialized()) {
|
if (!plasmaShell) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,25 +77,25 @@ QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto it = plasmaSurfaces.find(surface);
|
const auto it = plasmaShell->surfaces.find(surface);
|
||||||
if (it != plasmaSurfaces.cend()) {
|
if (it != plasmaShell->surfaces.cend()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto plasmaSurface = plasmaShell.get_surface(surface);
|
const auto plasmaSurface = plasmaShell->get_surface(surface);
|
||||||
if (!plasmaSurface) {
|
if (!plasmaSurface) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = plasmaSurfaces.emplace(surface, plasmaSurface);
|
const auto result = plasmaShell->surfaces.emplace(surface, plasmaSurface);
|
||||||
|
|
||||||
base::qt_signal_producer(
|
base::qt_signal_producer(
|
||||||
native,
|
native,
|
||||||
&QWaylandWindow::surfaceDestroyed
|
&QWaylandWindow::surfaceDestroyed
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
auto it = plasmaSurfaces.find(surface);
|
auto it = plasmaShell->surfaces.find(surface);
|
||||||
if (it != plasmaSurfaces.cend()) {
|
if (it != plasmaShell->surfaces.cend()) {
|
||||||
plasmaSurfaces.erase(it);
|
plasmaShell->surfaces.erase(it);
|
||||||
}
|
}
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
|
|
||||||
|
@ -130,7 +134,7 @@ WaylandIntegration *WaylandIntegration::Instance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandIntegration::skipTaskbarSupported() {
|
bool WaylandIntegration::skipTaskbarSupported() {
|
||||||
return _private->plasmaShell.isInitialized();
|
return _private->plasmaShell.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandIntegration::skipTaskbar(QWindow *window, bool skip) {
|
void WaylandIntegration::skipTaskbar(QWindow *window, bool skip) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user