diff options
author | emersion <contact@emersion.fr> | 2019-03-11 11:45:01 +0100 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-03-11 12:43:01 -0400 |
commit | 076257a978ce5f93b9b1613e43a067e602b5b041 (patch) | |
tree | f87dcb88bee0097cbf741df180f17d06299087cf /sway/desktop/render.c | |
parent | Fix size_t temporary underflow in log_loaded_themes (diff) | |
download | sway-076257a978ce5f93b9b1613e43a067e602b5b041.tar.gz sway-076257a978ce5f93b9b1613e43a067e602b5b041.tar.zst sway-076257a978ce5f93b9b1613e43a067e602b5b041.zip |
Stop using wlr_output->{lx,ly}
Also fixes sway_output->{lx,ly,width,height} not being updated. Also fixes
output_get_in_direction adding buffer coords to layout coords.
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r-- | sway/desktop/render.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 4b36a9c2..9e936bb5 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -157,16 +157,17 @@ static void render_drag_icons(struct sway_output *output, | |||
157 | 157 | ||
158 | // _box.x and .y are expected to be layout-local | 158 | // _box.x and .y are expected to be layout-local |
159 | // _box.width and .height are expected to be output-buffer-local | 159 | // _box.width and .height are expected to be output-buffer-local |
160 | void render_rect(struct wlr_output *wlr_output, | 160 | void render_rect(struct sway_output *output, |
161 | pixman_region32_t *output_damage, const struct wlr_box *_box, | 161 | pixman_region32_t *output_damage, const struct wlr_box *_box, |
162 | float color[static 4]) { | 162 | float color[static 4]) { |
163 | struct wlr_output *wlr_output = output->wlr_output; | ||
163 | struct wlr_renderer *renderer = | 164 | struct wlr_renderer *renderer = |
164 | wlr_backend_get_renderer(wlr_output->backend); | 165 | wlr_backend_get_renderer(wlr_output->backend); |
165 | 166 | ||
166 | struct wlr_box box; | 167 | struct wlr_box box; |
167 | memcpy(&box, _box, sizeof(struct wlr_box)); | 168 | memcpy(&box, _box, sizeof(struct wlr_box)); |
168 | box.x -= wlr_output->lx * wlr_output->scale; | 169 | box.x -= output->lx * wlr_output->scale; |
169 | box.y -= wlr_output->ly * wlr_output->scale; | 170 | box.y -= output->ly * wlr_output->scale; |
170 | 171 | ||
171 | pixman_region32_t damage; | 172 | pixman_region32_t damage; |
172 | pixman_region32_init(&damage); | 173 | pixman_region32_init(&damage); |
@@ -205,9 +206,9 @@ static void render_view_toplevels(struct sway_view *view, | |||
205 | }; | 206 | }; |
206 | // Render all toplevels without descending into popups | 207 | // Render all toplevels without descending into popups |
207 | double ox = view->container->surface_x - | 208 | double ox = view->container->surface_x - |
208 | output->wlr_output->lx - view->geometry.x; | 209 | output->lx - view->geometry.x; |
209 | double oy = view->container->surface_y - | 210 | double oy = view->container->surface_y - |
210 | output->wlr_output->ly - view->geometry.y; | 211 | output->ly - view->geometry.y; |
211 | output_surface_for_each_surface(output, view->surface, ox, oy, | 212 | output_surface_for_each_surface(output, view->surface, ox, oy, |
212 | render_surface_iterator, &data); | 213 | render_surface_iterator, &data); |
213 | } | 214 | } |
@@ -240,9 +241,9 @@ static void render_saved_view(struct sway_view *view, | |||
240 | return; | 241 | return; |
241 | } | 242 | } |
242 | struct wlr_box box = { | 243 | struct wlr_box box = { |
243 | .x = view->container->surface_x - output->wlr_output->lx - | 244 | .x = view->container->surface_x - output->lx - |
244 | view->saved_geometry.x, | 245 | view->saved_geometry.x, |
245 | .y = view->container->surface_y - output->wlr_output->ly - | 246 | .y = view->container->surface_y - output->ly - |
246 | view->saved_geometry.y, | 247 | view->saved_geometry.y, |
247 | .width = view->saved_buffer_width, | 248 | .width = view->saved_buffer_width, |
248 | .height = view->saved_buffer_height, | 249 | .height = view->saved_buffer_height, |
@@ -298,7 +299,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, | |||
298 | box.width = state->border_thickness; | 299 | box.width = state->border_thickness; |
299 | box.height = state->content_height; | 300 | box.height = state->content_height; |
300 | scale_box(&box, output_scale); | 301 | scale_box(&box, output_scale); |
301 | render_rect(output->wlr_output, damage, &box, color); | 302 | render_rect(output, damage, &box, color); |
302 | } | 303 | } |
303 | 304 | ||
304 | list_t *siblings = container_get_current_siblings(con); | 305 | list_t *siblings = container_get_current_siblings(con); |
@@ -317,7 +318,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, | |||
317 | box.width = state->border_thickness; | 318 | box.width = state->border_thickness; |
318 | box.height = state->content_height; | 319 | box.height = state->content_height; |
319 | scale_box(&box, output_scale); | 320 | scale_box(&box, output_scale); |
320 | render_rect(output->wlr_output, damage, &box, color); | 321 | render_rect(output, damage, &box, color); |
321 | } | 322 | } |
322 | 323 | ||
323 | if (state->border_bottom) { | 324 | if (state->border_bottom) { |
@@ -332,7 +333,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, | |||
332 | box.width = state->width; | 333 | box.width = state->width; |
333 | box.height = state->border_thickness; | 334 | box.height = state->border_thickness; |
334 | scale_box(&box, output_scale); | 335 | scale_box(&box, output_scale); |
335 | render_rect(output->wlr_output, damage, &box, color); | 336 | render_rect(output, damage, &box, color); |
336 | } | 337 | } |
337 | } | 338 | } |
338 | 339 | ||
@@ -359,8 +360,8 @@ static void render_titlebar(struct sway_output *output, | |||
359 | list_t *children = container_get_current_siblings(con); | 360 | list_t *children = container_get_current_siblings(con); |
360 | bool is_last_child = children->length == 0 || | 361 | bool is_last_child = children->length == 0 || |
361 | children->items[children->length - 1] == con; | 362 | children->items[children->length - 1] == con; |
362 | double output_x = output->wlr_output->lx; | 363 | double output_x = output->lx; |
363 | double output_y = output->wlr_output->ly; | 364 | double output_y = output->ly; |
364 | int titlebar_border_thickness = config->titlebar_border_thickness; | 365 | int titlebar_border_thickness = config->titlebar_border_thickness; |
365 | int titlebar_h_padding = config->titlebar_h_padding; | 366 | int titlebar_h_padding = config->titlebar_h_padding; |
366 | int titlebar_v_padding = config->titlebar_v_padding; | 367 | int titlebar_v_padding = config->titlebar_v_padding; |
@@ -374,7 +375,7 @@ static void render_titlebar(struct sway_output *output, | |||
374 | box.width = width; | 375 | box.width = width; |
375 | box.height = titlebar_border_thickness; | 376 | box.height = titlebar_border_thickness; |
376 | scale_box(&box, output_scale); | 377 | scale_box(&box, output_scale); |
377 | render_rect(output->wlr_output, output_damage, &box, color); | 378 | render_rect(output, output_damage, &box, color); |
378 | 379 | ||
379 | // Single pixel bar below title | 380 | // Single pixel bar below title |
380 | size_t left_offset = 0, right_offset = 0; | 381 | size_t left_offset = 0, right_offset = 0; |
@@ -392,7 +393,7 @@ static void render_titlebar(struct sway_output *output, | |||
392 | box.width = width - left_offset - right_offset; | 393 | box.width = width - left_offset - right_offset; |
393 | box.height = titlebar_border_thickness; | 394 | box.height = titlebar_border_thickness; |
394 | scale_box(&box, output_scale); | 395 | scale_box(&box, output_scale); |
395 | render_rect(output->wlr_output, output_damage, &box, color); | 396 | render_rect(output, output_damage, &box, color); |
396 | 397 | ||
397 | if (layout == L_TABBED) { | 398 | if (layout == L_TABBED) { |
398 | // Single pixel left edge | 399 | // Single pixel left edge |
@@ -402,7 +403,7 @@ static void render_titlebar(struct sway_output *output, | |||
402 | box.height = | 403 | box.height = |
403 | container_titlebar_height() - titlebar_border_thickness * 2; | 404 | container_titlebar_height() - titlebar_border_thickness * 2; |
404 | scale_box(&box, output_scale); | 405 | scale_box(&box, output_scale); |
405 | render_rect(output->wlr_output, output_damage, &box, color); | 406 | render_rect(output, output_damage, &box, color); |
406 | 407 | ||
407 | // Single pixel right edge | 408 | // Single pixel right edge |
408 | box.x = x + width - titlebar_border_thickness; | 409 | box.x = x + width - titlebar_border_thickness; |
@@ -411,7 +412,7 @@ static void render_titlebar(struct sway_output *output, | |||
411 | box.height = | 412 | box.height = |
412 | container_titlebar_height() - titlebar_border_thickness * 2; | 413 | container_titlebar_height() - titlebar_border_thickness * 2; |
413 | scale_box(&box, output_scale); | 414 | scale_box(&box, output_scale); |
414 | render_rect(output->wlr_output, output_damage, &box, color); | 415 | render_rect(output, output_damage, &box, color); |
415 | } | 416 | } |
416 | 417 | ||
417 | int inner_x = x - output_x + titlebar_h_padding; | 418 | int inner_x = x - output_x + titlebar_h_padding; |
@@ -470,12 +471,12 @@ static void render_titlebar(struct sway_output *output, | |||
470 | box.y = round((y + titlebar_border_thickness) * output_scale); | 471 | box.y = round((y + titlebar_border_thickness) * output_scale); |
471 | box.width = texture_box.width; | 472 | box.width = texture_box.width; |
472 | box.height = ob_padding_above; | 473 | box.height = ob_padding_above; |
473 | render_rect(output->wlr_output, output_damage, &box, color); | 474 | render_rect(output, output_damage, &box, color); |
474 | 475 | ||
475 | // Padding below | 476 | // Padding below |
476 | box.y += ob_padding_above + texture_box.height; | 477 | box.y += ob_padding_above + texture_box.height; |
477 | box.height = ob_padding_below; | 478 | box.height = ob_padding_below; |
478 | render_rect(output->wlr_output, output_damage, &box, color); | 479 | render_rect(output, output_damage, &box, color); |
479 | } | 480 | } |
480 | 481 | ||
481 | // Title text | 482 | // Title text |
@@ -538,12 +539,12 @@ static void render_titlebar(struct sway_output *output, | |||
538 | box.y = round((y + titlebar_border_thickness) * output_scale); | 539 | box.y = round((y + titlebar_border_thickness) * output_scale); |
539 | box.width = texture_box.width; | 540 | box.width = texture_box.width; |
540 | box.height = ob_padding_above; | 541 | box.height = ob_padding_above; |
541 | render_rect(output->wlr_output, output_damage, &box, color); | 542 | render_rect(output, output_damage, &box, color); |
542 | 543 | ||
543 | // Padding below | 544 | // Padding below |
544 | box.y += ob_padding_above + texture_box.height; | 545 | box.y += ob_padding_above + texture_box.height; |
545 | box.height = ob_padding_below; | 546 | box.height = ob_padding_below; |
546 | render_rect(output->wlr_output, output_damage, &box, color); | 547 | render_rect(output, output_damage, &box, color); |
547 | } | 548 | } |
548 | 549 | ||
549 | // Determine the left + right extends of the textures (output-buffer local) | 550 | // Determine the left + right extends of the textures (output-buffer local) |
@@ -577,7 +578,7 @@ static void render_titlebar(struct sway_output *output, | |||
577 | box.x = ob_left_x + ob_left_width + round(output_x * output_scale); | 578 | box.x = ob_left_x + ob_left_width + round(output_x * output_scale); |
578 | box.y = round(bg_y * output_scale); | 579 | box.y = round(bg_y * output_scale); |
579 | box.height = ob_bg_height; | 580 | box.height = ob_bg_height; |
580 | render_rect(output->wlr_output, output_damage, &box, color); | 581 | render_rect(output, output_damage, &box, color); |
581 | } | 582 | } |
582 | 583 | ||
583 | // Padding on left side | 584 | // Padding on left side |
@@ -592,7 +593,7 @@ static void render_titlebar(struct sway_output *output, | |||
592 | if (box.x + box.width < left_x) { | 593 | if (box.x + box.width < left_x) { |
593 | box.width += left_x - box.x - box.width; | 594 | box.width += left_x - box.x - box.width; |
594 | } | 595 | } |
595 | render_rect(output->wlr_output, output_damage, &box, color); | 596 | render_rect(output, output_damage, &box, color); |
596 | 597 | ||
597 | // Padding on right side | 598 | // Padding on right side |
598 | right_offset = (layout == L_TABBED) * titlebar_border_thickness; | 599 | right_offset = (layout == L_TABBED) * titlebar_border_thickness; |
@@ -607,7 +608,7 @@ static void render_titlebar(struct sway_output *output, | |||
607 | box.width += box.x - right_rx; | 608 | box.width += box.x - right_rx; |
608 | box.x = right_rx; | 609 | box.x = right_rx; |
609 | } | 610 | } |
610 | render_rect(output->wlr_output, output_damage, &box, color); | 611 | render_rect(output, output_damage, &box, color); |
611 | 612 | ||
612 | if (connects_sides) { | 613 | if (connects_sides) { |
613 | // Left pixel in line with bottom bar | 614 | // Left pixel in line with bottom bar |
@@ -616,7 +617,7 @@ static void render_titlebar(struct sway_output *output, | |||
616 | box.width = state->border_thickness * state->border_left; | 617 | box.width = state->border_thickness * state->border_left; |
617 | box.height = titlebar_border_thickness; | 618 | box.height = titlebar_border_thickness; |
618 | scale_box(&box, output_scale); | 619 | scale_box(&box, output_scale); |
619 | render_rect(output->wlr_output, output_damage, &box, color); | 620 | render_rect(output, output_damage, &box, color); |
620 | 621 | ||
621 | // Right pixel in line with bottom bar | 622 | // Right pixel in line with bottom bar |
622 | box.x = x + width - state->border_thickness * state->border_right; | 623 | box.x = x + width - state->border_thickness * state->border_right; |
@@ -624,7 +625,7 @@ static void render_titlebar(struct sway_output *output, | |||
624 | box.width = state->border_thickness * state->border_right; | 625 | box.width = state->border_thickness * state->border_right; |
625 | box.height = titlebar_border_thickness; | 626 | box.height = titlebar_border_thickness; |
626 | scale_box(&box, output_scale); | 627 | scale_box(&box, output_scale); |
627 | render_rect(output->wlr_output, output_damage, &box, color); | 628 | render_rect(output, output_damage, &box, color); |
628 | } | 629 | } |
629 | } | 630 | } |
630 | 631 | ||
@@ -650,7 +651,7 @@ static void render_top_border(struct sway_output *output, | |||
650 | box.width = state->width; | 651 | box.width = state->width; |
651 | box.height = state->border_thickness; | 652 | box.height = state->border_thickness; |
652 | scale_box(&box, output_scale); | 653 | scale_box(&box, output_scale); |
653 | render_rect(output->wlr_output, output_damage, &box, color); | 654 | render_rect(output, output_damage, &box, color); |
654 | } | 655 | } |
655 | 656 | ||
656 | struct parent_data { | 657 | struct parent_data { |