aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-03 19:34:56 -0400
committerLibravatar emersion <contact@emersion.fr>2018-04-03 19:34:56 -0400
commitc0554d23d3d89b92b6a871807771b2c2e1f29f61 (patch)
tree5377d383f4a308fcde86928388934f4cf2eb314f /sway/desktop
parentMerge pull request #1713 from emersion/swaybg-hidpi (diff)
downloadsway-c0554d23d3d89b92b6a871807771b2c2e1f29f61.tar.gz
sway-c0554d23d3d89b92b6a871807771b2c2e1f29f61.tar.zst
sway-c0554d23d3d89b92b6a871807771b2c2e1f29f61.zip
Fix rendering with multiple outputs
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/output.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 10ed1f6d..4b407f41 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -46,10 +46,7 @@ static void rotate_child_position(double *sx, double *sy, double sw, double sh,
46 */ 46 */
47static bool surface_intersect_output(struct wlr_surface *surface, 47static bool surface_intersect_output(struct wlr_surface *surface,
48 struct wlr_output_layout *output_layout, struct wlr_output *wlr_output, 48 struct wlr_output_layout *output_layout, struct wlr_output *wlr_output,
49 double lx, double ly, float rotation, struct wlr_box *box) { 49 double ox, double oy, float rotation, struct wlr_box *box) {
50 double ox = lx, oy = ly;
51 wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
52
53 if (box != NULL) { 50 if (box != NULL) {
54 box->x = ox * wlr_output->scale; 51 box->x = ox * wlr_output->scale;
55 box->y = oy * wlr_output->scale; 52 box->y = oy * wlr_output->scale;
@@ -58,7 +55,7 @@ static bool surface_intersect_output(struct wlr_surface *surface,
58 } 55 }
59 56
60 struct wlr_box layout_box = { 57 struct wlr_box layout_box = {
61 .x = lx, .y = ly, 58 .x = wlr_output->lx + ox, .y = wlr_output->ly + oy,
62 .width = surface->current->width, .height = surface->current->height, 59 .width = surface->current->width, .height = surface->current->height,
63 }; 60 };
64 wlr_box_rotated_bounds(&layout_box, rotation, &layout_box); 61 wlr_box_rotated_bounds(&layout_box, rotation, &layout_box);
@@ -67,7 +64,7 @@ static bool surface_intersect_output(struct wlr_surface *surface,
67 64
68static void render_surface(struct wlr_surface *surface, 65static void render_surface(struct wlr_surface *surface,
69 struct wlr_output *wlr_output, struct timespec *when, 66 struct wlr_output *wlr_output, struct timespec *when,
70 double lx, double ly, float rotation) { 67 double ox, double oy, float rotation) {
71 struct wlr_renderer *renderer = 68 struct wlr_renderer *renderer =
72 wlr_backend_get_renderer(wlr_output->backend); 69 wlr_backend_get_renderer(wlr_output->backend);
73 70
@@ -79,7 +76,7 @@ static void render_surface(struct wlr_surface *surface,
79 76
80 struct wlr_box box; 77 struct wlr_box box;
81 bool intersects = surface_intersect_output(surface, layout, wlr_output, 78 bool intersects = surface_intersect_output(surface, layout, wlr_output,
82 lx, ly, rotation, &box); 79 ox, oy, rotation, &box);
83 if (intersects) { 80 if (intersects) {
84 float matrix[9]; 81 float matrix[9];
85 enum wl_output_transform transform = 82 enum wl_output_transform transform =
@@ -102,7 +99,7 @@ static void render_surface(struct wlr_surface *surface,
102 surface->current->width, surface->current->height, rotation); 99 surface->current->width, surface->current->height, rotation);
103 100
104 render_surface(subsurface->surface, wlr_output, when, 101 render_surface(subsurface->surface, wlr_output, when,
105 lx + sx, ly + sy, rotation); 102 ox + sx, oy + sy, rotation);
106 } 103 }
107} 104}
108 105
@@ -200,9 +197,7 @@ static void render_view(struct sway_container *view, void *data) {
200 } 197 }
201} 198}
202 199
203static void render_layer(struct sway_output *output, 200static void render_layer(struct sway_output *output, struct timespec *when,
204 const struct wlr_box *output_layout_box,
205 struct timespec *when,
206 struct wl_list *layer) { 201 struct wl_list *layer) {
207 struct sway_layer_surface *sway_layer; 202 struct sway_layer_surface *sway_layer;
208 wl_list_for_each(sway_layer, layer, link) { 203 wl_list_for_each(sway_layer, layer, link) {
@@ -234,14 +229,15 @@ static void render_output(struct sway_output *output, struct timespec *when,
234 float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; 229 float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
235 wlr_renderer_clear(renderer, clear_color); 230 wlr_renderer_clear(renderer, clear_color);
236 231
237 struct wlr_output_layout *layout = root_container.sway_root->output_layout; 232 struct wlr_output_layout *output_layout =
233 root_container.sway_root->output_layout;
238 const struct wlr_box *output_box = 234 const struct wlr_box *output_box =
239 wlr_output_layout_get_box(layout, wlr_output); 235 wlr_output_layout_get_box(output_layout, wlr_output);
240 236
241 render_layer(output, output_box, when, 237 render_layer(output, when,
242 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); 238 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
243 render_layer(output, output_box, when, 239 render_layer(output, when,
244 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); 240 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
245 241
246 struct sway_seat *seat = input_manager_current_seat(input_manager); 242 struct sway_seat *seat = input_manager_current_seat(input_manager);
247 struct sway_container *focus = 243 struct sway_container *focus =
@@ -251,7 +247,7 @@ static void render_output(struct sway_output *output, struct timespec *when,
251 focus = output->swayc->children->items[0]; 247 focus = output->swayc->children->items[0];
252 } 248 }
253 struct sway_container *workspace = focus->type == C_WORKSPACE ? 249 struct sway_container *workspace = focus->type == C_WORKSPACE ?
254 focus : container_parent(focus, C_WORKSPACE); 250 focus : container_parent(focus, C_WORKSPACE);
255 251
256 struct render_data rdata = { 252 struct render_data rdata = {
257 .output = output, 253 .output = output,
@@ -285,10 +281,10 @@ static void render_output(struct sway_output *output, struct timespec *when,
285 } 281 }
286 282
287 // TODO: Consider revising this when fullscreen windows are supported 283 // TODO: Consider revising this when fullscreen windows are supported
288 render_layer(output, output_box, when, 284 render_layer(output, when,
289 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); 285 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
290 render_layer(output, output_box, when, 286 render_layer(output, when,
291 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); 287 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
292 288
293renderer_end: 289renderer_end:
294 wlr_renderer_end(renderer); 290 wlr_renderer_end(renderer);