diff options
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/view.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 6263bfb0..06e9edc5 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -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; |