mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-03-03 01:41:28 -05:00
view: replace view_has_children with view_is_transient_for
This is a much cleaner implementation but allows us to do the same things.
This commit is contained in:
parent
7de253386c
commit
5c403edc0b
5 changed files with 36 additions and 22 deletions
18
xdg_shell.c
18
xdg_shell.c
|
|
@ -51,14 +51,22 @@ is_primary(struct cg_view *view)
|
|||
}
|
||||
|
||||
static bool
|
||||
is_parent(struct cg_view *parent, struct cg_view *child)
|
||||
is_transient_for(struct cg_view *child, struct cg_view *parent)
|
||||
{
|
||||
if (child->type != CAGE_XDG_SHELL_VIEW) {
|
||||
if (parent->type != CAGE_XDG_SHELL_VIEW) {
|
||||
return false;
|
||||
}
|
||||
struct cg_xdg_shell_view *_parent = xdg_shell_view_from_view(parent);
|
||||
struct cg_xdg_shell_view *_child = xdg_shell_view_from_view(child);
|
||||
return _child->xdg_surface->toplevel->parent == _parent->xdg_surface;
|
||||
struct wlr_xdg_surface *xdg_surface = _child->xdg_surface;
|
||||
struct cg_xdg_shell_view *_parent = xdg_shell_view_from_view(parent);
|
||||
struct wlr_xdg_surface *parent_xdg_surface = _parent->xdg_surface;
|
||||
while (xdg_surface) {
|
||||
if (xdg_surface->toplevel->parent == parent_xdg_surface) {
|
||||
return true;
|
||||
}
|
||||
xdg_surface = xdg_surface->toplevel->parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -133,7 +141,7 @@ static const struct cg_view_impl xdg_shell_view_impl = {
|
|||
.get_title = get_title,
|
||||
.get_geometry = get_geometry,
|
||||
.is_primary = is_primary,
|
||||
.is_parent = is_parent,
|
||||
.is_transient_for = is_transient_for,
|
||||
.activate = activate,
|
||||
.maximize = maximize,
|
||||
.destroy = destroy,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue