aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xwayland.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-03-31 18:07:44 -0400
committerLibravatar emersion <contact@emersion.fr>2018-03-31 18:07:44 -0400
commit1d68f9ecca8870f2f2a6823072c77657436b123a (patch)
treed66fbfa54f5c20f77c640bb695e43c02f2364bc3 /sway/desktop/xwayland.c
parentIntroduce common functions to create, map, unmap, destroy views (diff)
downloadsway-1d68f9ecca8870f2f2a6823072c77657436b123a.tar.gz
sway-1d68f9ecca8870f2f2a6823072c77657436b123a.tar.zst
sway-1d68f9ecca8870f2f2a6823072c77657436b123a.zip
Add sway_view_impl
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r--sway/desktop/xwayland.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index e1c2ad08..93c78228 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -81,13 +81,21 @@ static void set_activated(struct sway_view *view, bool activated) {
81 wlr_xwayland_surface_activate(surface, activated); 81 wlr_xwayland_surface_activate(surface, activated);
82} 82}
83 83
84static void close_view(struct sway_view *view) { 84static void _close(struct sway_view *view) {
85 if (!assert_xwayland(view)) { 85 if (!assert_xwayland(view)) {
86 return; 86 return;
87 } 87 }
88 wlr_xwayland_surface_close(view->wlr_xwayland_surface); 88 wlr_xwayland_surface_close(view->wlr_xwayland_surface);
89} 89}
90 90
91static const struct sway_view_impl view_impl = {
92 .get_prop = get_prop,
93 .set_size = set_size,
94 .set_position = set_position,
95 .set_activated = set_activated,
96 .close = _close,
97};
98
91static void handle_commit(struct wl_listener *listener, void *data) { 99static void handle_commit(struct wl_listener *listener, void *data) {
92 struct sway_xwayland_surface *sway_surface = 100 struct sway_xwayland_surface *sway_surface =
93 wl_container_of(listener, sway_surface, commit); 101 wl_container_of(listener, sway_surface, commit);
@@ -159,15 +167,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
159 return; 167 return;
160 } 168 }
161 169
162 struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW); 170 struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW, &view_impl);
163 if (!sway_assert(view, "Failed to allocate view")) { 171 if (!sway_assert(view, "Failed to allocate view")) {
164 return; 172 return;
165 } 173 }
166 view->iface.get_prop = get_prop;
167 view->iface.set_size = set_size;
168 view->iface.set_position = set_position;
169 view->iface.set_activated = set_activated;
170 view->iface.close = close_view;
171 view->wlr_xwayland_surface = xsurface; 174 view->wlr_xwayland_surface = xsurface;
172 view->sway_xwayland_surface = sway_surface; 175 view->sway_xwayland_surface = sway_surface;
173 sway_surface->view = view; 176 sway_surface->view = view;