diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-16 22:41:10 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 10:39:38 +1000 |
commit | 982a2d0c99f4128a7cf2236ca190dd9b4e6d7828 (patch) | |
tree | 3106f8f05af455924abfadb2893e0c3599b465c9 | |
parent | Add view_get_geometry (diff) | |
download | sway-982a2d0c99f4128a7cf2236ca190dd9b4e6d7828.tar.gz sway-982a2d0c99f4128a7cf2236ca190dd9b4e6d7828.tar.zst sway-982a2d0c99f4128a7cf2236ca190dd9b4e6d7828.zip |
Fix geometry
-rw-r--r-- | include/sway/tree/view.h | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 8 | ||||
-rw-r--r-- | sway/desktop/render.c | 10 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 41 | ||||
-rw-r--r-- | sway/tree/container.c | 5 |
5 files changed, 57 insertions, 10 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 1ded601c..0e7f166c 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -88,6 +88,7 @@ struct sway_view { | |||
88 | 88 | ||
89 | struct wlr_buffer *saved_buffer; | 89 | struct wlr_buffer *saved_buffer; |
90 | int saved_buffer_width, saved_buffer_height; | 90 | int saved_buffer_width, saved_buffer_height; |
91 | struct wlr_box saved_geometry; // The "old" geometry during a transaction | ||
91 | 92 | ||
92 | bool destroying; | 93 | bool destroying; |
93 | 94 | ||
@@ -242,6 +243,8 @@ const char *view_get_shell(struct sway_view *view); | |||
242 | void view_get_constraints(struct sway_view *view, double *min_width, | 243 | void view_get_constraints(struct sway_view *view, double *min_width, |
243 | double *max_width, double *min_height, double *max_height); | 244 | double *max_width, double *min_height, double *max_height); |
244 | 245 | ||
246 | void view_get_geometry(struct sway_view *view, struct wlr_box *box); | ||
247 | |||
245 | uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | 248 | uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, |
246 | int height); | 249 | int height); |
247 | 250 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 66747a3f..cb0b4a07 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -140,12 +140,16 @@ void output_surface_for_each_surface(struct sway_output *output, | |||
140 | void output_view_for_each_surface(struct sway_output *output, | 140 | void output_view_for_each_surface(struct sway_output *output, |
141 | struct sway_view *view, sway_surface_iterator_func_t iterator, | 141 | struct sway_view *view, sway_surface_iterator_func_t iterator, |
142 | void *user_data) { | 142 | void *user_data) { |
143 | struct wlr_box geometry; | ||
144 | view_get_geometry(view, &geometry); | ||
143 | struct surface_iterator_data data = { | 145 | struct surface_iterator_data data = { |
144 | .user_iterator = iterator, | 146 | .user_iterator = iterator, |
145 | .user_data = user_data, | 147 | .user_data = user_data, |
146 | .output = output, | 148 | .output = output, |
147 | .ox = view->swayc->current.view_x - output->swayc->current.swayc_x, | 149 | .ox = view->swayc->current.view_x - output->swayc->current.swayc_x |
148 | .oy = view->swayc->current.view_y - output->swayc->current.swayc_y, | 150 | - geometry.x, |
151 | .oy = view->swayc->current.view_y - output->swayc->current.swayc_y | ||
152 | - geometry.y, | ||
149 | .width = view->swayc->current.view_width, | 153 | .width = view->swayc->current.view_width, |
150 | .height = view->swayc->current.view_height, | 154 | .height = view->swayc->current.view_height, |
151 | .rotation = 0, // TODO | 155 | .rotation = 0, // TODO |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 6e1e31f0..93fcfbf4 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -192,10 +192,12 @@ static void render_view_toplevels(struct sway_view *view, | |||
192 | .damage = damage, | 192 | .damage = damage, |
193 | .alpha = alpha, | 193 | .alpha = alpha, |
194 | }; | 194 | }; |
195 | struct wlr_box geometry; | ||
196 | view_get_geometry(view, &geometry); | ||
195 | // Render all toplevels without descending into popups | 197 | // Render all toplevels without descending into popups |
196 | output_surface_for_each_surface(output, view->surface, | 198 | output_surface_for_each_surface(output, view->surface, |
197 | view->swayc->current.view_x - output->wlr_output->lx, | 199 | view->swayc->current.view_x - output->wlr_output->lx - geometry.x, |
198 | view->swayc->current.view_y - output->wlr_output->ly, | 200 | view->swayc->current.view_y - output->wlr_output->ly - geometry.y, |
199 | render_surface_iterator, &data); | 201 | render_surface_iterator, &data); |
200 | } | 202 | } |
201 | 203 | ||
@@ -232,6 +234,10 @@ static void render_saved_view(struct sway_view *view, | |||
232 | .width = view->saved_buffer_width, | 234 | .width = view->saved_buffer_width, |
233 | .height = view->saved_buffer_height, | 235 | .height = view->saved_buffer_height, |
234 | }; | 236 | }; |
237 | struct wlr_box geometry; | ||
238 | view_get_geometry(view, &geometry); | ||
239 | box.x -= geometry.x; | ||
240 | box.y -= geometry.y; | ||
235 | 241 | ||
236 | struct wlr_box output_box = { | 242 | struct wlr_box output_box = { |
237 | .width = output->swayc->current.swayc_width, | 243 | .width = output->swayc->current.swayc_width, |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index e89f01d8..7383c455 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -170,23 +170,49 @@ static void transaction_apply(struct sway_transaction *transaction) { | |||
170 | struct sway_container *container = instruction->container; | 170 | struct sway_container *container = instruction->container; |
171 | 171 | ||
172 | // Damage the old and new locations | 172 | // Damage the old and new locations |
173 | struct wlr_box old_box = { | 173 | struct wlr_box old_con_box = { |
174 | .x = container->current.swayc_x, | 174 | .x = container->current.swayc_x, |
175 | .y = container->current.swayc_y, | 175 | .y = container->current.swayc_y, |
176 | .width = container->current.swayc_width, | 176 | .width = container->current.swayc_width, |
177 | .height = container->current.swayc_height, | 177 | .height = container->current.swayc_height, |
178 | }; | 178 | }; |
179 | struct wlr_box new_box = { | 179 | struct wlr_box new_con_box = { |
180 | .x = instruction->state.swayc_x, | 180 | .x = instruction->state.swayc_x, |
181 | .y = instruction->state.swayc_y, | 181 | .y = instruction->state.swayc_y, |
182 | .width = instruction->state.swayc_width, | 182 | .width = instruction->state.swayc_width, |
183 | .height = instruction->state.swayc_height, | 183 | .height = instruction->state.swayc_height, |
184 | }; | 184 | }; |
185 | // Handle geometry, which may overflow the bounds of the container | ||
186 | struct wlr_box old_surface_box = {0,0,0,0}; | ||
187 | struct wlr_box new_surface_box = {0,0,0,0}; | ||
188 | if (container->type == C_VIEW) { | ||
189 | struct sway_view *view = container->sway_view; | ||
190 | if (container->sway_view->saved_buffer) { | ||
191 | old_surface_box.x = | ||
192 | container->current.view_x - view->saved_geometry.x; | ||
193 | old_surface_box.y = | ||
194 | container->current.view_y - view->saved_geometry.y; | ||
195 | old_surface_box.width = view->saved_buffer_width; | ||
196 | old_surface_box.height = view->saved_buffer_height; | ||
197 | } | ||
198 | struct wlr_surface *surface = container->sway_view->surface; | ||
199 | if (surface) { | ||
200 | struct wlr_box geometry; | ||
201 | view_get_geometry(view, &geometry); | ||
202 | new_surface_box.x = instruction->state.view_x - geometry.x; | ||
203 | new_surface_box.y = instruction->state.view_y - geometry.y; | ||
204 | new_surface_box.width = surface->current.width; | ||
205 | new_surface_box.height = surface->current.height; | ||
206 | } | ||
207 | } | ||
185 | for (int j = 0; j < root_container.current.children->length; ++j) { | 208 | for (int j = 0; j < root_container.current.children->length; ++j) { |
186 | struct sway_container *output = root_container.current.children->items[j]; | 209 | struct sway_container *output = |
210 | root_container.current.children->items[j]; | ||
187 | if (output->sway_output) { | 211 | if (output->sway_output) { |
188 | output_damage_box(output->sway_output, &old_box); | 212 | output_damage_box(output->sway_output, &old_con_box); |
189 | output_damage_box(output->sway_output, &new_box); | 213 | output_damage_box(output->sway_output, &new_con_box); |
214 | output_damage_box(output->sway_output, &old_surface_box); | ||
215 | output_damage_box(output->sway_output, &new_surface_box); | ||
190 | } | 216 | } |
191 | } | 217 | } |
192 | 218 | ||
@@ -297,6 +323,7 @@ static void transaction_commit(struct sway_transaction *transaction) { | |||
297 | } | 323 | } |
298 | if (con->type == C_VIEW) { | 324 | if (con->type == C_VIEW) { |
299 | view_save_buffer(con->sway_view); | 325 | view_save_buffer(con->sway_view); |
326 | view_get_geometry(con->sway_view, &con->sway_view->saved_geometry); | ||
300 | } | 327 | } |
301 | con->instruction = instruction; | 328 | con->instruction = instruction; |
302 | } | 329 | } |
@@ -355,7 +382,9 @@ static void set_instruction_ready( | |||
355 | } | 382 | } |
356 | 383 | ||
357 | instruction->container->instruction = NULL; | 384 | instruction->container->instruction = NULL; |
358 | transaction_progress_queue(); | 385 | if (!txn_debug) { |
386 | transaction_progress_queue(); | ||
387 | } | ||
359 | } | 388 | } |
360 | 389 | ||
361 | void transaction_notify_view_ready_by_serial(struct sway_view *view, | 390 | void transaction_notify_view_ready_by_serial(struct sway_view *view, |
diff --git a/sway/tree/container.c b/sway/tree/container.c index db780270..1dc4be4b 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -525,6 +525,11 @@ static void surface_at_view(struct sway_container *swayc, double lx, double ly, | |||
525 | double view_sx = lx - sview->x; | 525 | double view_sx = lx - sview->x; |
526 | double view_sy = ly - sview->y; | 526 | double view_sy = ly - sview->y; |
527 | 527 | ||
528 | struct wlr_box geometry; | ||
529 | view_get_geometry(sview, &geometry); | ||
530 | view_sx += geometry.x; | ||
531 | view_sy += geometry.y; | ||
532 | |||
528 | double _sx, _sy; | 533 | double _sx, _sy; |
529 | struct wlr_surface *_surface = NULL; | 534 | struct wlr_surface *_surface = NULL; |
530 | switch (sview->type) { | 535 | switch (sview->type) { |