diff options
-rw-r--r-- | include/sway/tree/container.h | 10 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 3 | ||||
-rw-r--r-- | sway/commands/layout.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 7 | ||||
-rw-r--r-- | sway/commands/resize.c | 8 | ||||
-rw-r--r-- | sway/desktop/desktop.c | 2 | ||||
-rw-r--r-- | sway/desktop/output.c | 15 | ||||
-rw-r--r-- | sway/input/seat.c | 4 | ||||
-rw-r--r-- | sway/ipc-json.c | 8 | ||||
-rw-r--r-- | sway/tree/container.c | 8 | ||||
-rw-r--r-- | sway/tree/layout.c | 204 | ||||
-rw-r--r-- | sway/tree/view.c | 10 | ||||
-rw-r--r-- | sway/tree/workspace.c | 8 |
13 files changed, 145 insertions, 144 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e7a071be..4c60530f 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -68,10 +68,12 @@ struct sway_container { | |||
68 | enum sway_container_layout prev_layout; | 68 | enum sway_container_layout prev_layout; |
69 | enum sway_container_layout workspace_layout; | 69 | enum sway_container_layout workspace_layout; |
70 | 70 | ||
71 | // For C_ROOT, this is the extents of the whole layout box. | 71 | // For C_ROOT, this has no meaning |
72 | // For C_OUTPUT, this is the output position in layout coordinates. | 72 | // For C_OUTPUT, this is the output position in layout coordinates |
73 | // For other types, this is the position in output-local coordinates. | 73 | // For other types, this is the position in output-local coordinates |
74 | struct wlr_box box; | 74 | double x, y; |
75 | // does not include borders or gaps. | ||
76 | double width, height; | ||
75 | 77 | ||
76 | list_t *children; | 78 | list_t *children; |
77 | 79 | ||
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index b2b98ee4..fc5ce21f 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h | |||
@@ -61,7 +61,8 @@ enum sway_container_layout container_get_default_layout( | |||
61 | 61 | ||
62 | void container_sort_workspaces(struct sway_container *output); | 62 | void container_sort_workspaces(struct sway_container *output); |
63 | 63 | ||
64 | void arrange_windows(struct sway_container *container, int width, int height); | 64 | void arrange_windows(struct sway_container *container, |
65 | double width, double height); | ||
65 | 66 | ||
66 | struct sway_container *container_get_in_direction(struct sway_container | 67 | struct sway_container *container_get_in_direction(struct sway_container |
67 | *container, struct sway_seat *seat, enum movement_direction dir); | 68 | *container, struct sway_seat *seat, enum movement_direction dir); |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 162173c5..4c49a627 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -49,7 +49,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | arrange_windows(parent, parent->box.width, parent->box.height); | 52 | arrange_windows(parent, parent->width, parent->height); |
53 | 53 | ||
54 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 54 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
55 | } | 55 | } |
diff --git a/sway/commands/move.c b/sway/commands/move.c index e8668ce7..c954ab94 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -95,8 +95,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
95 | } | 95 | } |
96 | struct sway_container *source = container_parent(current, C_OUTPUT); | 96 | struct sway_container *source = container_parent(current, C_OUTPUT); |
97 | struct sway_container *destination = output_in_direction(argv[3], | 97 | struct sway_container *destination = output_in_direction(argv[3], |
98 | source->sway_output->wlr_output, | 98 | source->sway_output->wlr_output, current->x, current->y); |
99 | current->box.x, current->box.y); | ||
100 | if (!destination) { | 99 | if (!destination) { |
101 | return cmd_results_new(CMD_FAILURE, "move workspace", | 100 | return cmd_results_new(CMD_FAILURE, "move workspace", |
102 | "Can't find output with name/direction '%s'", argv[3]); | 101 | "Can't find output with name/direction '%s'", argv[3]); |
@@ -125,8 +124,8 @@ static struct cmd_results *cmd_move_workspace(struct sway_container *current, | |||
125 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 124 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |
126 | } | 125 | } |
127 | struct sway_container *source = container_parent(current, C_OUTPUT); | 126 | struct sway_container *source = container_parent(current, C_OUTPUT); |
128 | int center_x = current->box.width / 2 + current->box.x, | 127 | int center_x = current->width / 2 + current->x, |
129 | center_y = current->box.height / 2 + current->box.y; | 128 | center_y = current->height / 2 + current->y; |
130 | struct sway_container *destination = output_in_direction(argv[3], | 129 | struct sway_container *destination = output_in_direction(argv[3], |
131 | source->sway_output->wlr_output, center_x, center_y); | 130 | source->sway_output->wlr_output, center_x, center_y); |
132 | if (!destination) { | 131 | if (!destination) { |
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 8e295f65..93c1fe7d 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -48,11 +48,11 @@ static enum resize_axis parse_resize_axis(const char *axis) { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | static int parallel_coord(struct sway_container *c, enum resize_axis a) { | 50 | static int parallel_coord(struct sway_container *c, enum resize_axis a) { |
51 | return a == RESIZE_AXIS_HORIZONTAL ? c->box.x : c->box.y; | 51 | return a == RESIZE_AXIS_HORIZONTAL ? c->x : c->y; |
52 | } | 52 | } |
53 | 53 | ||
54 | static int parallel_size(struct sway_container *c, enum resize_axis a) { | 54 | static int parallel_size(struct sway_container *c, enum resize_axis a) { |
55 | return a == RESIZE_AXIS_HORIZONTAL ? c->box.width : c->box.height; | 55 | return a == RESIZE_AXIS_HORIZONTAL ? c->width : c->height; |
56 | } | 56 | } |
57 | 57 | ||
58 | static void resize_tiled(int amount, enum resize_axis axis) { | 58 | static void resize_tiled(int amount, enum resize_axis axis) { |
@@ -196,10 +196,10 @@ static void resize(int amount, enum resize_axis axis, enum resize_unit unit) { | |||
196 | float pct = amount / 100.0f; | 196 | float pct = amount / 100.0f; |
197 | switch (axis) { | 197 | switch (axis) { |
198 | case RESIZE_AXIS_HORIZONTAL: | 198 | case RESIZE_AXIS_HORIZONTAL: |
199 | amount = (float)current->box.width * pct; | 199 | amount = (float)current->width * pct; |
200 | break; | 200 | break; |
201 | case RESIZE_AXIS_VERTICAL: | 201 | case RESIZE_AXIS_VERTICAL: |
202 | amount = (float)current->box.height * pct; | 202 | amount = (float)current->height * pct; |
203 | break; | 203 | break; |
204 | default: | 204 | default: |
205 | sway_assert(0, "invalid resize axis"); | 205 | sway_assert(0, "invalid resize axis"); |
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c index f0a14445..3a13191f 100644 --- a/sway/desktop/desktop.c +++ b/sway/desktop/desktop.c | |||
@@ -8,7 +8,7 @@ void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, | |||
8 | struct sway_container *cont = root_container.children->items[i]; | 8 | struct sway_container *cont = root_container.children->items[i]; |
9 | if (cont->type == C_OUTPUT) { | 9 | if (cont->type == C_OUTPUT) { |
10 | output_damage_whole_surface(cont->sway_output, | 10 | output_damage_whole_surface(cont->sway_output, |
11 | lx - cont->box.x, ly - cont->box.y, surface); | 11 | lx - cont->x, ly - cont->y, surface); |
12 | } | 12 | } |
13 | } | 13 | } |
14 | } | 14 | } |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 49ffe74c..aa18f1b8 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -192,22 +192,17 @@ static void render_view(struct sway_container *view, void *data) { | |||
192 | int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry.x; | 192 | int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry.x; |
193 | int window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry.y; | 193 | int window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry.y; |
194 | render_surface(surface, wlr_output, when, | 194 | render_surface(surface, wlr_output, when, |
195 | view->box.x - window_offset_x, | 195 | view->x - window_offset_x, view->y - window_offset_y, 0, alpha); |
196 | view->box.y - window_offset_y, | 196 | render_xdg_v6_popups(sway_view->wlr_xdg_surface_v6, wlr_output, |
197 | 0, alpha); | 197 | when, view->x - window_offset_x, view->y - window_offset_y, 0, alpha); |
198 | render_xdg_v6_popups(sway_view->wlr_xdg_surface_v6, wlr_output, when, | ||
199 | view->box.x - window_offset_x, | ||
200 | view->box.y - window_offset_y, | ||
201 | 0, alpha); | ||
202 | break; | 198 | break; |
203 | } | 199 | } |
204 | case SWAY_VIEW_WL_SHELL: | 200 | case SWAY_VIEW_WL_SHELL: |
205 | render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output, | 201 | render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output, |
206 | when, view->box.x, view->box.y, 0, alpha, false); | 202 | when, view->x, view->y, 0, alpha, false); |
207 | break; | 203 | break; |
208 | case SWAY_VIEW_XWAYLAND: | 204 | case SWAY_VIEW_XWAYLAND: |
209 | render_surface(surface, wlr_output, when, | 205 | render_surface(surface, wlr_output, when, view->x, view->y, 0, alpha); |
210 | view->box.x, view->box.y, 0, alpha); | ||
211 | break; | 206 | break; |
212 | } | 207 | } |
213 | } | 208 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 44a471bd..ad3584a0 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -415,8 +415,8 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
415 | if (new_output && last_output && new_output != last_output | 415 | if (new_output && last_output && new_output != last_output |
416 | && config->mouse_warping && warp) { | 416 | && config->mouse_warping && warp) { |
417 | struct wlr_output *output = new_output->sway_output->wlr_output; | 417 | struct wlr_output *output = new_output->sway_output->wlr_output; |
418 | int x = container->box.x + output->lx + container->box.width / 2; | 418 | double x = container->x + output->lx + container->width / 2.0; |
419 | int y = container->box.y + output->ly + container->box.height / 2; | 419 | double y = container->y + output->ly + container->height / 2.0; |
420 | if (!wlr_output_layout_contains_point( | 420 | if (!wlr_output_layout_contains_point( |
421 | root_container.sway_root->output_layout, | 421 | root_container.sway_root->output_layout, |
422 | output, seat->cursor->cursor->x, seat->cursor->cursor->y)) { | 422 | output, seat->cursor->cursor->x, seat->cursor->cursor->y)) { |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 951adada..f9c6c90b 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -47,10 +47,10 @@ json_object *ipc_json_get_version() { | |||
47 | static json_object *ipc_json_create_rect(struct sway_container *c) { | 47 | static json_object *ipc_json_create_rect(struct sway_container *c) { |
48 | json_object *rect = json_object_new_object(); | 48 | json_object *rect = json_object_new_object(); |
49 | 49 | ||
50 | json_object_object_add(rect, "x", json_object_new_int(c->box.x)); | 50 | json_object_object_add(rect, "x", json_object_new_int((int32_t)c->x)); |
51 | json_object_object_add(rect, "y", json_object_new_int(c->box.y)); | 51 | json_object_object_add(rect, "y", json_object_new_int((int32_t)c->y)); |
52 | json_object_object_add(rect, "width", json_object_new_int(c->box.width)); | 52 | json_object_object_add(rect, "width", json_object_new_int((int32_t)c->width)); |
53 | json_object_object_add(rect, "height", json_object_new_int(c->box.height)); | 53 | json_object_object_add(rect, "height", json_object_new_int((int32_t)c->height)); |
54 | 54 | ||
55 | return rect; | 55 | return rect; |
56 | } | 56 | } |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 04fcee81..ab8363bc 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -333,8 +333,8 @@ struct sway_container *container_view_create(struct sway_container *sibling, | |||
333 | // Setup values | 333 | // Setup values |
334 | swayc->sway_view = sway_view; | 334 | swayc->sway_view = sway_view; |
335 | swayc->name = title ? strdup(title) : NULL; | 335 | swayc->name = title ? strdup(title) : NULL; |
336 | swayc->box.width = 0; | 336 | swayc->width = 0; |
337 | swayc->box.height = 0; | 337 | swayc->height = 0; |
338 | 338 | ||
339 | if (sibling->type == C_WORKSPACE) { | 339 | if (sibling->type == C_WORKSPACE) { |
340 | // Case of focused workspace, just create as child of it | 340 | // Case of focused workspace, just create as child of it |
@@ -418,8 +418,8 @@ struct sway_container *container_at(struct sway_container *parent, | |||
418 | soutput->sway_output->wlr_output); | 418 | soutput->sway_output->wlr_output); |
419 | double ox = lx - output_box->x; | 419 | double ox = lx - output_box->x; |
420 | double oy = ly - output_box->y; | 420 | double oy = ly - output_box->y; |
421 | double view_sx = ox - swayc->box.x; | 421 | double view_sx = ox - swayc->x; |
422 | double view_sy = oy - swayc->box.y; | 422 | double view_sy = oy - swayc->y; |
423 | 423 | ||
424 | double _sx, _sy; | 424 | double _sx, _sy; |
425 | struct wlr_surface *_surface; | 425 | struct wlr_surface *_surface; |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 9580d3a7..343f349a 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -24,10 +24,10 @@ static void output_layout_handle_change(struct wl_listener *listener, | |||
24 | root_container.sway_root->output_layout; | 24 | root_container.sway_root->output_layout; |
25 | const struct wlr_box *layout_box = | 25 | const struct wlr_box *layout_box = |
26 | wlr_output_layout_get_box(output_layout, NULL); | 26 | wlr_output_layout_get_box(output_layout, NULL); |
27 | root_container.box.x = layout_box->x; | 27 | root_container.x = layout_box->x; |
28 | root_container.box.y = layout_box->y; | 28 | root_container.y = layout_box->y; |
29 | root_container.box.width = layout_box->width; | 29 | root_container.width = layout_box->width; |
30 | root_container.box.height = layout_box->height; | 30 | root_container.height = layout_box->height; |
31 | 31 | ||
32 | for (int i = 0 ; i < root_container.children->length; ++i) { | 32 | for (int i = 0 ; i < root_container.children->length; ++i) { |
33 | struct sway_container *output_container = | 33 | struct sway_container *output_container = |
@@ -42,10 +42,10 @@ static void output_layout_handle_change(struct wl_listener *listener, | |||
42 | if (!output_box) { | 42 | if (!output_box) { |
43 | continue; | 43 | continue; |
44 | } | 44 | } |
45 | output_container->box.x = output_box->x; | 45 | output_container->x = output_box->x; |
46 | output_container->box.y = output_box->y; | 46 | output_container->y = output_box->y; |
47 | output_container->box.width = output_box->width; | 47 | output_container->width = output_box->width; |
48 | output_container->box.height = output_box->height; | 48 | output_container->height = output_box->height; |
49 | } | 49 | } |
50 | 50 | ||
51 | arrange_windows(&root_container, -1, -1); | 51 | arrange_windows(&root_container, -1, -1); |
@@ -112,9 +112,9 @@ struct sway_container *container_add_sibling(struct sway_container *fixed, | |||
112 | 112 | ||
113 | void container_add_child(struct sway_container *parent, | 113 | void container_add_child(struct sway_container *parent, |
114 | struct sway_container *child) { | 114 | struct sway_container *child) { |
115 | wlr_log(L_DEBUG, "Adding id:%zd (%d, %dx%d) to id:%zd (%d, %dx%d)", | 115 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", |
116 | child->id, child->type, child->box.width, child->box.height, | 116 | child, child->type, child->width, child->height, |
117 | parent->id, parent->type, parent->box.width, parent->box.height); | 117 | parent, parent->type, parent->width, parent->height); |
118 | list_add(parent->children, child); | 118 | list_add(parent->children, child); |
119 | child->parent = parent; | 119 | child->parent = parent; |
120 | } | 120 | } |
@@ -138,7 +138,7 @@ void container_move_to(struct sway_container *container, | |||
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | struct sway_container *old_parent = container_remove_child(container); | 140 | struct sway_container *old_parent = container_remove_child(container); |
141 | container->box.width = container->box.height = 0; | 141 | container->width = container->height = 0; |
142 | struct sway_container *new_parent; | 142 | struct sway_container *new_parent; |
143 | if (destination->type == C_VIEW) { | 143 | if (destination->type == C_VIEW) { |
144 | new_parent = container_add_sibling(destination, container); | 144 | new_parent = container_add_sibling(destination, container); |
@@ -187,10 +187,11 @@ enum sway_container_layout container_get_default_layout( | |||
187 | return config->default_layout; | 187 | return config->default_layout; |
188 | } else if (config->default_orientation != L_NONE) { | 188 | } else if (config->default_orientation != L_NONE) { |
189 | return config->default_orientation; | 189 | return config->default_orientation; |
190 | } else if (con->box.width >= con->box.height) { | 190 | } else if (con->width >= con->height) { |
191 | return L_HORIZ; | 191 | return L_HORIZ; |
192 | } else { | ||
193 | return L_VERT; | ||
192 | } | 194 | } |
193 | return L_VERT; | ||
194 | } | 195 | } |
195 | 196 | ||
196 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | 197 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { |
@@ -215,23 +216,25 @@ void container_sort_workspaces(struct sway_container *output) { | |||
215 | list_stable_sort(output->children, sort_workspace_cmp_qsort); | 216 | list_stable_sort(output->children, sort_workspace_cmp_qsort); |
216 | } | 217 | } |
217 | 218 | ||
218 | static void apply_horiz_layout(struct sway_container *container, | 219 | static void apply_horiz_layout(struct sway_container *container, const double x, |
219 | const int x, const int y, const int width, | 220 | const double y, const double width, |
220 | const int height, const int start, const int end); | 221 | const double height, const int start, |
222 | const int end); | ||
221 | 223 | ||
222 | static void apply_vert_layout(struct sway_container *container, | 224 | static void apply_vert_layout(struct sway_container *container, const double x, |
223 | const int x, const int y, const int width, | 225 | const double y, const double width, |
224 | const int height, const int start, const int end); | 226 | const double height, const int start, |
227 | const int end); | ||
225 | 228 | ||
226 | void arrange_windows(struct sway_container *container, | 229 | void arrange_windows(struct sway_container *container, |
227 | int width, int height) { | 230 | double width, double height) { |
228 | if (config->reloading) { | 231 | if (config->reloading) { |
229 | return; | 232 | return; |
230 | } | 233 | } |
231 | int i; | 234 | int i; |
232 | if (width == -1 || height == -1) { | 235 | if (width == -1 || height == -1) { |
233 | width = container->box.width; | 236 | width = container->width; |
234 | height = container->box.height; | 237 | height = container->height; |
235 | } | 238 | } |
236 | // pixels are indivisible. if we don't round the pixels, then the view | 239 | // pixels are indivisible. if we don't round the pixels, then the view |
237 | // calculations will be off (e.g. 50.5 + 50.5 = 101, but in reality it's | 240 | // calculations will be off (e.g. 50.5 + 50.5 = 101, but in reality it's |
@@ -239,17 +242,17 @@ void arrange_windows(struct sway_container *container, | |||
239 | width = floor(width); | 242 | width = floor(width); |
240 | height = floor(height); | 243 | height = floor(height); |
241 | 244 | ||
242 | wlr_log(L_DEBUG, "Arranging layout for %p %s %dx%d+%d,%d", container, | 245 | wlr_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", container, |
243 | container->name, container->box.width, container->box.height, | 246 | container->name, container->width, container->height, container->x, |
244 | container->box.x, container->box.y); | 247 | container->y); |
245 | 248 | ||
246 | int x = 0, y = 0; | 249 | double x = 0, y = 0; |
247 | switch (container->type) { | 250 | switch (container->type) { |
248 | case C_ROOT: | 251 | case C_ROOT: |
249 | for (i = 0; i < container->children->length; ++i) { | 252 | for (i = 0; i < container->children->length; ++i) { |
250 | struct sway_container *output = container->children->items[i]; | 253 | struct sway_container *output = container->children->items[i]; |
251 | wlr_log(L_DEBUG, "Arranging output '%s' at %d,%d", | 254 | wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", |
252 | output->name, output->box.x, output->box.y); | 255 | output->name, output->x, output->y); |
253 | arrange_windows(output, -1, -1); | 256 | arrange_windows(output, -1, -1); |
254 | } | 257 | } |
255 | return; | 258 | return; |
@@ -258,8 +261,8 @@ void arrange_windows(struct sway_container *container, | |||
258 | int _width, _height; | 261 | int _width, _height; |
259 | wlr_output_effective_resolution( | 262 | wlr_output_effective_resolution( |
260 | container->sway_output->wlr_output, &_width, &_height); | 263 | container->sway_output->wlr_output, &_width, &_height); |
261 | width = container->box.width = _width; | 264 | width = container->width = _width; |
262 | height = container->box.height = _height; | 265 | height = container->height = _height; |
263 | } | 266 | } |
264 | // arrange all workspaces: | 267 | // arrange all workspaces: |
265 | for (i = 0; i < container->children->length; ++i) { | 268 | for (i = 0; i < container->children->length; ++i) { |
@@ -274,32 +277,31 @@ void arrange_windows(struct sway_container *container, | |||
274 | struct wlr_box *area = &output->sway_output->usable_area; | 277 | struct wlr_box *area = &output->sway_output->usable_area; |
275 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", | 278 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", |
276 | area->width, area->height, area->x, area->y); | 279 | area->width, area->height, area->x, area->y); |
277 | container->box.width = width = area->width; | 280 | container->width = width = area->width; |
278 | container->box.height = height = area->height; | 281 | container->height = height = area->height; |
279 | container->box.x = x = area->x; | 282 | container->x = x = area->x; |
280 | container->box.y = y = area->y; | 283 | container->y = y = area->y; |
281 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %d,%d", | 284 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", |
282 | container->name, container->box.x, container->box.y); | 285 | container->name, container->x, container->y); |
283 | } | 286 | } |
284 | // children are properly handled below | 287 | // children are properly handled below |
285 | break; | 288 | break; |
286 | case C_VIEW: | 289 | case C_VIEW: |
287 | { | 290 | { |
288 | container->box.width = width; | 291 | container->width = width; |
289 | container->box.height = height; | 292 | container->height = height; |
290 | view_configure(container->sway_view, | 293 | view_configure(container->sway_view, container->x, container->y, |
291 | container->box.x, container->box.y, | 294 | container->width, container->height); |
292 | container->box.width, container->box.height); | 295 | wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f", |
293 | wlr_log(L_DEBUG, "Set view to %d x %d @ %d, %d", | 296 | container->width, container->height, |
294 | container->box.width, container->box.height, | 297 | container->x, container->y); |
295 | container->box.x, container->box.y); | ||
296 | } | 298 | } |
297 | return; | 299 | return; |
298 | default: | 300 | default: |
299 | container->box.width = width; | 301 | container->width = width; |
300 | container->box.height = height; | 302 | container->height = height; |
301 | x = container->box.x; | 303 | x = container->x; |
302 | y = container->box.y; | 304 | y = container->y; |
303 | break; | 305 | break; |
304 | } | 306 | } |
305 | 307 | ||
@@ -321,49 +323,50 @@ void arrange_windows(struct sway_container *container, | |||
321 | } | 323 | } |
322 | 324 | ||
323 | static void apply_horiz_layout(struct sway_container *container, | 325 | static void apply_horiz_layout(struct sway_container *container, |
324 | const int x, const int y, const int width, const int height, | 326 | const double x, const double y, |
327 | const double width, const double height, | ||
325 | const int start, const int end) { | 328 | const int start, const int end) { |
326 | double scale = 0; | 329 | double scale = 0; |
327 | // Calculate total width | 330 | // Calculate total width |
328 | for (int i = start; i < end; ++i) { | 331 | for (int i = start; i < end; ++i) { |
329 | struct sway_container *child = container->children->items[i]; | 332 | double *old_width = |
330 | int old_width = child->box.width; | 333 | &((struct sway_container *)container->children->items[i])->width; |
331 | if (old_width <= 0) { | 334 | if (*old_width <= 0) { |
332 | if (end - start > 1) { | 335 | if (end - start > 1) { |
333 | old_width = width / (end - start - 1); | 336 | *old_width = width / (end - start - 1); |
334 | } else { | 337 | } else { |
335 | old_width = width; | 338 | *old_width = width; |
336 | } | 339 | } |
337 | } | 340 | } |
338 | scale += old_width; | 341 | scale += *old_width; |
339 | } | 342 | } |
340 | scale = width / scale; | 343 | scale = width / scale; |
341 | 344 | ||
342 | // Resize windows | 345 | // Resize windows |
343 | int child_x = x; | 346 | double child_x = x; |
344 | if (scale > 0.1) { | 347 | if (scale > 0.1) { |
345 | wlr_log(L_DEBUG, "Arranging %p horizontally", container); | 348 | wlr_log(L_DEBUG, "Arranging %p horizontally", container); |
346 | for (int i = start; i < end; ++i) { | 349 | for (int i = start; i < end; ++i) { |
347 | struct sway_container *child = container->children->items[i]; | 350 | struct sway_container *child = container->children->items[i]; |
348 | wlr_log(L_DEBUG, | 351 | wlr_log(L_DEBUG, |
349 | "Calculating arrangement for %p:%d (will scale %d by %f)", | 352 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
350 | child, child->type, width, scale); | 353 | child, child->type, width, scale); |
351 | 354 | ||
352 | if (child->type == C_VIEW) { | 355 | if (child->type == C_VIEW) { |
353 | view_configure(child->sway_view, child_x, y, | 356 | view_configure(child->sway_view, child_x, y, child->width, |
354 | child->box.width, child->box.height); | 357 | child->height); |
355 | } else { | 358 | } else { |
356 | child->box.x = child_x; | 359 | child->x = child_x; |
357 | child->box.y = y; | 360 | child->y = y; |
358 | } | 361 | } |
359 | 362 | ||
360 | if (i == end - 1) { | 363 | if (i == end - 1) { |
361 | int remaining_width = x + width - child_x; | 364 | double remaining_width = x + width - child_x; |
362 | arrange_windows(child, remaining_width, height); | 365 | arrange_windows(child, remaining_width, height); |
363 | } else { | 366 | } else { |
364 | arrange_windows(child, child->box.width * scale, height); | 367 | arrange_windows(child, child->width * scale, height); |
365 | } | 368 | } |
366 | child_x += child->box.width; | 369 | child_x += child->width; |
367 | } | 370 | } |
368 | 371 | ||
369 | // update focused view border last because it may | 372 | // update focused view border last because it may |
@@ -377,49 +380,50 @@ static void apply_horiz_layout(struct sway_container *container, | |||
377 | } | 380 | } |
378 | 381 | ||
379 | void apply_vert_layout(struct sway_container *container, | 382 | void apply_vert_layout(struct sway_container *container, |
380 | const int x, const int y, const int width, const int height, | 383 | const double x, const double y, |
381 | const int start, const int end) { | 384 | const double width, const double height, const int start, |
385 | const int end) { | ||
382 | int i; | 386 | int i; |
383 | double scale = 0; | 387 | double scale = 0; |
384 | // Calculate total height | 388 | // Calculate total height |
385 | for (i = start; i < end; ++i) { | 389 | for (i = start; i < end; ++i) { |
386 | struct sway_container *child = container->children->items[i]; | 390 | double *old_height = |
387 | int old_height = child->box.height; | 391 | &((struct sway_container *)container->children->items[i])->height; |
388 | if (old_height <= 0) { | 392 | if (*old_height <= 0) { |
389 | if (end - start > 1) { | 393 | if (end - start > 1) { |
390 | old_height = height / (end - start - 1); | 394 | *old_height = height / (end - start - 1); |
391 | } else { | 395 | } else { |
392 | old_height = height; | 396 | *old_height = height; |
393 | } | 397 | } |
394 | } | 398 | } |
395 | scale += old_height; | 399 | scale += *old_height; |
396 | } | 400 | } |
397 | scale = height / scale; | 401 | scale = height / scale; |
398 | 402 | ||
399 | // Resize | 403 | // Resize |
400 | int child_y = y; | 404 | double child_y = y; |
401 | if (scale > 0.1) { | 405 | if (scale > 0.1) { |
402 | wlr_log(L_DEBUG, "Arranging %p vertically", container); | 406 | wlr_log(L_DEBUG, "Arranging %p vertically", container); |
403 | for (i = start; i < end; ++i) { | 407 | for (i = start; i < end; ++i) { |
404 | struct sway_container *child = container->children->items[i]; | 408 | struct sway_container *child = container->children->items[i]; |
405 | wlr_log(L_DEBUG, | 409 | wlr_log(L_DEBUG, |
406 | "Calculating arrangement for %p:%d (will scale %d by %f)", | 410 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
407 | child, child->type, height, scale); | 411 | child, child->type, height, scale); |
408 | if (child->type == C_VIEW) { | 412 | if (child->type == C_VIEW) { |
409 | view_configure(child->sway_view, x, child_y, | 413 | view_configure(child->sway_view, x, child_y, child->width, |
410 | child->box.width, child->box.height); | 414 | child->height); |
411 | } else { | 415 | } else { |
412 | child->box.x = x; | 416 | child->x = x; |
413 | child->box.y = child_y; | 417 | child->y = child_y; |
414 | } | 418 | } |
415 | 419 | ||
416 | if (i == end - 1) { | 420 | if (i == end - 1) { |
417 | int remaining_height = y + height - child_y; | 421 | double remaining_height = y + height - child_y; |
418 | arrange_windows(child, width, remaining_height); | 422 | arrange_windows(child, width, remaining_height); |
419 | } else { | 423 | } else { |
420 | arrange_windows(child, width, child->box.height * scale); | 424 | arrange_windows(child, width, child->height * scale); |
421 | } | 425 | } |
422 | child_y += child->box.height; | 426 | child_y += child->height; |
423 | } | 427 | } |
424 | 428 | ||
425 | // update focused view border last because it may | 429 | // update focused view border last because it may |
@@ -492,18 +496,18 @@ static void get_layout_center_position(struct sway_container *container, | |||
492 | int *x, int *y) { | 496 | int *x, int *y) { |
493 | // FIXME view coords are inconsistently referred to in layout/output systems | 497 | // FIXME view coords are inconsistently referred to in layout/output systems |
494 | if (container->type == C_OUTPUT) { | 498 | if (container->type == C_OUTPUT) { |
495 | *x = container->box.x + container->box.width / 2; | 499 | *x = container->x + container->width/2; |
496 | *y = container->box.y + container->box.height / 2; | 500 | *y = container->y + container->height/2; |
497 | } else { | 501 | } else { |
498 | struct sway_container *output = container_parent(container, C_OUTPUT); | 502 | struct sway_container *output = container_parent(container, C_OUTPUT); |
499 | if (container->type == C_WORKSPACE) { | 503 | if (container->type == C_WORKSPACE) { |
500 | // Workspace coordinates are actually wrong/arbitrary, but should | 504 | // Workspace coordinates are actually wrong/arbitrary, but should |
501 | // be same as output. | 505 | // be same as output. |
502 | *x = output->box.x; | 506 | *x = output->x; |
503 | *y = output->box.y; | 507 | *y = output->y; |
504 | } else { | 508 | } else { |
505 | *x = output->box.x + container->box.x; | 509 | *x = output->x + container->x; |
506 | *y = output->box.y + container->box.y; | 510 | *y = output->y + container->y; |
507 | } | 511 | } |
508 | } | 512 | } |
509 | } | 513 | } |
@@ -674,14 +678,14 @@ struct sway_container *container_replace_child(struct sway_container *child, | |||
674 | child->parent = NULL; | 678 | child->parent = NULL; |
675 | 679 | ||
676 | // Set geometry for new child | 680 | // Set geometry for new child |
677 | new_child->box.x = child->box.x; | 681 | new_child->x = child->x; |
678 | new_child->box.y = child->box.y; | 682 | new_child->y = child->y; |
679 | new_child->box.width = child->box.width; | 683 | new_child->width = child->width; |
680 | new_child->box.height = child->box.height; | 684 | new_child->height = child->height; |
681 | 685 | ||
682 | // reset geometry for child | 686 | // reset geometry for child |
683 | child->box.width = 0; | 687 | child->width = 0; |
684 | child->box.height = 0; | 688 | child->height = 0; |
685 | 689 | ||
686 | return parent; | 690 | return parent; |
687 | } | 691 | } |
@@ -697,10 +701,10 @@ struct sway_container *container_split(struct sway_container *child, | |||
697 | wlr_log(L_DEBUG, "creating container %p around %p", cont, child); | 701 | wlr_log(L_DEBUG, "creating container %p around %p", cont, child); |
698 | 702 | ||
699 | cont->prev_layout = L_NONE; | 703 | cont->prev_layout = L_NONE; |
700 | cont->box.width = child->box.width; | 704 | cont->width = child->width; |
701 | cont->box.height = child->box.height; | 705 | cont->height = child->height; |
702 | cont->box.x = child->box.x; | 706 | cont->x = child->x; |
703 | cont->box.y = child->box.y; | 707 | cont->y = child->y; |
704 | 708 | ||
705 | if (child->type == C_WORKSPACE) { | 709 | if (child->type == C_WORKSPACE) { |
706 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 710 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); |
@@ -733,10 +737,10 @@ void container_recursive_resize(struct sway_container *container, | |||
733 | bool layout_match = true; | 737 | bool layout_match = true; |
734 | wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount); | 738 | wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount); |
735 | if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) { | 739 | if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) { |
736 | container->box.width += amount; | 740 | container->width += amount; |
737 | layout_match = container->layout == L_HORIZ; | 741 | layout_match = container->layout == L_HORIZ; |
738 | } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) { | 742 | } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) { |
739 | container->box.height += amount; | 743 | container->height += amount; |
740 | layout_match = container->layout == L_VERT; | 744 | layout_match = container->layout == L_VERT; |
741 | } | 745 | } |
742 | if (container->children) { | 746 | if (container->children) { |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 8ceb0d6c..9855c5e1 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -96,8 +96,8 @@ void view_damage_from(struct sway_view *view) { | |||
96 | static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { | 96 | static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { |
97 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 97 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
98 | 98 | ||
99 | box->x = output->box.x + view->swayc->box.x; | 99 | box->x = output->x + view->swayc->x; |
100 | box->y = output->box.y + view->swayc->box.y; | 100 | box->y = output->y + view->swayc->y; |
101 | box->width = view->width; | 101 | box->width = view->width; |
102 | box->height = view->height; | 102 | box->height = view->height; |
103 | } | 103 | } |
@@ -216,13 +216,13 @@ void view_unmap(struct sway_view *view) { | |||
216 | } | 216 | } |
217 | 217 | ||
218 | void view_update_position(struct sway_view *view, double ox, double oy) { | 218 | void view_update_position(struct sway_view *view, double ox, double oy) { |
219 | if (view->swayc->box.x == ox && view->swayc->box.y == oy) { | 219 | if (view->swayc->x == ox && view->swayc->y == oy) { |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | 222 | ||
223 | view_damage_whole(view); | 223 | view_damage_whole(view); |
224 | view->swayc->box.x = ox; | 224 | view->swayc->x = ox; |
225 | view->swayc->box.y = oy; | 225 | view->swayc->y = oy; |
226 | view_damage_whole(view); | 226 | view_damage_whole(view); |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 9e1a8a37..316f01e4 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -50,10 +50,10 @@ struct sway_container *workspace_create(struct sway_container *output, | |||
50 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); | 50 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); |
51 | struct sway_container *workspace = container_create(C_WORKSPACE); | 51 | struct sway_container *workspace = container_create(C_WORKSPACE); |
52 | 52 | ||
53 | workspace->box.x = output->box.x; | 53 | workspace->x = output->x; |
54 | workspace->box.y = output->box.y; | 54 | workspace->y = output->y; |
55 | workspace->box.width = output->box.width; | 55 | workspace->width = output->width; |
56 | workspace->box.height = output->box.height; | 56 | workspace->height = output->height; |
57 | workspace->name = !name ? NULL : strdup(name); | 57 | workspace->name = !name ? NULL : strdup(name); |
58 | workspace->prev_layout = L_NONE; | 58 | workspace->prev_layout = L_NONE; |
59 | workspace->layout = container_get_default_layout(output); | 59 | workspace->layout = container_get_default_layout(output); |