diff options
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 8ecb330d..f685ef71 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -80,7 +80,7 @@ static struct sway_xdg_shell_v6_view *xdg_shell_v6_view_from_view( | |||
80 | return (struct sway_xdg_shell_v6_view *)view; | 80 | return (struct sway_xdg_shell_v6_view *)view; |
81 | } | 81 | } |
82 | 82 | ||
83 | static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | 83 | static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { |
84 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 84 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
85 | return NULL; | 85 | return NULL; |
86 | } | 86 | } |
@@ -158,7 +158,7 @@ static void destroy(struct sway_view *view) { | |||
158 | } | 158 | } |
159 | 159 | ||
160 | static const struct sway_view_impl view_impl = { | 160 | static const struct sway_view_impl view_impl = { |
161 | .get_prop = get_prop, | 161 | .get_string_prop = get_string_prop, |
162 | .configure = configure, | 162 | .configure = configure, |
163 | .set_activated = set_activated, | 163 | .set_activated = set_activated, |
164 | .set_fullscreen = set_fullscreen, | 164 | .set_fullscreen = set_fullscreen, |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 8f935760..554c070e 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 | ||
129 | static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | 129 | static const char *get_string_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,11 +135,27 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | |||
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; | ||
138 | default: | 140 | default: |
139 | return NULL; | 141 | return NULL; |
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
145 | static 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 | |||
143 | static void configure(struct sway_view *view, double ox, double oy, int width, | 159 | static void configure(struct sway_view *view, double ox, double oy, int width, |
144 | int height) { | 160 | int height) { |
145 | struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); | 161 | struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); |
@@ -200,13 +216,17 @@ static void destroy(struct sway_view *view) { | |||
200 | wl_list_remove(&xwayland_view->destroy.link); | 216 | wl_list_remove(&xwayland_view->destroy.link); |
201 | wl_list_remove(&xwayland_view->request_configure.link); | 217 | wl_list_remove(&xwayland_view->request_configure.link); |
202 | wl_list_remove(&xwayland_view->request_fullscreen.link); | 218 | 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); | ||
203 | wl_list_remove(&xwayland_view->map.link); | 222 | wl_list_remove(&xwayland_view->map.link); |
204 | wl_list_remove(&xwayland_view->unmap.link); | 223 | wl_list_remove(&xwayland_view->unmap.link); |
205 | free(xwayland_view); | 224 | free(xwayland_view); |
206 | } | 225 | } |
207 | 226 | ||
208 | static const struct sway_view_impl view_impl = { | 227 | static const struct sway_view_impl view_impl = { |
209 | .get_prop = get_prop, | 228 | .get_string_prop = get_string_prop, |
229 | .get_int_prop = get_int_prop, | ||
210 | .configure = configure, | 230 | .configure = configure, |
211 | .set_activated = set_activated, | 231 | .set_activated = set_activated, |
212 | .set_fullscreen = set_fullscreen, | 232 | .set_fullscreen = set_fullscreen, |
@@ -223,7 +243,6 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
223 | view_update_size(view, xwayland_view->pending_width, | 243 | view_update_size(view, xwayland_view->pending_width, |
224 | xwayland_view->pending_height); | 244 | xwayland_view->pending_height); |
225 | view_damage_from(view); | 245 | view_damage_from(view); |
226 | view_update_title(view, false); | ||
227 | } | 246 | } |
228 | 247 | ||
229 | static void handle_unmap(struct wl_listener *listener, void *data) { | 248 | static void handle_unmap(struct wl_listener *listener, void *data) { |
@@ -285,6 +304,40 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
285 | view_set_fullscreen(view, xsurface->fullscreen); | 304 | view_set_fullscreen(view, xsurface->fullscreen); |
286 | } | 305 | } |
287 | 306 | ||
307 | static 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 | |||
319 | static 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 | |||
330 | static 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 | |||
288 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { | 341 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { |
289 | struct sway_server *server = wl_container_of(listener, server, | 342 | struct sway_server *server = wl_container_of(listener, server, |
290 | xwayland_surface); | 343 | xwayland_surface); |
@@ -323,6 +376,16 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
323 | &xwayland_view->request_fullscreen); | 376 | &xwayland_view->request_fullscreen); |
324 | xwayland_view->request_fullscreen.notify = handle_request_fullscreen; | 377 | xwayland_view->request_fullscreen.notify = handle_request_fullscreen; |
325 | 378 | ||
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 | |||
326 | wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); | 389 | wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); |
327 | xwayland_view->unmap.notify = handle_unmap; | 390 | xwayland_view->unmap.notify = handle_unmap; |
328 | 391 | ||