diff options
Diffstat (limited to 'src/protocols/XDGShell.cpp')
-rw-r--r-- | src/protocols/XDGShell.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/protocols/XDGShell.cpp b/src/protocols/XDGShell.cpp index 39a511c3..25d8b1ba 100644 --- a/src/protocols/XDGShell.cpp +++ b/src/protocols/XDGShell.cpp @@ -1,10 +1,12 @@ #include "XDGShell.hpp" +#include "XDGDialog.hpp" #include <algorithm> #include "../Compositor.hpp" #include "../managers/SeatManager.hpp" #include "core/Seat.hpp" #include "core/Compositor.hpp" #include <cstring> +#include <ranges> void SXDGPositionerState::setAnchor(xdgPositionerAnchor edges) { anchor.setTop(edges == XDG_POSITIONER_ANCHOR_TOP || edges == XDG_POSITIONER_ANCHOR_TOP_LEFT || edges == XDG_POSITIONER_ANCHOR_TOP_RIGHT); @@ -207,15 +209,25 @@ CXDGToplevelResource::CXDGToplevelResource(SP<CXdgToplevel> resource_, SP<CXDGSu }); resource->setSetParent([this](CXdgToplevel* r, wl_resource* parentR) { + auto oldParent = parent; + + if (parent) + std::erase(parent->children, self); + auto newp = parentR ? CXDGToplevelResource::fromResource(parentR) : nullptr; parent = newp; - LOGM(LOG, "Toplevel {:x} sets parent to {:x}", (uintptr_t)this, (uintptr_t)newp.get()); + if (parent) + parent->children.emplace_back(self); + + LOGM(LOG, "Toplevel {:x} sets parent to {:x}{}", (uintptr_t)this, (uintptr_t)newp.get(), (oldParent ? std::format(" (was {:x})", (uintptr_t)oldParent.get()) : "")); }); } CXDGToplevelResource::~CXDGToplevelResource() { events.destroy.emit(); + if (parent) + std::erase_if(parent->children, [this](const auto& other) { return !other || other.get() == this; }); } SP<CXDGToplevelResource> CXDGToplevelResource::fromResource(wl_resource* res) { @@ -227,6 +239,10 @@ bool CXDGToplevelResource::good() { return resource->resource(); } +bool CXDGToplevelResource::anyChildModal() { + return std::ranges::any_of(children, [](const auto& child) { return child && child->dialog && child->dialog->modal; }); +} + uint32_t CXDGToplevelResource::setSize(const Vector2D& size) { pendingApply.size = size; applyState(); |