mirror of
https://github.com/swaywm/sway.git
synced 2025-11-07 13:29:56 -05:00
sway views: add helpers to get view and layer from wlr_surface
This commit is contained in:
parent
d8c61c9763
commit
9ea4cc13a0
8 changed files with 73 additions and 0 deletions
|
|
@ -694,6 +694,36 @@ void view_child_destroy(struct sway_view_child *child) {
|
|||
}
|
||||
}
|
||||
|
||||
struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
|
||||
if (wlr_surface_is_xdg_surface(wlr_surface)) {
|
||||
struct wlr_xdg_surface *xdg_surface =
|
||||
wlr_xdg_surface_from_wlr_surface(wlr_surface);
|
||||
return view_from_wlr_xdg_surface(xdg_surface);
|
||||
}
|
||||
if (wlr_surface_is_xdg_surface_v6(wlr_surface)) {
|
||||
struct wlr_xdg_surface_v6 *xdg_surface_v6 =
|
||||
wlr_xdg_surface_v6_from_wlr_surface(wlr_surface);
|
||||
return view_from_wlr_xdg_surface_v6(xdg_surface_v6);
|
||||
}
|
||||
if (wlr_surface_is_xwayland_surface(wlr_surface)) {
|
||||
struct wlr_xwayland_surface *xsurface =
|
||||
wlr_xwayland_surface_from_wlr_surface(wlr_surface);
|
||||
return view_from_wlr_xwayland_surface(xsurface);
|
||||
}
|
||||
if (wlr_surface_is_subsurface(wlr_surface)) {
|
||||
struct wlr_subsurface *subsurface =
|
||||
wlr_subsurface_from_wlr_surface(wlr_surface);
|
||||
return view_from_wlr_surface(subsurface->parent);
|
||||
}
|
||||
if (wlr_surface_is_layer_surface(wlr_surface)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wlr_log(L_DEBUG, "Surface of unknown type (role %s): %p",
|
||||
wlr_surface->role, wlr_surface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static size_t append_prop(char *buffer, const char *value) {
|
||||
if (!value) {
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue