constraint popups to its parent client

Closes: #146
Closes: #155
This commit is contained in:
Leonardo Hernández Hernández 2022-03-16 23:08:17 -06:00
parent 2768af5a9b
commit 294fb324d8
No known key found for this signature in database
GPG key ID: E538897EE11B9624
2 changed files with 29 additions and 1 deletions

View file

@ -179,3 +179,24 @@ client_surface_at(Client *c, double cx, double cy, double *sx, double *sy)
#endif
return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy);
}
static inline Client *
client_from_popup(struct wlr_xdg_popup *popup)
{
struct wlr_xdg_surface *surface = popup->base;
while (1) {
switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_POPUP:
if (!wlr_surface_is_xdg_surface(surface->popup->parent))
return NULL;
surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent);
break;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
return surface->data;
case WLR_XDG_SURFACE_ROLE_NONE:
return NULL;
}
}
}