diff options
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 37528cac..a485cb10 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <wayland-server.h> | 6 | #include <wayland-server.h> |
7 | #include <wlr/render/wlr_renderer.h> | 7 | #include <wlr/render/wlr_renderer.h> |
8 | #include <wlr/types/wlr_box.h> | 8 | #include <wlr/types/wlr_box.h> |
9 | #include <wlr/types/wlr_buffer.h> | ||
9 | #include <wlr/types/wlr_matrix.h> | 10 | #include <wlr/types/wlr_matrix.h> |
10 | #include <wlr/types/wlr_output_damage.h> | 11 | #include <wlr/types/wlr_output_damage.h> |
11 | #include <wlr/types/wlr_output_layout.h> | 12 | #include <wlr/types/wlr_output_layout.h> |
@@ -112,8 +113,8 @@ static bool get_surface_box(struct root_geometry *geo, | |||
112 | static bool get_view_box(struct root_geometry *geo, | 113 | static bool get_view_box(struct root_geometry *geo, |
113 | struct sway_output *output, struct sway_view *view, int sx, int sy, | 114 | struct sway_output *output, struct sway_view *view, int sx, int sy, |
114 | struct wlr_box *surface_box) { | 115 | struct wlr_box *surface_box) { |
115 | int sw = view->width; | 116 | int sw = view->saved_surface_width; |
116 | int sh = view->height; | 117 | int sh = view->saved_surface_height; |
117 | 118 | ||
118 | double _sx = sx, _sy = sy; | 119 | double _sx = sx, _sy = sy; |
119 | rotate_child_position(&_sx, &_sy, sw, sh, geo->width, geo->height, | 120 | rotate_child_position(&_sx, &_sy, sw, sh, geo->width, geo->height, |
@@ -157,10 +158,10 @@ static void output_view_for_each_surface(struct sway_view *view, | |||
157 | struct root_geometry *geo, wlr_surface_iterator_func_t iterator, | 158 | struct root_geometry *geo, wlr_surface_iterator_func_t iterator, |
158 | void *user_data) { | 159 | void *user_data) { |
159 | struct render_data *data = user_data; | 160 | struct render_data *data = user_data; |
160 | geo->x = view->x - data->output->swayc->x; | 161 | geo->x = view->swayc->current.view_x - data->output->swayc->x; |
161 | geo->y = view->y - data->output->swayc->y; | 162 | geo->y = view->swayc->current.view_y - data->output->swayc->y; |
162 | geo->width = view->surface->current->width; | 163 | geo->width = view->swayc->current.view_width; |
163 | geo->height = view->surface->current->height; | 164 | geo->height = view->swayc->current.view_height; |
164 | geo->rotation = 0; // TODO | 165 | geo->rotation = 0; // TODO |
165 | 166 | ||
166 | view_for_each_surface(view, iterator, user_data); | 167 | view_for_each_surface(view, iterator, user_data); |
@@ -277,11 +278,11 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy, | |||
277 | struct wlr_box box; | 278 | struct wlr_box box; |
278 | bool intersects; | 279 | bool intersects; |
279 | 280 | ||
280 | // If this is the main surface of a view, render the saved_texture instead | 281 | // If this is the main surface of a view, render the saved_buffer instead |
281 | // if it exists. It exists when we are mid-transaction. | 282 | // if it exists. It exists when we are mid-transaction. |
282 | if (data->view && data->view->saved_texture && | 283 | if (data->view && data->view->saved_buffer && |
283 | data->view->surface == surface) { | 284 | data->view->surface == surface) { |
284 | texture = data->view->saved_texture; | 285 | texture = data->view->saved_buffer->texture; |
285 | intersects = get_view_box(&data->root_geo, data->output, data->view, | 286 | intersects = get_view_box(&data->root_geo, data->output, data->view, |
286 | sx, sy, &box); | 287 | sx, sy, &box); |
287 | } else { | 288 | } else { |
@@ -405,46 +406,46 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, | |||
405 | float output_scale = output->wlr_output->scale; | 406 | float output_scale = output->wlr_output->scale; |
406 | float color[4]; | 407 | float color[4]; |
407 | 408 | ||
408 | if (view->border != B_NONE) { | 409 | if (con->current.border != B_NONE) { |
409 | if (view->border_left) { | 410 | if (con->current.border_left) { |
410 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 411 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
411 | premultiply_alpha(color, con->alpha); | 412 | premultiply_alpha(color, con->alpha); |
412 | box.x = con->x; | 413 | box.x = con->current.swayc_x; |
413 | box.y = view->y; | 414 | box.y = con->current.view_y; |
414 | box.width = view->border_thickness; | 415 | box.width = con->current.border_thickness; |
415 | box.height = view->height; | 416 | box.height = con->current.view_height; |
416 | scale_box(&box, output_scale); | 417 | scale_box(&box, output_scale); |
417 | render_rect(output->wlr_output, damage, &box, color); | 418 | render_rect(output->wlr_output, damage, &box, color); |
418 | } | 419 | } |
419 | 420 | ||
420 | if (view->border_right) { | 421 | if (con->current.border_right) { |
421 | if (con->parent->children->length == 1 | 422 | if (con->parent->children->length == 1 |
422 | && con->parent->layout == L_HORIZ) { | 423 | && con->parent->current.layout == L_HORIZ) { |
423 | memcpy(&color, colors->indicator, sizeof(float) * 4); | 424 | memcpy(&color, colors->indicator, sizeof(float) * 4); |
424 | } else { | 425 | } else { |
425 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 426 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
426 | } | 427 | } |
427 | premultiply_alpha(color, con->alpha); | 428 | premultiply_alpha(color, con->alpha); |
428 | box.x = view->x + view->width; | 429 | box.x = con->current.view_x + con->current.view_width; |
429 | box.y = view->y; | 430 | box.y = con->current.view_y; |
430 | box.width = view->border_thickness; | 431 | box.width = con->current.border_thickness; |
431 | box.height = view->height; | 432 | box.height = con->current.view_height; |
432 | scale_box(&box, output_scale); | 433 | scale_box(&box, output_scale); |
433 | render_rect(output->wlr_output, damage, &box, color); | 434 | render_rect(output->wlr_output, damage, &box, color); |
434 | } | 435 | } |
435 | 436 | ||
436 | if (view->border_bottom) { | 437 | if (con->current.border_bottom) { |
437 | if (con->parent->children->length == 1 | 438 | if (con->parent->children->length == 1 |
438 | && con->parent->layout == L_VERT) { | 439 | && con->parent->current.layout == L_VERT) { |
439 | memcpy(&color, colors->indicator, sizeof(float) * 4); | 440 | memcpy(&color, colors->indicator, sizeof(float) * 4); |
440 | } else { | 441 | } else { |
441 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 442 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
442 | } | 443 | } |
443 | premultiply_alpha(color, con->alpha); | 444 | premultiply_alpha(color, con->alpha); |
444 | box.x = con->x; | 445 | box.x = con->current.swayc_x; |
445 | box.y = view->y + view->height; | 446 | box.y = con->current.view_y + con->current.view_height; |
446 | box.width = con->width; | 447 | box.width = con->current.swayc_width; |
447 | box.height = view->border_thickness; | 448 | box.height = con->current.border_thickness; |
448 | scale_box(&box, output_scale); | 449 | scale_box(&box, output_scale); |
449 | render_rect(output->wlr_output, damage, &box, color); | 450 | render_rect(output->wlr_output, damage, &box, color); |
450 | } | 451 | } |
@@ -468,9 +469,8 @@ static void render_titlebar(struct sway_output *output, | |||
468 | struct wlr_texture *marks_texture) { | 469 | struct wlr_texture *marks_texture) { |
469 | struct wlr_box box; | 470 | struct wlr_box box; |
470 | float color[4]; | 471 | float color[4]; |
471 | struct sway_view *view = con->type == C_VIEW ? con->sway_view : NULL; | ||
472 | float output_scale = output->wlr_output->scale; | 472 | float output_scale = output->wlr_output->scale; |
473 | enum sway_container_layout layout = con->parent->layout; | 473 | enum sway_container_layout layout = con->parent->current.layout; |
474 | bool is_last_child = | 474 | bool is_last_child = |
475 | con->parent->children->items[con->parent->children->length - 1] == con; | 475 | con->parent->children->items[con->parent->children->length - 1] == con; |
476 | 476 | ||
@@ -489,9 +489,11 @@ static void render_titlebar(struct sway_output *output, | |||
489 | bool connects_sides = false; | 489 | bool connects_sides = false; |
490 | if (layout == L_HORIZ || layout == L_VERT || | 490 | if (layout == L_HORIZ || layout == L_VERT || |
491 | (layout == L_STACKED && is_last_child)) { | 491 | (layout == L_STACKED && is_last_child)) { |
492 | if (view) { | 492 | if (con->type == C_VIEW) { |
493 | left_offset = view->border_left * view->border_thickness; | 493 | left_offset = |
494 | right_offset = view->border_right * view->border_thickness; | 494 | con->current.border_left * con->current.border_thickness; |
495 | right_offset = | ||
496 | con->current.border_right * con->current.border_thickness; | ||
495 | connects_sides = true; | 497 | connects_sides = true; |
496 | } | 498 | } |
497 | } | 499 | } |
@@ -612,15 +614,16 @@ static void render_titlebar(struct sway_output *output, | |||
612 | // Left pixel in line with bottom bar | 614 | // Left pixel in line with bottom bar |
613 | box.x = x; | 615 | box.x = x; |
614 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; | 616 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; |
615 | box.width = view->border_thickness * view->border_left; | 617 | box.width = con->current.border_thickness * con->current.border_left; |
616 | box.height = TITLEBAR_BORDER_THICKNESS; | 618 | box.height = TITLEBAR_BORDER_THICKNESS; |
617 | scale_box(&box, output_scale); | 619 | scale_box(&box, output_scale); |
618 | render_rect(output->wlr_output, output_damage, &box, color); | 620 | render_rect(output->wlr_output, output_damage, &box, color); |
619 | 621 | ||
620 | // Right pixel in line with bottom bar | 622 | // Right pixel in line with bottom bar |
621 | box.x = x + width - view->border_thickness * view->border_right; | 623 | box.x = x + width - |
624 | con->current.border_thickness * con->current.border_right; | ||
622 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; | 625 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; |
623 | box.width = view->border_thickness * view->border_right; | 626 | box.width = con->current.border_thickness * con->current.border_right; |
624 | box.height = TITLEBAR_BORDER_THICKNESS; | 627 | box.height = TITLEBAR_BORDER_THICKNESS; |
625 | scale_box(&box, output_scale); | 628 | scale_box(&box, output_scale); |
626 | render_rect(output->wlr_output, output_damage, &box, color); | 629 | render_rect(output->wlr_output, output_damage, &box, color); |
@@ -633,8 +636,7 @@ static void render_titlebar(struct sway_output *output, | |||
633 | static void render_top_border(struct sway_output *output, | 636 | static void render_top_border(struct sway_output *output, |
634 | pixman_region32_t *output_damage, struct sway_container *con, | 637 | pixman_region32_t *output_damage, struct sway_container *con, |
635 | struct border_colors *colors) { | 638 | struct border_colors *colors) { |
636 | struct sway_view *view = con->sway_view; | 639 | if (!con->current.border_top) { |
637 | if (!view->border_top) { | ||
638 | return; | 640 | return; |
639 | } | 641 | } |
640 | struct wlr_box box; | 642 | struct wlr_box box; |
@@ -644,10 +646,10 @@ static void render_top_border(struct sway_output *output, | |||
644 | // Child border - top edge | 646 | // Child border - top edge |
645 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 647 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
646 | premultiply_alpha(color, con->alpha); | 648 | premultiply_alpha(color, con->alpha); |
647 | box.x = con->x; | 649 | box.x = con->current.swayc_x; |
648 | box.y = con->y; | 650 | box.y = con->current.swayc_y; |
649 | box.width = con->width; | 651 | box.width = con->current.swayc_width; |
650 | box.height = view->border_thickness; | 652 | box.height = con->current.border_thickness; |
651 | scale_box(&box, output_scale); | 653 | scale_box(&box, output_scale); |
652 | render_rect(output->wlr_output, output_damage, &box, color); | 654 | render_rect(output->wlr_output, output_damage, &box, color); |
653 | } | 655 | } |
@@ -688,9 +690,10 @@ static void render_container_simple(struct sway_output *output, | |||
688 | marks_texture = child->sway_view->marks_unfocused; | 690 | marks_texture = child->sway_view->marks_unfocused; |
689 | } | 691 | } |
690 | 692 | ||
691 | if (child->sway_view->border == B_NORMAL) { | 693 | if (child->current.border == B_NORMAL) { |
692 | render_titlebar(output, damage, child, child->x, child->y, | 694 | render_titlebar(output, damage, child, child->current.swayc_x, |
693 | child->width, colors, title_texture, marks_texture); | 695 | child->current.swayc_y, child->current.swayc_width, |
696 | colors, title_texture, marks_texture); | ||
694 | } else { | 697 | } else { |
695 | render_top_border(output, damage, child, colors); | 698 | render_top_border(output, damage, child, colors); |
696 | } | 699 | } |
@@ -739,15 +742,15 @@ static void render_container_tabbed(struct sway_output *output, | |||
739 | marks_texture = view ? view->marks_unfocused : NULL; | 742 | marks_texture = view ? view->marks_unfocused : NULL; |
740 | } | 743 | } |
741 | 744 | ||
742 | int tab_width = con->width / con->children->length; | 745 | int tab_width = con->current.swayc_width / con->children->length; |
743 | int x = con->x + tab_width * i; | 746 | int x = con->current.swayc_x + tab_width * i; |
744 | // Make last tab use the remaining width of the parent | 747 | // Make last tab use the remaining width of the parent |
745 | if (i == con->children->length - 1) { | 748 | if (i == con->children->length - 1) { |
746 | tab_width = con->width - tab_width * i; | 749 | tab_width = con->current.swayc_width - tab_width * i; |
747 | } | 750 | } |
748 | 751 | ||
749 | render_titlebar(output, damage, child, x, child->y, tab_width, colors, | 752 | render_titlebar(output, damage, child, x, child->current.swayc_y, |
750 | title_texture, marks_texture); | 753 | tab_width, colors, title_texture, marks_texture); |
751 | 754 | ||
752 | if (child == current) { | 755 | if (child == current) { |
753 | current_colors = colors; | 756 | current_colors = colors; |