diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-07-25 08:32:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 08:32:32 -0400 |
commit | 53dbe2da4bd2563ec69211d0c51fb347109fc70d (patch) | |
tree | b7de5dc2d2556866aec06c5c513ac3020b6af2d6 | |
parent | Merge pull request #2350 from ppascher/xwayland-optional (diff) | |
parent | Improve rendering with a fullscreen opaque overlay surface (diff) | |
download | sway-53dbe2da4bd2563ec69211d0c51fb347109fc70d.tar.gz sway-53dbe2da4bd2563ec69211d0c51fb347109fc70d.tar.zst sway-53dbe2da4bd2563ec69211d0c51fb347109fc70d.zip |
Merge pull request #2353 from emersion/render-opaque-overlay
Improve rendering with a fullscreen opaque overlay surface
-rw-r--r-- | include/sway/output.h | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 26 | ||||
-rw-r--r-- | sway/desktop/render.c | 23 |
3 files changed, 17 insertions, 35 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index b6cda83c..c225e541 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -65,8 +65,7 @@ struct sway_container *output_by_name(const char *name); | |||
65 | 65 | ||
66 | void output_enable(struct sway_output *output); | 66 | void output_enable(struct sway_output *output); |
67 | 67 | ||
68 | bool output_has_opaque_lockscreen(struct sway_output *output, | 68 | bool output_has_opaque_overlay_layer_surface(struct sway_output *output); |
69 | struct sway_seat *seat); | ||
70 | 69 | ||
71 | struct sway_container *output_get_active_workspace(struct sway_output *output); | 70 | struct sway_container *output_get_active_workspace(struct sway_output *output); |
72 | 71 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1512408e..1764b4e3 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -182,21 +182,14 @@ struct sway_container *output_get_active_workspace(struct sway_output *output) { | |||
182 | return workspace; | 182 | return workspace; |
183 | } | 183 | } |
184 | 184 | ||
185 | bool output_has_opaque_lockscreen(struct sway_output *output, | 185 | bool output_has_opaque_overlay_layer_surface(struct sway_output *output) { |
186 | struct sway_seat *seat) { | ||
187 | if (!seat->exclusive_client) { | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | struct wlr_layer_surface *wlr_layer_surface; | 186 | struct wlr_layer_surface *wlr_layer_surface; |
192 | wl_list_for_each(wlr_layer_surface, &server.layer_shell->surfaces, link) { | 187 | wl_list_for_each(wlr_layer_surface, &server.layer_shell->surfaces, link) { |
193 | if (wlr_layer_surface->output != output->wlr_output) { | 188 | if (wlr_layer_surface->output != output->wlr_output || |
189 | wlr_layer_surface->layer != ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { | ||
194 | continue; | 190 | continue; |
195 | } | 191 | } |
196 | struct wlr_surface *wlr_surface = wlr_layer_surface->surface; | 192 | struct wlr_surface *wlr_surface = wlr_layer_surface->surface; |
197 | if (wlr_surface->resource->client != seat->exclusive_client) { | ||
198 | continue; | ||
199 | } | ||
200 | struct sway_layer_surface *sway_layer_surface = | 193 | struct sway_layer_surface *sway_layer_surface = |
201 | layer_from_wlr_layer_surface(wlr_layer_surface); | 194 | layer_from_wlr_layer_surface(wlr_layer_surface); |
202 | pixman_box32_t output_box = { | 195 | pixman_box32_t output_box = { |
@@ -222,16 +215,11 @@ struct send_frame_done_data { | |||
222 | struct root_geometry root_geo; | 215 | struct root_geometry root_geo; |
223 | struct sway_output *output; | 216 | struct sway_output *output; |
224 | struct timespec *when; | 217 | struct timespec *when; |
225 | struct wl_client *exclusive_client; | ||
226 | }; | 218 | }; |
227 | 219 | ||
228 | static void send_frame_done_iterator(struct wlr_surface *surface, | 220 | static void send_frame_done_iterator(struct wlr_surface *surface, |
229 | int sx, int sy, void *_data) { | 221 | int sx, int sy, void *_data) { |
230 | struct send_frame_done_data *data = _data; | 222 | struct send_frame_done_data *data = _data; |
231 | if (data->exclusive_client && | ||
232 | data->exclusive_client != surface->resource->client) { | ||
233 | return; | ||
234 | } | ||
235 | 223 | ||
236 | bool intersects = output_get_surface_box(&data->root_geo, data->output, surface, | 224 | bool intersects = output_get_surface_box(&data->root_geo, data->output, surface, |
237 | sx, sy, NULL); | 225 | sx, sy, NULL); |
@@ -280,14 +268,15 @@ static void send_frame_done_container(struct send_frame_done_data *data, | |||
280 | } | 268 | } |
281 | 269 | ||
282 | static void send_frame_done(struct sway_output *output, struct timespec *when) { | 270 | static void send_frame_done(struct sway_output *output, struct timespec *when) { |
283 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
284 | struct send_frame_done_data data = { | 271 | struct send_frame_done_data data = { |
285 | .output = output, | 272 | .output = output, |
286 | .when = when, | 273 | .when = when, |
287 | .exclusive_client = output_has_opaque_lockscreen(output, seat) ? | ||
288 | seat->exclusive_client : NULL, | ||
289 | }; | 274 | }; |
290 | 275 | ||
276 | if (output_has_opaque_overlay_layer_surface(output)) { | ||
277 | goto send_frame_overlay; | ||
278 | } | ||
279 | |||
291 | struct sway_container *workspace = output_get_active_workspace(output); | 280 | struct sway_container *workspace = output_get_active_workspace(output); |
292 | if (workspace->current.ws_fullscreen) { | 281 | if (workspace->current.ws_fullscreen) { |
293 | send_frame_done_container_iterator( | 282 | send_frame_done_container_iterator( |
@@ -315,6 +304,7 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { | |||
315 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 304 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
316 | } | 305 | } |
317 | 306 | ||
307 | send_frame_overlay: | ||
318 | send_frame_done_layer(&data, | 308 | send_frame_done_layer(&data, |
319 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 309 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
320 | send_frame_done_drag_icons(&data, &root_container.sway_root->drag_icons); | 310 | send_frame_done_drag_icons(&data, &root_container.sway_root->drag_icons); |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 3e7bd94b..15c5b94c 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -837,21 +837,12 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
837 | 837 | ||
838 | struct sway_container *workspace = output_get_active_workspace(output); | 838 | struct sway_container *workspace = output_get_active_workspace(output); |
839 | struct sway_view *fullscreen_view = workspace->current.ws_fullscreen; | 839 | struct sway_view *fullscreen_view = workspace->current.ws_fullscreen; |
840 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 840 | |
841 | 841 | if (output_has_opaque_overlay_layer_surface(output)) { | |
842 | if (output_has_opaque_lockscreen(output, seat) && seat->focused_layer) { | 842 | goto render_overlay; |
843 | struct wlr_layer_surface *wlr_layer_surface = seat->focused_layer; | 843 | } |
844 | struct sway_layer_surface *sway_layer_surface = | 844 | |
845 | layer_from_wlr_layer_surface(seat->focused_layer); | 845 | if (fullscreen_view) { |
846 | struct render_data data = { | ||
847 | .output = output, | ||
848 | .damage = damage, | ||
849 | .alpha = 1.0f, | ||
850 | }; | ||
851 | output_surface_for_each_surface(wlr_layer_surface->surface, | ||
852 | sway_layer_surface->geo.x, sway_layer_surface->geo.y, | ||
853 | &data.root_geo, render_surface_iterator, &data); | ||
854 | } else if (fullscreen_view) { | ||
855 | float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f}; | 846 | float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f}; |
856 | 847 | ||
857 | int nrects; | 848 | int nrects; |
@@ -897,6 +888,8 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
897 | render_layer(output, damage, | 888 | render_layer(output, damage, |
898 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 889 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
899 | } | 890 | } |
891 | |||
892 | render_overlay: | ||
900 | render_layer(output, damage, | 893 | render_layer(output, damage, |
901 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 894 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
902 | render_drag_icons(output, damage, &root_container.sway_root->drag_icons); | 895 | render_drag_icons(output, damage, &root_container.sway_root->drag_icons); |