mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-05 14:42:01 -07:00
xdg-dialog: implement new protocol
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user