diff options
author | 2018-04-16 20:36:40 +1000 | |
---|---|---|
committer | 2018-04-16 20:36:40 +1000 | |
commit | 52420cc24d61db8d22cf0d391f1f84b37bf087d5 (patch) | |
tree | f975a3708c0d1562a8d2fcdceaed9a76aadbf1f4 /sway/desktop | |
parent | Merge pull request #1816 from thejan2009/multi-output-ws-destroy (diff) | |
download | sway-52420cc24d61db8d22cf0d391f1f84b37bf087d5.tar.gz sway-52420cc24d61db8d22cf0d391f1f84b37bf087d5.tar.zst sway-52420cc24d61db8d22cf0d391f1f84b37bf087d5.zip |
Implement fullscreen.
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/output.c | 24 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 26 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 34 |
3 files changed, 76 insertions, 8 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1b3143d0..b86f20e8 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -273,17 +273,25 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
273 | float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; | 273 | float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; |
274 | wlr_renderer_clear(renderer, clear_color); | 274 | wlr_renderer_clear(renderer, clear_color); |
275 | 275 | ||
276 | render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); | ||
277 | render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); | ||
278 | |||
279 | struct sway_container *workspace = output_get_active_workspace(output); | 276 | struct sway_container *workspace = output_get_active_workspace(output); |
280 | render_container(output, workspace); | ||
281 | 277 | ||
282 | render_unmanaged(output, &root_container.sway_root->xwayland_unmanaged); | 278 | if (workspace->fullscreen) { |
279 | wlr_output_set_fullscreen_surface(wlr_output, | ||
280 | workspace->fullscreen->surface); | ||
281 | } else { | ||
282 | wlr_output_set_fullscreen_surface(wlr_output, NULL); | ||
283 | render_layer(output, | ||
284 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); | ||
285 | render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); | ||
286 | |||
287 | render_container(output, workspace); | ||
283 | 288 | ||
284 | // TODO: consider revising this when fullscreen windows are supported | 289 | render_unmanaged(output, &root_container.sway_root->xwayland_unmanaged); |
285 | render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 290 | |
286 | render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 291 | render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
292 | render_layer(output, | ||
293 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | ||
294 | } | ||
287 | 295 | ||
288 | renderer_end: | 296 | renderer_end: |
289 | if (root_container.sway_root->debug_tree) { | 297 | if (root_container.sway_root->debug_tree) { |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index e4703040..133b60c3 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -118,6 +118,14 @@ static void set_activated(struct sway_view *view, bool activated) { | |||
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | static void set_fullscreen(struct sway_view *view, bool fullscreen) { | ||
122 | if (xdg_shell_v6_view_from_view(view) == NULL) { | ||
123 | return; | ||
124 | } | ||
125 | struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; | ||
126 | wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen); | ||
127 | } | ||
128 | |||
121 | static void for_each_surface(struct sway_view *view, | 129 | static void for_each_surface(struct sway_view *view, |
122 | wlr_surface_iterator_func_t iterator, void *user_data) { | 130 | wlr_surface_iterator_func_t iterator, void *user_data) { |
123 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 131 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
@@ -146,6 +154,7 @@ static void destroy(struct sway_view *view) { | |||
146 | wl_list_remove(&xdg_shell_v6_view->destroy.link); | 154 | wl_list_remove(&xdg_shell_v6_view->destroy.link); |
147 | wl_list_remove(&xdg_shell_v6_view->map.link); | 155 | wl_list_remove(&xdg_shell_v6_view->map.link); |
148 | wl_list_remove(&xdg_shell_v6_view->unmap.link); | 156 | wl_list_remove(&xdg_shell_v6_view->unmap.link); |
157 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); | ||
149 | free(xdg_shell_v6_view); | 158 | free(xdg_shell_v6_view); |
150 | } | 159 | } |
151 | 160 | ||
@@ -153,6 +162,7 @@ static const struct sway_view_impl view_impl = { | |||
153 | .get_prop = get_prop, | 162 | .get_prop = get_prop, |
154 | .configure = configure, | 163 | .configure = configure, |
155 | .set_activated = set_activated, | 164 | .set_activated = set_activated, |
165 | .set_fullscreen = set_fullscreen, | ||
156 | .for_each_surface = for_each_surface, | 166 | .for_each_surface = for_each_surface, |
157 | .close = _close, | 167 | .close = _close, |
158 | .destroy = destroy, | 168 | .destroy = destroy, |
@@ -210,6 +220,18 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
210 | view_destroy(&xdg_shell_v6_view->view); | 220 | view_destroy(&xdg_shell_v6_view->view); |
211 | } | 221 | } |
212 | 222 | ||
223 | static void handle_request_fullscreen(struct wl_listener *listener, void *data) { | ||
224 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | ||
225 | wl_container_of(listener, xdg_shell_v6_view, request_fullscreen); | ||
226 | struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data; | ||
227 | |||
228 | if (xdg_shell_v6_view->view.wlr_xdg_surface_v6->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { | ||
229 | return; | ||
230 | } | ||
231 | |||
232 | view_set_fullscreen(&xdg_shell_v6_view->view, e->fullscreen); | ||
233 | } | ||
234 | |||
213 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | 235 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { |
214 | struct sway_server *server = wl_container_of(listener, server, | 236 | struct sway_server *server = wl_container_of(listener, server, |
215 | xdg_shell_v6_surface); | 237 | xdg_shell_v6_surface); |
@@ -246,4 +268,8 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
246 | 268 | ||
247 | xdg_shell_v6_view->destroy.notify = handle_destroy; | 269 | xdg_shell_v6_view->destroy.notify = handle_destroy; |
248 | wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_v6_view->destroy); | 270 | wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_v6_view->destroy); |
271 | |||
272 | xdg_shell_v6_view->request_fullscreen.notify = handle_request_fullscreen; | ||
273 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, | ||
274 | &xdg_shell_v6_view->request_fullscreen); | ||
249 | } | 275 | } |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 69166af0..716d8882 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -25,6 +25,15 @@ static void unmanaged_handle_request_configure(struct wl_listener *listener, | |||
25 | ev->width, ev->height); | 25 | ev->width, ev->height); |
26 | } | 26 | } |
27 | 27 | ||
28 | static void unmanaged_handle_request_fullscreen(struct wl_listener *listener, | ||
29 | void *data) { | ||
30 | struct sway_xwayland_view *xwayland_view = | ||
31 | wl_container_of(listener, xwayland_view, request_fullscreen); | ||
32 | struct sway_view *view = &xwayland_view->view; | ||
33 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | ||
34 | view_set_fullscreen(view, xsurface->fullscreen); | ||
35 | } | ||
36 | |||
28 | static void unmanaged_handle_commit(struct wl_listener *listener, void *data) { | 37 | static void unmanaged_handle_commit(struct wl_listener *listener, void *data) { |
29 | struct sway_xwayland_unmanaged *surface = | 38 | struct sway_xwayland_unmanaged *surface = |
30 | wl_container_of(listener, surface, commit); | 39 | wl_container_of(listener, surface, commit); |
@@ -106,6 +115,9 @@ static struct sway_xwayland_unmanaged *create_unmanaged( | |||
106 | wl_signal_add(&xsurface->events.request_configure, | 115 | wl_signal_add(&xsurface->events.request_configure, |
107 | &surface->request_configure); | 116 | &surface->request_configure); |
108 | surface->request_configure.notify = unmanaged_handle_request_configure; | 117 | surface->request_configure.notify = unmanaged_handle_request_configure; |
118 | wl_signal_add(&xsurface->events.request_fullscreen, | ||
119 | &surface->request_fullscreen); | ||
120 | surface->request_fullscreen.notify = unmanaged_handle_request_fullscreen; | ||
109 | wl_signal_add(&xsurface->events.map, &surface->map); | 121 | wl_signal_add(&xsurface->events.map, &surface->map); |
110 | surface->map.notify = unmanaged_handle_map; | 122 | surface->map.notify = unmanaged_handle_map; |
111 | wl_signal_add(&xsurface->events.unmap, &surface->unmap); | 123 | wl_signal_add(&xsurface->events.unmap, &surface->unmap); |
@@ -179,6 +191,14 @@ static void set_activated(struct sway_view *view, bool activated) { | |||
179 | wlr_xwayland_surface_activate(surface, activated); | 191 | wlr_xwayland_surface_activate(surface, activated); |
180 | } | 192 | } |
181 | 193 | ||
194 | static void set_fullscreen(struct sway_view *view, bool fullscreen) { | ||
195 | if (xwayland_view_from_view(view) == NULL) { | ||
196 | return; | ||
197 | } | ||
198 | struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; | ||
199 | wlr_xwayland_surface_set_fullscreen(surface, fullscreen); | ||
200 | } | ||
201 | |||
182 | static void _close(struct sway_view *view) { | 202 | static void _close(struct sway_view *view) { |
183 | if (xwayland_view_from_view(view) == NULL) { | 203 | if (xwayland_view_from_view(view) == NULL) { |
184 | return; | 204 | return; |
@@ -193,6 +213,7 @@ static void destroy(struct sway_view *view) { | |||
193 | } | 213 | } |
194 | wl_list_remove(&xwayland_view->destroy.link); | 214 | wl_list_remove(&xwayland_view->destroy.link); |
195 | wl_list_remove(&xwayland_view->request_configure.link); | 215 | wl_list_remove(&xwayland_view->request_configure.link); |
216 | wl_list_remove(&xwayland_view->request_fullscreen.link); | ||
196 | wl_list_remove(&xwayland_view->map.link); | 217 | wl_list_remove(&xwayland_view->map.link); |
197 | wl_list_remove(&xwayland_view->unmap.link); | 218 | wl_list_remove(&xwayland_view->unmap.link); |
198 | free(xwayland_view); | 219 | free(xwayland_view); |
@@ -202,6 +223,7 @@ static const struct sway_view_impl view_impl = { | |||
202 | .get_prop = get_prop, | 223 | .get_prop = get_prop, |
203 | .configure = configure, | 224 | .configure = configure, |
204 | .set_activated = set_activated, | 225 | .set_activated = set_activated, |
226 | .set_fullscreen = set_fullscreen, | ||
205 | .close = _close, | 227 | .close = _close, |
206 | .destroy = destroy, | 228 | .destroy = destroy, |
207 | }; | 229 | }; |
@@ -263,6 +285,14 @@ static void handle_request_configure(struct wl_listener *listener, void *data) { | |||
263 | ev->width, ev->height); | 285 | ev->width, ev->height); |
264 | } | 286 | } |
265 | 287 | ||
288 | static void handle_request_fullscreen(struct wl_listener *listener, void *data) { | ||
289 | struct sway_xwayland_view *xwayland_view = | ||
290 | wl_container_of(listener, xwayland_view, request_fullscreen); | ||
291 | struct sway_view *view = &xwayland_view->view; | ||
292 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | ||
293 | view_set_fullscreen(view, xsurface->fullscreen); | ||
294 | } | ||
295 | |||
266 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { | 296 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { |
267 | struct sway_server *server = wl_container_of(listener, server, | 297 | struct sway_server *server = wl_container_of(listener, server, |
268 | xwayland_surface); | 298 | xwayland_surface); |
@@ -298,6 +328,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
298 | &xwayland_view->request_configure); | 328 | &xwayland_view->request_configure); |
299 | xwayland_view->request_configure.notify = handle_request_configure; | 329 | xwayland_view->request_configure.notify = handle_request_configure; |
300 | 330 | ||
331 | wl_signal_add(&xsurface->events.request_fullscreen, | ||
332 | &xwayland_view->request_fullscreen); | ||
333 | xwayland_view->request_fullscreen.notify = handle_request_fullscreen; | ||
334 | |||
301 | wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); | 335 | wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); |
302 | xwayland_view->unmap.notify = handle_unmap; | 336 | xwayland_view->unmap.notify = handle_unmap; |
303 | 337 | ||