diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-06-30 06:41:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-30 06:41:33 -0700 |
commit | 792eb6ad402ae76bdc12b267af6bf7abac2b95f9 (patch) | |
tree | a4f6056b5cfa80e065f366d20e1d97957d3ee393 /sway/tree/view.c | |
parent | d8c61c976372eedf271f505ffd82c461b6503f6f (diff) | |
parent | 9ea4cc13a0cf2d231c4e4c71aa674cd76831e6f9 (diff) |
Merge pull request #2174 from martinetd/view-from-surface
sway views: add helpers to get view and layer from wlr_surface
Diffstat (limited to 'sway/tree/view.c')
-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; |