diff options
-rw-r--r-- | include/sway/tree/view.h | 9 | ||||
-rw-r--r-- | sway/desktop/output.c | 101 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 28 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 3 |
5 files changed, 76 insertions, 67 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index d0093db5..fc4c8df9 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -72,10 +72,11 @@ struct sway_view { | |||
72 | list_t *marks; // char * | 72 | list_t *marks; // char * |
73 | list_t *instructions; // struct sway_transaction_instruction * | 73 | list_t *instructions; // struct sway_transaction_instruction * |
74 | 74 | ||
75 | // If saved_texture is set, the main surface of the view will render this | 75 | // If saved_buffer is set, the main surface of the view will render this |
76 | // texture instead of its own. This is used while waiting for transactions | 76 | // buffer/texture instead of its own. This is used while waiting for |
77 | // to complete. | 77 | // transactions to complete. |
78 | struct wlr_texture *saved_texture; | 78 | struct wlr_buffer *saved_buffer; |
79 | int saved_surface_width, saved_surface_height; | ||
79 | 80 | ||
80 | struct wlr_texture *marks_focused; | 81 | struct wlr_texture *marks_focused; |
81 | struct wlr_texture *marks_focused_inactive; | 82 | struct wlr_texture *marks_focused_inactive; |
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; |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 07bfbf7a..77377a18 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <wlr/types/wlr_buffer.h> | ||
5 | #include <wlr/types/wlr_linux_dmabuf.h> | 6 | #include <wlr/types/wlr_linux_dmabuf.h> |
6 | #include "sway/debug.h" | 7 | #include "sway/debug.h" |
7 | #include "sway/desktop/transaction.h" | 8 | #include "sway/desktop/transaction.h" |
@@ -112,16 +113,23 @@ void transaction_add_damage(struct sway_transaction *transaction, | |||
112 | list_add(transaction->damage, box); | 113 | list_add(transaction->damage, box); |
113 | } | 114 | } |
114 | 115 | ||
115 | static void save_view_texture(struct sway_view *view) { | 116 | static void save_view_buffer(struct sway_view *view) { |
116 | wlr_texture_destroy(view->saved_texture); | 117 | if (view->saved_buffer) { |
117 | view->saved_texture = NULL; | 118 | wlr_buffer_unref(view->saved_buffer); |
118 | 119 | } | |
119 | // TODO: Copy the texture and store it in view->saved_texture. | 120 | wlr_buffer_ref(view->surface->buffer); |
121 | view->saved_buffer = view->surface->buffer; | ||
122 | view->saved_surface_width = view->surface->current->width; | ||
123 | view->saved_surface_height = view->surface->current->height; | ||
120 | } | 124 | } |
121 | 125 | ||
122 | static void remove_saved_view_texture(struct sway_view *view) { | 126 | static void remove_saved_view_buffer(struct sway_view *view) { |
123 | wlr_texture_destroy(view->saved_texture); | 127 | if (view->saved_buffer) { |
124 | view->saved_texture = NULL; | 128 | wlr_buffer_unref(view->saved_buffer); |
129 | view->saved_buffer = NULL; | ||
130 | view->saved_surface_width = 0; | ||
131 | view->saved_surface_height = 0; | ||
132 | } | ||
125 | } | 133 | } |
126 | 134 | ||
127 | /** | 135 | /** |
@@ -141,7 +149,7 @@ static void transaction_apply(struct sway_transaction *transaction) { | |||
141 | sizeof(struct sway_container_state)); | 149 | sizeof(struct sway_container_state)); |
142 | 150 | ||
143 | if (container->type == C_VIEW) { | 151 | if (container->type == C_VIEW) { |
144 | remove_saved_view_texture(container->sway_view); | 152 | remove_saved_view_buffer(container->sway_view); |
145 | } | 153 | } |
146 | } | 154 | } |
147 | 155 | ||
@@ -183,7 +191,7 @@ void transaction_commit(struct sway_transaction *transaction) { | |||
183 | instruction->state.view_width, | 191 | instruction->state.view_width, |
184 | instruction->state.view_height); | 192 | instruction->state.view_height); |
185 | if (instruction->serial) { | 193 | if (instruction->serial) { |
186 | save_view_texture(con->sway_view); | 194 | save_view_buffer(con->sway_view); |
187 | list_add(con->sway_view->instructions, instruction); | 195 | list_add(con->sway_view->instructions, instruction); |
188 | ++transaction->num_waiting; | 196 | ++transaction->num_waiting; |
189 | } | 197 | } |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 70929d48..55917bf6 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -261,8 +261,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
261 | view_update_size(view, view->swayc->width, view->swayc->height); | 261 | view_update_size(view, view->swayc->width, view->swayc->height); |
262 | } | 262 | } |
263 | view_update_position(view, view->x, view->y); | 263 | view_update_position(view, view->x, view->y); |
264 | view_damage_from(view); | ||
265 | } | 264 | } |
265 | view_damage_from(view); | ||
266 | } | 266 | } |
267 | 267 | ||
268 | static void handle_unmap(struct wl_listener *listener, void *data) { | 268 | static void handle_unmap(struct wl_listener *listener, void *data) { |
diff --git a/sway/tree/container.c b/sway/tree/container.c index f8620b72..b071f394 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -766,9 +766,6 @@ static void update_title_texture(struct sway_container *con, | |||
766 | "Unexpected type %s", container_type_to_str(con->type))) { | 766 | "Unexpected type %s", container_type_to_str(con->type))) { |
767 | return; | 767 | return; |
768 | } | 768 | } |
769 | if (!con->width) { | ||
770 | return; | ||
771 | } | ||
772 | struct sway_container *output = container_parent(con, C_OUTPUT); | 769 | struct sway_container *output = container_parent(con, C_OUTPUT); |
773 | if (!output) { | 770 | if (!output) { |
774 | return; | 771 | return; |