aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xwayland.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-13 08:16:36 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-14 11:38:09 +1000
commit1e9aaa54a85e98d6b46ca594b4f50770f71047ea (patch)
treecb6a2748d1c53dfc80f9faa5da7052790e668400 /sway/desktop/xwayland.c
parentActually fix swayidle (diff)
downloadsway-1e9aaa54a85e98d6b46ca594b4f50770f71047ea.tar.gz
sway-1e9aaa54a85e98d6b46ca594b4f50770f71047ea.tar.zst
sway-1e9aaa54a85e98d6b46ca594b4f50770f71047ea.zip
Revert "Revert "Merge pull request #1943 from RyanDwyer/criteria-improvements""
This reverts commit 32a572cecfd0f6072a78ce0a381a2f8365f9010a. This reimplements the criteria overhaul in preparation for fixing a known bug.
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r--sway/desktop/xwayland.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 1d3c857d..6a99a66a 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -122,7 +122,7 @@ static struct sway_xwayland_view *xwayland_view_from_view(
122 return (struct sway_xwayland_view *)view; 122 return (struct sway_xwayland_view *)view;
123} 123}
124 124
125static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { 125static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) {
126 if (xwayland_view_from_view(view) == NULL) { 126 if (xwayland_view_from_view(view) == NULL) {
127 return NULL; 127 return NULL;
128 } 128 }
@@ -131,11 +131,27 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
131 return view->wlr_xwayland_surface->title; 131 return view->wlr_xwayland_surface->title;
132 case VIEW_PROP_CLASS: 132 case VIEW_PROP_CLASS:
133 return view->wlr_xwayland_surface->class; 133 return view->wlr_xwayland_surface->class;
134 case VIEW_PROP_INSTANCE:
135 return view->wlr_xwayland_surface->instance;
134 default: 136 default:
135 return NULL; 137 return NULL;
136 } 138 }
137} 139}
138 140
141static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
142 if (xwayland_view_from_view(view) == NULL) {
143 return 0;
144 }
145 switch (prop) {
146 case VIEW_PROP_X11_WINDOW_ID:
147 return view->wlr_xwayland_surface->window_id;
148 case VIEW_PROP_WINDOW_TYPE:
149 return *view->wlr_xwayland_surface->window_type;
150 default:
151 return 0;
152 }
153}
154
139static void configure(struct sway_view *view, double ox, double oy, int width, 155static void configure(struct sway_view *view, double ox, double oy, int width,
140 int height) { 156 int height) {
141 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); 157 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
@@ -196,13 +212,17 @@ static void destroy(struct sway_view *view) {
196 wl_list_remove(&xwayland_view->destroy.link); 212 wl_list_remove(&xwayland_view->destroy.link);
197 wl_list_remove(&xwayland_view->request_configure.link); 213 wl_list_remove(&xwayland_view->request_configure.link);
198 wl_list_remove(&xwayland_view->request_fullscreen.link); 214 wl_list_remove(&xwayland_view->request_fullscreen.link);
215 wl_list_remove(&xwayland_view->set_title.link);
216 wl_list_remove(&xwayland_view->set_class.link);
217 wl_list_remove(&xwayland_view->set_window_type.link);
199 wl_list_remove(&xwayland_view->map.link); 218 wl_list_remove(&xwayland_view->map.link);
200 wl_list_remove(&xwayland_view->unmap.link); 219 wl_list_remove(&xwayland_view->unmap.link);
201 free(xwayland_view); 220 free(xwayland_view);
202} 221}
203 222
204static const struct sway_view_impl view_impl = { 223static const struct sway_view_impl view_impl = {
205 .get_prop = get_prop, 224 .get_string_prop = get_string_prop,
225 .get_int_prop = get_int_prop,
206 .configure = configure, 226 .configure = configure,
207 .set_activated = set_activated, 227 .set_activated = set_activated,
208 .set_fullscreen = set_fullscreen, 228 .set_fullscreen = set_fullscreen,
@@ -219,7 +239,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
219 view_update_size(view, xwayland_view->pending_width, 239 view_update_size(view, xwayland_view->pending_width,
220 xwayland_view->pending_height); 240 xwayland_view->pending_height);
221 view_damage_from(view); 241 view_damage_from(view);
222 view_update_title(view, false);
223} 242}
224 243
225static void handle_unmap(struct wl_listener *listener, void *data) { 244static void handle_unmap(struct wl_listener *listener, void *data) {
@@ -281,6 +300,40 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
281 view_set_fullscreen(view, xsurface->fullscreen); 300 view_set_fullscreen(view, xsurface->fullscreen);
282} 301}
283 302
303static void handle_set_title(struct wl_listener *listener, void *data) {
304 struct sway_xwayland_view *xwayland_view =
305 wl_container_of(listener, xwayland_view, set_title);
306 struct sway_view *view = &xwayland_view->view;
307 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
308 if (!xsurface->mapped) {
309 return;
310 }
311 view_update_title(view, false);
312 view_execute_criteria(view);
313}
314
315static void handle_set_class(struct wl_listener *listener, void *data) {
316 struct sway_xwayland_view *xwayland_view =
317 wl_container_of(listener, xwayland_view, set_class);
318 struct sway_view *view = &xwayland_view->view;
319 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
320 if (!xsurface->mapped) {
321 return;
322 }
323 view_execute_criteria(view);
324}
325
326static void handle_set_window_type(struct wl_listener *listener, void *data) {
327 struct sway_xwayland_view *xwayland_view =
328 wl_container_of(listener, xwayland_view, set_window_type);
329 struct sway_view *view = &xwayland_view->view;
330 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
331 if (!xsurface->mapped) {
332 return;
333 }
334 view_execute_criteria(view);
335}
336
284void handle_xwayland_surface(struct wl_listener *listener, void *data) { 337void handle_xwayland_surface(struct wl_listener *listener, void *data) {
285 struct sway_server *server = wl_container_of(listener, server, 338 struct sway_server *server = wl_container_of(listener, server,
286 xwayland_surface); 339 xwayland_surface);
@@ -319,6 +372,16 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
319 &xwayland_view->request_fullscreen); 372 &xwayland_view->request_fullscreen);
320 xwayland_view->request_fullscreen.notify = handle_request_fullscreen; 373 xwayland_view->request_fullscreen.notify = handle_request_fullscreen;
321 374
375 wl_signal_add(&xsurface->events.set_title, &xwayland_view->set_title);
376 xwayland_view->set_title.notify = handle_set_title;
377
378 wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_class);
379 xwayland_view->set_class.notify = handle_set_class;
380
381 wl_signal_add(&xsurface->events.set_window_type,
382 &xwayland_view->set_window_type);
383 xwayland_view->set_window_type.notify = handle_set_window_type;
384
322 wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); 385 wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap);
323 xwayland_view->unmap.notify = handle_unmap; 386 xwayland_view->unmap.notify = handle_unmap;
324 387