aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xwayland.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r--sway/desktop/xwayland.c69
1 files changed, 3 insertions, 66 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 554c070e..8f935760 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -126,7 +126,7 @@ static struct sway_xwayland_view *xwayland_view_from_view(
126 return (struct sway_xwayland_view *)view; 126 return (struct sway_xwayland_view *)view;
127} 127}
128 128
129static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { 129static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
130 if (xwayland_view_from_view(view) == NULL) { 130 if (xwayland_view_from_view(view) == NULL) {
131 return NULL; 131 return NULL;
132 } 132 }
@@ -135,27 +135,11 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
135 return view->wlr_xwayland_surface->title; 135 return view->wlr_xwayland_surface->title;
136 case VIEW_PROP_CLASS: 136 case VIEW_PROP_CLASS:
137 return view->wlr_xwayland_surface->class; 137 return view->wlr_xwayland_surface->class;
138 case VIEW_PROP_INSTANCE:
139 return view->wlr_xwayland_surface->instance;
140 default: 138 default:
141 return NULL; 139 return NULL;
142 } 140 }
143} 141}
144 142
145static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
146 if (xwayland_view_from_view(view) == NULL) {
147 return 0;
148 }
149 switch (prop) {
150 case VIEW_PROP_X11_WINDOW_ID:
151 return view->wlr_xwayland_surface->window_id;
152 case VIEW_PROP_WINDOW_TYPE:
153 return *view->wlr_xwayland_surface->window_type;
154 default:
155 return 0;
156 }
157}
158
159static void configure(struct sway_view *view, double ox, double oy, int width, 143static void configure(struct sway_view *view, double ox, double oy, int width,
160 int height) { 144 int height) {
161 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); 145 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
@@ -216,17 +200,13 @@ static void destroy(struct sway_view *view) {
216 wl_list_remove(&xwayland_view->destroy.link); 200 wl_list_remove(&xwayland_view->destroy.link);
217 wl_list_remove(&xwayland_view->request_configure.link); 201 wl_list_remove(&xwayland_view->request_configure.link);
218 wl_list_remove(&xwayland_view->request_fullscreen.link); 202 wl_list_remove(&xwayland_view->request_fullscreen.link);
219 wl_list_remove(&xwayland_view->set_title.link);
220 wl_list_remove(&xwayland_view->set_class.link);
221 wl_list_remove(&xwayland_view->set_window_type.link);
222 wl_list_remove(&xwayland_view->map.link); 203 wl_list_remove(&xwayland_view->map.link);
223 wl_list_remove(&xwayland_view->unmap.link); 204 wl_list_remove(&xwayland_view->unmap.link);
224 free(xwayland_view); 205 free(xwayland_view);
225} 206}
226 207
227static const struct sway_view_impl view_impl = { 208static const struct sway_view_impl view_impl = {
228 .get_string_prop = get_string_prop, 209 .get_prop = get_prop,
229 .get_int_prop = get_int_prop,
230 .configure = configure, 210 .configure = configure,
231 .set_activated = set_activated, 211 .set_activated = set_activated,
232 .set_fullscreen = set_fullscreen, 212 .set_fullscreen = set_fullscreen,
@@ -243,6 +223,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
243 view_update_size(view, xwayland_view->pending_width, 223 view_update_size(view, xwayland_view->pending_width,
244 xwayland_view->pending_height); 224 xwayland_view->pending_height);
245 view_damage_from(view); 225 view_damage_from(view);
226 view_update_title(view, false);
246} 227}
247 228
248static void handle_unmap(struct wl_listener *listener, void *data) { 229static void handle_unmap(struct wl_listener *listener, void *data) {
@@ -304,40 +285,6 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
304 view_set_fullscreen(view, xsurface->fullscreen); 285 view_set_fullscreen(view, xsurface->fullscreen);
305} 286}
306 287
307static void handle_set_title(struct wl_listener *listener, void *data) {
308 struct sway_xwayland_view *xwayland_view =
309 wl_container_of(listener, xwayland_view, set_title);
310 struct sway_view *view = &xwayland_view->view;
311 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
312 if (!xsurface->mapped) {
313 return;
314 }
315 view_update_title(view, false);
316 view_execute_criteria(view);
317}
318
319static void handle_set_class(struct wl_listener *listener, void *data) {
320 struct sway_xwayland_view *xwayland_view =
321 wl_container_of(listener, xwayland_view, set_class);
322 struct sway_view *view = &xwayland_view->view;
323 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
324 if (!xsurface->mapped) {
325 return;
326 }
327 view_execute_criteria(view);
328}
329
330static void handle_set_window_type(struct wl_listener *listener, void *data) {
331 struct sway_xwayland_view *xwayland_view =
332 wl_container_of(listener, xwayland_view, set_window_type);
333 struct sway_view *view = &xwayland_view->view;
334 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
335 if (!xsurface->mapped) {
336 return;
337 }
338 view_execute_criteria(view);
339}
340
341void handle_xwayland_surface(struct wl_listener *listener, void *data) { 288void handle_xwayland_surface(struct wl_listener *listener, void *data) {
342 struct sway_server *server = wl_container_of(listener, server, 289 struct sway_server *server = wl_container_of(listener, server,
343 xwayland_surface); 290 xwayland_surface);
@@ -376,16 +323,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
376 &xwayland_view->request_fullscreen); 323 &xwayland_view->request_fullscreen);
377 xwayland_view->request_fullscreen.notify = handle_request_fullscreen; 324 xwayland_view->request_fullscreen.notify = handle_request_fullscreen;
378 325
379 wl_signal_add(&xsurface->events.set_title, &xwayland_view->set_title);
380 xwayland_view->set_title.notify = handle_set_title;
381
382 wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_class);
383 xwayland_view->set_class.notify = handle_set_class;
384
385 wl_signal_add(&xsurface->events.set_window_type,
386 &xwayland_view->set_window_type);
387 xwayland_view->set_window_type.notify = handle_set_window_type;
388
389 wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); 326 wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap);
390 xwayland_view->unmap.notify = handle_unmap; 327 xwayland_view->unmap.notify = handle_unmap;
391 328