diff options
author | 2018-05-13 08:16:36 +1000 | |
---|---|---|
committer | 2018-05-14 11:38:09 +1000 | |
commit | 1e9aaa54a85e98d6b46ca594b4f50770f71047ea (patch) | |
tree | cb6a2748d1c53dfc80f9faa5da7052790e668400 /sway/desktop | |
parent | Actually fix swayidle (diff) | |
download | sway-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')
-rw-r--r-- | sway/desktop/wl_shell.c | 4 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 4 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 69 |
3 files changed, 70 insertions, 7 deletions
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index 99e8947b..cb3774f7 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -20,7 +20,7 @@ static struct sway_wl_shell_view *wl_shell_view_from_view( | |||
20 | return (struct sway_wl_shell_view *)view; | 20 | return (struct sway_wl_shell_view *)view; |
21 | } | 21 | } |
22 | 22 | ||
23 | static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | 23 | static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { |
24 | if (wl_shell_view_from_view(view) == NULL) { | 24 | if (wl_shell_view_from_view(view) == NULL) { |
25 | return NULL; | 25 | return NULL; |
26 | } | 26 | } |
@@ -70,7 +70,7 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { | |||
70 | } | 70 | } |
71 | 71 | ||
72 | static const struct sway_view_impl view_impl = { | 72 | static const struct sway_view_impl view_impl = { |
73 | .get_prop = get_prop, | 73 | .get_string_prop = get_string_prop, |
74 | .configure = configure, | 74 | .configure = configure, |
75 | .close = _close, | 75 | .close = _close, |
76 | .destroy = destroy, | 76 | .destroy = destroy, |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index e9051b6c..d098c797 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -72,7 +72,7 @@ static struct sway_xdg_shell_v6_view *xdg_shell_v6_view_from_view( | |||
72 | return (struct sway_xdg_shell_v6_view *)view; | 72 | return (struct sway_xdg_shell_v6_view *)view; |
73 | } | 73 | } |
74 | 74 | ||
75 | static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | 75 | static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { |
76 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 76 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
77 | return NULL; | 77 | return NULL; |
78 | } | 78 | } |
@@ -150,7 +150,7 @@ static void destroy(struct sway_view *view) { | |||
150 | } | 150 | } |
151 | 151 | ||
152 | static const struct sway_view_impl view_impl = { | 152 | static const struct sway_view_impl view_impl = { |
153 | .get_prop = get_prop, | 153 | .get_string_prop = get_string_prop, |
154 | .configure = configure, | 154 | .configure = configure, |
155 | .set_activated = set_activated, | 155 | .set_activated = set_activated, |
156 | .set_fullscreen = set_fullscreen, | 156 | .set_fullscreen = set_fullscreen, |
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 | ||
125 | static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | 125 | static 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 | ||
141 | static 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 | |||
139 | static void configure(struct sway_view *view, double ox, double oy, int width, | 155 | static 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 | ||
204 | static const struct sway_view_impl view_impl = { | 223 | static 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 | ||
225 | static void handle_unmap(struct wl_listener *listener, void *data) { | 244 | static 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 | ||
303 | static 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 | |||
315 | static 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 | |||
326 | static 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 | |||
284 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { | 337 | void 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 | ||