mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
view: add view_has_children to query if a view has children
This allows us to check per-view whether is has dialogs open, instead of diong it on a global basis as we are doing currently. This is necessary for fully supporting multiple primary clients.
This commit is contained in:
parent
112a662ebc
commit
b0bd4e680d
4 changed files with 28 additions and 0 deletions
12
view.c
12
view.c
|
|
@ -68,6 +68,18 @@ view_is_primary(struct cg_view *view)
|
|||
return view->is_primary(view);
|
||||
}
|
||||
|
||||
bool
|
||||
view_has_children(struct cg_server *server, struct cg_view *parent)
|
||||
{
|
||||
struct cg_view *child;
|
||||
wl_list_for_each(child, &server->views, link) {
|
||||
if (parent != child && parent->is_parent(parent, child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
view_position(struct cg_view *view)
|
||||
{
|
||||
|
|
|
|||
2
view.h
2
view.h
|
|
@ -49,6 +49,7 @@ struct cg_view {
|
|||
struct wlr_surface *(*wlr_surface_at)(struct cg_view *view, double sx, double sy,
|
||||
double *sub_x, double *sub_y);
|
||||
bool (*is_primary)(struct cg_view *view);
|
||||
bool (*is_parent)(struct cg_view *parent, struct cg_view *child);
|
||||
};
|
||||
|
||||
void view_activate(struct cg_view *view, bool activate);
|
||||
|
|
@ -56,6 +57,7 @@ void view_for_each_surface(struct cg_view *view, wlr_surface_iterator_func_t ite
|
|||
struct wlr_surface *view_wlr_surface_at(struct cg_view *view, double sx, double sy,
|
||||
double *sub_x, double *sub_y);
|
||||
bool view_is_primary(struct cg_view *view);
|
||||
bool view_has_children(struct cg_server *server, struct cg_view *view);
|
||||
void view_position(struct cg_view *view);
|
||||
void view_unmap(struct cg_view *view);
|
||||
void view_map(struct cg_view *view, struct wlr_surface *surface);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ is_primary(struct cg_view *view)
|
|||
return parent == NULL; /*&& role == WLR_XDG_SURFACE_ROLE_TOPLEVEL */
|
||||
}
|
||||
|
||||
static bool
|
||||
is_parent(struct cg_view *parent, struct cg_view *child)
|
||||
{
|
||||
return child->xdg_surface->toplevel->parent == parent->xdg_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_xdg_shell_surface_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
@ -106,4 +112,5 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
|
|||
view->for_each_surface = for_each_surface;
|
||||
view->wlr_surface_at = wlr_surface_at;
|
||||
view->is_primary = is_primary;
|
||||
view->is_parent = is_parent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,12 @@ is_primary(struct cg_view *view)
|
|||
return parent == NULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_parent(struct cg_view *parent, struct cg_view *child)
|
||||
{
|
||||
return child->xwayland_surface->parent == parent->xwayland_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_xwayland_surface_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
@ -98,4 +104,5 @@ handle_xwayland_surface_new(struct wl_listener *listener, void *data)
|
|||
view->for_each_surface = for_each_surface;
|
||||
view->wlr_surface_at = wlr_surface_at;
|
||||
view->is_primary = is_primary;
|
||||
view->is_parent = is_parent;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue