diff options
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 83 |
1 files changed, 25 insertions, 58 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index fb80fd87..8600d049 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -65,6 +65,13 @@ struct root_geometry { | |||
65 | float rotation; | 65 | float rotation; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct render_data { | ||
69 | struct root_geometry root_geo; | ||
70 | struct sway_output *output; | ||
71 | pixman_region32_t *damage; | ||
72 | float alpha; | ||
73 | }; | ||
74 | |||
68 | static bool get_surface_box(struct root_geometry *geo, | 75 | static bool get_surface_box(struct root_geometry *geo, |
69 | struct sway_output *output, struct wlr_surface *surface, int sx, int sy, | 76 | struct sway_output *output, struct wlr_surface *surface, int sx, int sy, |
70 | struct wlr_box *surface_box) { | 77 | struct wlr_box *surface_box) { |
@@ -116,8 +123,9 @@ static void surface_for_each_surface(struct wlr_surface *surface, | |||
116 | static void output_view_for_each_surface(struct sway_view *view, | 123 | static void output_view_for_each_surface(struct sway_view *view, |
117 | struct root_geometry *geo, wlr_surface_iterator_func_t iterator, | 124 | struct root_geometry *geo, wlr_surface_iterator_func_t iterator, |
118 | void *user_data) { | 125 | void *user_data) { |
119 | geo->x = view->x; | 126 | struct render_data *data = user_data; |
120 | geo->y = view->y; | 127 | geo->x = view->x - data->output->wlr_output->lx; |
128 | geo->y = view->y - data->output->wlr_output->ly; | ||
121 | geo->width = view->surface->current->width; | 129 | geo->width = view->surface->current->width; |
122 | geo->height = view->surface->current->height; | 130 | geo->height = view->surface->current->height; |
123 | geo->rotation = 0; // TODO | 131 | geo->rotation = 0; // TODO |
@@ -160,13 +168,6 @@ static void scale_box(struct wlr_box *box, float scale) { | |||
160 | box->height *= scale; | 168 | box->height *= scale; |
161 | } | 169 | } |
162 | 170 | ||
163 | struct render_data { | ||
164 | struct root_geometry root_geo; | ||
165 | struct sway_output *output; | ||
166 | pixman_region32_t *damage; | ||
167 | float alpha; | ||
168 | }; | ||
169 | |||
170 | static void scissor_output(struct wlr_output *wlr_output, | 171 | static void scissor_output(struct wlr_output *wlr_output, |
171 | pixman_box32_t *rect) { | 172 | pixman_box32_t *rect) { |
172 | struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); | 173 | struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); |
@@ -275,7 +276,10 @@ static void render_rect(struct wlr_output *wlr_output, | |||
275 | struct wlr_renderer *renderer = | 276 | struct wlr_renderer *renderer = |
276 | wlr_backend_get_renderer(wlr_output->backend); | 277 | wlr_backend_get_renderer(wlr_output->backend); |
277 | 278 | ||
278 | struct wlr_box box = *_box; | 279 | struct wlr_box box; |
280 | memcpy(&box, _box, sizeof(struct wlr_box)); | ||
281 | box.x -= wlr_output->lx * wlr_output->scale; | ||
282 | box.y -= wlr_output->ly * wlr_output->scale; | ||
279 | 283 | ||
280 | pixman_region32_t damage; | 284 | pixman_region32_t damage; |
281 | pixman_region32_init(&damage); | 285 | pixman_region32_init(&damage); |
@@ -450,8 +454,10 @@ static void render_titlebar(struct sway_output *output, | |||
450 | wlr_texture_get_size(marks_texture, | 454 | wlr_texture_get_size(marks_texture, |
451 | &texture_box.width, &texture_box.height); | 455 | &texture_box.width, &texture_box.height); |
452 | texture_box.x = | 456 | texture_box.x = |
453 | (x + width - TITLEBAR_H_PADDING) * output_scale - texture_box.width; | 457 | (x - output->wlr_output->lx + width - TITLEBAR_H_PADDING) |
454 | texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; | 458 | * output_scale - texture_box.width; |
459 | texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) | ||
460 | * output_scale; | ||
455 | 461 | ||
456 | float matrix[9]; | 462 | float matrix[9]; |
457 | wlr_matrix_project_box(matrix, &texture_box, | 463 | wlr_matrix_project_box(matrix, &texture_box, |
@@ -472,8 +478,10 @@ static void render_titlebar(struct sway_output *output, | |||
472 | struct wlr_box texture_box; | 478 | struct wlr_box texture_box; |
473 | wlr_texture_get_size(title_texture, | 479 | wlr_texture_get_size(title_texture, |
474 | &texture_box.width, &texture_box.height); | 480 | &texture_box.width, &texture_box.height); |
475 | texture_box.x = (x + TITLEBAR_H_PADDING) * output_scale; | 481 | texture_box.x = (x - output->wlr_output->lx + TITLEBAR_H_PADDING) |
476 | texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; | 482 | * output_scale; |
483 | texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) | ||
484 | * output_scale; | ||
477 | 485 | ||
478 | float matrix[9]; | 486 | float matrix[9]; |
479 | wlr_matrix_project_box(matrix, &texture_box, | 487 | wlr_matrix_project_box(matrix, &texture_box, |
@@ -771,28 +779,8 @@ static bool floater_intersects_output(struct sway_container *floater, | |||
771 | output->sway_output->wlr_output, &box); | 779 | output->sway_output->wlr_output, &box); |
772 | } | 780 | } |
773 | 781 | ||
774 | static void container_translate(struct sway_container *con, int x, int y) { | ||
775 | con->x += x; | ||
776 | con->y += y; | ||
777 | if (con->type == C_VIEW) { | ||
778 | con->sway_view->x += x; | ||
779 | con->sway_view->y += y; | ||
780 | } else { | ||
781 | for (int i = 0; i < con->children->length; ++i) { | ||
782 | struct sway_container *child = con->children->items[i]; | ||
783 | container_translate(child, x, y); | ||
784 | } | ||
785 | } | ||
786 | } | ||
787 | |||
788 | static void render_floating_container(struct sway_output *soutput, | 782 | static void render_floating_container(struct sway_output *soutput, |
789 | pixman_region32_t *damage, struct sway_container *con) { | 783 | pixman_region32_t *damage, struct sway_container *con) { |
790 | // We need to translate the floating container's coordinates from layout | ||
791 | // coordinates into output-local coordinates. This needs to happen for all | ||
792 | // children of the floating container too. | ||
793 | struct sway_container *output = container_parent(con, C_OUTPUT); | ||
794 | container_translate(con, -output->x, -output->y); | ||
795 | |||
796 | if (con->type == C_VIEW) { | 784 | if (con->type == C_VIEW) { |
797 | struct sway_view *view = con->sway_view; | 785 | struct sway_view *view = con->sway_view; |
798 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 786 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
@@ -821,8 +809,6 @@ static void render_floating_container(struct sway_output *soutput, | |||
821 | } else { | 809 | } else { |
822 | render_container(soutput, damage, con, false); | 810 | render_container(soutput, damage, con, false); |
823 | } | 811 | } |
824 | // Undo the translation | ||
825 | container_translate(con, output->x, output->y); | ||
826 | } | 812 | } |
827 | 813 | ||
828 | static void render_floating(struct sway_output *soutput, | 814 | static void render_floating(struct sway_output *soutput, |
@@ -1123,15 +1109,7 @@ static void output_damage_view(struct sway_output *output, | |||
1123 | 1109 | ||
1124 | void output_damage_from_view(struct sway_output *output, | 1110 | void output_damage_from_view(struct sway_output *output, |
1125 | struct sway_view *view) { | 1111 | struct sway_view *view) { |
1126 | if (container_self_or_parent_floating(view->swayc)) { | 1112 | output_damage_view(output, view, false); |
1127 | view->x -= output->swayc->x; | ||
1128 | view->y -= output->swayc->y; | ||
1129 | output_damage_view(output, view, false); | ||
1130 | view->x += output->swayc->x; | ||
1131 | view->y += output->swayc->y; | ||
1132 | } else { | ||
1133 | output_damage_view(output, view, false); | ||
1134 | } | ||
1135 | } | 1113 | } |
1136 | 1114 | ||
1137 | static void output_damage_whole_container_iterator(struct sway_container *con, | 1115 | static void output_damage_whole_container_iterator(struct sway_container *con, |
@@ -1148,24 +1126,13 @@ static void output_damage_whole_container_iterator(struct sway_container *con, | |||
1148 | void output_damage_whole_container(struct sway_output *output, | 1126 | void output_damage_whole_container(struct sway_output *output, |
1149 | struct sway_container *con) { | 1127 | struct sway_container *con) { |
1150 | struct wlr_box box = { | 1128 | struct wlr_box box = { |
1151 | .x = con->x, | 1129 | .x = con->x - output->wlr_output->lx, |
1152 | .y = con->y, | 1130 | .y = con->y - output->wlr_output->ly, |
1153 | .width = con->width, | 1131 | .width = con->width, |
1154 | .height = con->height, | 1132 | .height = con->height, |
1155 | }; | 1133 | }; |
1156 | if (container_is_floating(con)) { | ||
1157 | box.x -= output->wlr_output->lx; | ||
1158 | box.y -= output->wlr_output->ly; | ||
1159 | } | ||
1160 | scale_box(&box, output->wlr_output->scale); | 1134 | scale_box(&box, output->wlr_output->scale); |
1161 | wlr_output_damage_add_box(output->damage, &box); | 1135 | wlr_output_damage_add_box(output->damage, &box); |
1162 | |||
1163 | if (con->type == C_VIEW) { | ||
1164 | output_damage_whole_container_iterator(con, output); | ||
1165 | } else { | ||
1166 | container_descendants(con, C_VIEW, | ||
1167 | output_damage_whole_container_iterator, output); | ||
1168 | } | ||
1169 | } | 1136 | } |
1170 | 1137 | ||
1171 | static void damage_handle_destroy(struct wl_listener *listener, void *data) { | 1138 | static void damage_handle_destroy(struct wl_listener *listener, void *data) { |