aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/container.h3
-rw-r--r--include/sway/tree/view.h4
-rw-r--r--sway/desktop/output.c83
-rw-r--r--sway/desktop/xdg_shell.c4
-rw-r--r--sway/desktop/xdg_shell_v6.c4
-rw-r--r--sway/desktop/xwayland.c28
-rw-r--r--sway/input/cursor.c14
-rw-r--r--sway/tree/arrange.c4
-rw-r--r--sway/tree/container.c42
-rw-r--r--sway/tree/view.c15
10 files changed, 71 insertions, 130 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index e4f74b08..4b686040 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -79,8 +79,7 @@ struct sway_container {
79 bool is_sticky; 79 bool is_sticky;
80 80
81 // For C_ROOT, this has no meaning 81 // For C_ROOT, this has no meaning
82 // For C_OUTPUT, this is the output position in layout coordinates 82 // For other types, this is the position in layout coordinates
83 // For other types, this is the position in output-local coordinates
84 // Includes borders 83 // Includes borders
85 double x, y; 84 double x, y;
86 double width, height; 85 double width, height;
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 7a94b2c2..65a23902 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -29,7 +29,7 @@ struct sway_view_impl {
29 const char *(*get_string_prop)(struct sway_view *view, 29 const char *(*get_string_prop)(struct sway_view *view,
30 enum sway_view_prop prop); 30 enum sway_view_prop prop);
31 uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); 31 uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
32 void (*configure)(struct sway_view *view, double ox, double oy, int width, 32 void (*configure)(struct sway_view *view, double lx, double ly, int width,
33 int height); 33 int height);
34 void (*set_activated)(struct sway_view *view, bool activated); 34 void (*set_activated)(struct sway_view *view, bool activated);
35 void (*set_tiled)(struct sway_view *view, bool tiled); 35 void (*set_tiled)(struct sway_view *view, bool tiled);
@@ -48,7 +48,7 @@ struct sway_view {
48 struct sway_container *swayc; // NULL for unmapped views 48 struct sway_container *swayc; // NULL for unmapped views
49 struct wlr_surface *surface; // NULL for unmapped views 49 struct wlr_surface *surface; // NULL for unmapped views
50 50
51 // Geometry of the view itself (excludes borders) 51 // Geometry of the view itself (excludes borders) in layout coordinates
52 double x, y; 52 double x, y;
53 int width, height; 53 int width, height;
54 54
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
68struct render_data {
69 struct root_geometry root_geo;
70 struct sway_output *output;
71 pixman_region32_t *damage;
72 float alpha;
73};
74
68static bool get_surface_box(struct root_geometry *geo, 75static 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,
116static void output_view_for_each_surface(struct sway_view *view, 123static 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
163struct render_data {
164 struct root_geometry root_geo;
165 struct sway_output *output;
166 pixman_region32_t *damage;
167 float alpha;
168};
169
170static void scissor_output(struct wlr_output *wlr_output, 171static 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
774static 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
788static void render_floating_container(struct sway_output *soutput, 782static 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
828static void render_floating(struct sway_output *soutput, 814static void render_floating(struct sway_output *soutput,
@@ -1123,15 +1109,7 @@ static void output_damage_view(struct sway_output *output,
1123 1109
1124void output_damage_from_view(struct sway_output *output, 1110void 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
1137static void output_damage_whole_container_iterator(struct sway_container *con, 1115static 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,
1148void output_damage_whole_container(struct sway_output *output, 1126void 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
1171static void damage_handle_destroy(struct wl_listener *listener, void *data) { 1138static void damage_handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 73d9477f..412488b3 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -87,7 +87,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
87 } 87 }
88} 88}
89 89
90static void configure(struct sway_view *view, double ox, double oy, int width, 90static void configure(struct sway_view *view, double lx, double ly, int width,
91 int height) { 91 int height) {
92 struct sway_xdg_shell_view *xdg_shell_view = 92 struct sway_xdg_shell_view *xdg_shell_view =
93 xdg_shell_view_from_view(view); 93 xdg_shell_view_from_view(view);
@@ -98,7 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
98 xdg_shell_view->pending_width = width; 98 xdg_shell_view->pending_width = width;
99 xdg_shell_view->pending_height = height; 99 xdg_shell_view->pending_height = height;
100 wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); 100 wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
101 view_update_position(view, ox, oy); 101 view_update_position(view, lx, ly);
102} 102}
103 103
104static void set_activated(struct sway_view *view, bool activated) { 104static void set_activated(struct sway_view *view, bool activated) {
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 6c98744c..b3653913 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -86,7 +86,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
86 } 86 }
87} 87}
88 88
89static void configure(struct sway_view *view, double ox, double oy, int width, 89static void configure(struct sway_view *view, double lx, double ly, int width,
90 int height) { 90 int height) {
91 struct sway_xdg_shell_v6_view *xdg_shell_v6_view = 91 struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
92 xdg_shell_v6_view_from_view(view); 92 xdg_shell_v6_view_from_view(view);
@@ -97,7 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
97 xdg_shell_v6_view->pending_width = width; 97 xdg_shell_v6_view->pending_width = width;
98 xdg_shell_v6_view->pending_height = height; 98 xdg_shell_v6_view->pending_height = height;
99 wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); 99 wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
100 view_update_position(view, ox, oy); 100 view_update_position(view, lx, ly);
101} 101}
102 102
103static void set_activated(struct sway_view *view, bool activated) { 103static void set_activated(struct sway_view *view, bool activated) {
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 783868bc..fc488162 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -152,9 +152,7 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
152 } 152 }
153} 153}
154 154
155// The x and y arguments are output-local for tiled views, and layout 155static void configure(struct sway_view *view, double lx, double ly, int width,
156// coordinates for floating views.
157static void configure(struct sway_view *view, double x, double y, int width,
158 int height) { 156 int height) {
159 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); 157 struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
160 if (xwayland_view == NULL) { 158 if (xwayland_view == NULL) {
@@ -162,30 +160,6 @@ static void configure(struct sway_view *view, double x, double y, int width,
162 } 160 }
163 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; 161 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
164 162
165 double lx, ly;
166 if (container_is_floating(view->swayc)) {
167 lx = x;
168 ly = y;
169 } else {
170 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
171 if (!sway_assert(output, "view must be within tree to set position")) {
172 return;
173 }
174 struct sway_container *root = container_parent(output, C_ROOT);
175 if (!sway_assert(root, "output must be within tree to set position")) {
176 return;
177 }
178 struct wlr_output_layout *layout = root->sway_root->output_layout;
179 struct wlr_output_layout_output *loutput =
180 wlr_output_layout_get(layout, output->sway_output->wlr_output);
181 if (!sway_assert(loutput,
182 "output must be within layout to set position")) {
183 return;
184 }
185 lx = x + loutput->x;
186 ly = y + loutput->y;
187 }
188
189 xwayland_view->pending_width = width; 163 xwayland_view->pending_width = width;
190 xwayland_view->pending_height = height; 164 xwayland_view->pending_height = height;
191 wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); 165 wlr_xwayland_surface_configure(xsurface, lx, ly, width, height);
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 96bf574c..16e5427b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -46,7 +46,7 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output,
46 * location, it is stored in **surface (it may not be a view). 46 * location, it is stored in **surface (it may not be a view).
47 */ 47 */
48static struct sway_container *container_at_coords( 48static struct sway_container *container_at_coords(
49 struct sway_seat *seat, double x, double y, 49 struct sway_seat *seat, double lx, double ly,
50 struct wlr_surface **surface, double *sx, double *sy) { 50 struct wlr_surface **surface, double *sx, double *sy) {
51 // check for unmanaged views first 51 // check for unmanaged views first
52 struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; 52 struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged;
@@ -55,8 +55,8 @@ static struct sway_container *container_at_coords(
55 struct wlr_xwayland_surface *xsurface = 55 struct wlr_xwayland_surface *xsurface =
56 unmanaged_surface->wlr_xwayland_surface; 56 unmanaged_surface->wlr_xwayland_surface;
57 57
58 double _sx = x - unmanaged_surface->lx; 58 double _sx = lx - unmanaged_surface->lx;
59 double _sy = y - unmanaged_surface->ly; 59 double _sy = ly - unmanaged_surface->ly;
60 if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { 60 if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) {
61 *surface = xsurface->surface; 61 *surface = xsurface->surface;
62 *sx = _sx; 62 *sx = _sx;
@@ -69,12 +69,12 @@ static struct sway_container *container_at_coords(
69 struct wlr_output_layout *output_layout = 69 struct wlr_output_layout *output_layout =
70 root_container.sway_root->output_layout; 70 root_container.sway_root->output_layout;
71 struct wlr_output *wlr_output = wlr_output_layout_output_at( 71 struct wlr_output *wlr_output = wlr_output_layout_output_at(
72 output_layout, x, y); 72 output_layout, lx, ly);
73 if (wlr_output == NULL) { 73 if (wlr_output == NULL) {
74 return NULL; 74 return NULL;
75 } 75 }
76 struct sway_output *output = wlr_output->data; 76 struct sway_output *output = wlr_output->data;
77 double ox = x, oy = y; 77 double ox = lx, oy = ly;
78 wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); 78 wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
79 79
80 // find the focused workspace on the output for this seat 80 // find the focused workspace on the output for this seat
@@ -108,10 +108,10 @@ static struct sway_container *container_at_coords(
108 } 108 }
109 109
110 struct sway_container *c; 110 struct sway_container *c;
111 if ((c = floating_container_at(x, y, surface, sx, sy))) { 111 if ((c = floating_container_at(lx, ly, surface, sx, sy))) {
112 return c; 112 return c;
113 } 113 }
114 if ((c = container_at(ws, ox, oy, surface, sx, sy))) { 114 if ((c = container_at(ws, lx, ly, surface, sx, sy))) {
115 return c; 115 return c;
116 } 116 }
117 117
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index da4f7889..721b557e 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -73,8 +73,8 @@ void arrange_workspace(struct sway_container *workspace) {
73 area->width, area->height, area->x, area->y); 73 area->width, area->height, area->x, area->y);
74 workspace->width = area->width; 74 workspace->width = area->width;
75 workspace->height = area->height; 75 workspace->height = area->height;
76 workspace->x = area->x; 76 workspace->x = output->x + area->x;
77 workspace->y = area->y; 77 workspace->y = output->y + area->y;
78 wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", 78 wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
79 workspace->name, workspace->x, workspace->y); 79 workspace->name, workspace->x, workspace->y);
80 arrange_children_of(workspace); 80 arrange_children_of(workspace);
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 12f74e37..7928ffc3 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -467,14 +467,14 @@ struct sway_container *container_parent(struct sway_container *container,
467} 467}
468 468
469static struct sway_container *container_at_view(struct sway_container *swayc, 469static struct sway_container *container_at_view(struct sway_container *swayc,
470 double ox, double oy, 470 double lx, double ly,
471 struct wlr_surface **surface, double *sx, double *sy) { 471 struct wlr_surface **surface, double *sx, double *sy) {
472 if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) { 472 if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) {
473 return NULL; 473 return NULL;
474 } 474 }
475 struct sway_view *sview = swayc->sway_view; 475 struct sway_view *sview = swayc->sway_view;
476 double view_sx = ox - sview->x; 476 double view_sx = lx - sview->x;
477 double view_sy = oy - sview->y; 477 double view_sy = ly - sview->y;
478 478
479 double _sx, _sy; 479 double _sx, _sy;
480 struct wlr_surface *_surface = NULL; 480 struct wlr_surface *_surface = NULL;
@@ -516,18 +516,18 @@ static struct sway_container *container_at_view(struct sway_container *swayc,
516 * container_at for a container with layout L_TABBED. 516 * container_at for a container with layout L_TABBED.
517 */ 517 */
518static struct sway_container *container_at_tabbed(struct sway_container *parent, 518static struct sway_container *container_at_tabbed(struct sway_container *parent,
519 double ox, double oy, 519 double lx, double ly,
520 struct wlr_surface **surface, double *sx, double *sy) { 520 struct wlr_surface **surface, double *sx, double *sy) {
521 if (oy < parent->y || oy > parent->y + parent->height) { 521 if (ly < parent->y || ly > parent->y + parent->height) {
522 return NULL; 522 return NULL;
523 } 523 }
524 struct sway_seat *seat = input_manager_current_seat(input_manager); 524 struct sway_seat *seat = input_manager_current_seat(input_manager);
525 525
526 // Tab titles 526 // Tab titles
527 int title_height = container_titlebar_height(); 527 int title_height = container_titlebar_height();
528 if (oy < parent->y + title_height) { 528 if (ly < parent->y + title_height) {
529 int tab_width = parent->width / parent->children->length; 529 int tab_width = parent->width / parent->children->length;
530 int child_index = (ox - parent->x) / tab_width; 530 int child_index = (lx - parent->x) / tab_width;
531 if (child_index >= parent->children->length) { 531 if (child_index >= parent->children->length) {
532 child_index = parent->children->length - 1; 532 child_index = parent->children->length - 1;
533 } 533 }
@@ -538,23 +538,23 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent,
538 // Surfaces 538 // Surfaces
539 struct sway_container *current = seat_get_active_child(seat, parent); 539 struct sway_container *current = seat_get_active_child(seat, parent);
540 540
541 return container_at(current, ox, oy, surface, sx, sy); 541 return container_at(current, lx, ly, surface, sx, sy);
542} 542}
543 543
544/** 544/**
545 * container_at for a container with layout L_STACKED. 545 * container_at for a container with layout L_STACKED.
546 */ 546 */
547static struct sway_container *container_at_stacked( 547static struct sway_container *container_at_stacked(
548 struct sway_container *parent, double ox, double oy, 548 struct sway_container *parent, double lx, double ly,
549 struct wlr_surface **surface, double *sx, double *sy) { 549 struct wlr_surface **surface, double *sx, double *sy) {
550 if (oy < parent->y || oy > parent->y + parent->height) { 550 if (ly < parent->y || ly > parent->y + parent->height) {
551 return NULL; 551 return NULL;
552 } 552 }
553 struct sway_seat *seat = input_manager_current_seat(input_manager); 553 struct sway_seat *seat = input_manager_current_seat(input_manager);
554 554
555 // Title bars 555 // Title bars
556 int title_height = container_titlebar_height(); 556 int title_height = container_titlebar_height();
557 int child_index = (oy - parent->y) / title_height; 557 int child_index = (ly - parent->y) / title_height;
558 if (child_index < parent->children->length) { 558 if (child_index < parent->children->length) {
559 struct sway_container *child = parent->children->items[child_index]; 559 struct sway_container *child = parent->children->items[child_index];
560 return seat_get_focus_inactive(seat, child); 560 return seat_get_focus_inactive(seat, child);
@@ -563,14 +563,14 @@ static struct sway_container *container_at_stacked(
563 // Surfaces 563 // Surfaces
564 struct sway_container *current = seat_get_active_child(seat, parent); 564 struct sway_container *current = seat_get_active_child(seat, parent);
565 565
566 return container_at(current, ox, oy, surface, sx, sy); 566 return container_at(current, lx, ly, surface, sx, sy);
567} 567}
568 568
569/** 569/**
570 * container_at for a container with layout L_HORIZ or L_VERT. 570 * container_at for a container with layout L_HORIZ or L_VERT.
571 */ 571 */
572static struct sway_container *container_at_linear(struct sway_container *parent, 572static struct sway_container *container_at_linear(struct sway_container *parent,
573 double ox, double oy, 573 double lx, double ly,
574 struct wlr_surface **surface, double *sx, double *sy) { 574 struct wlr_surface **surface, double *sx, double *sy) {
575 for (int i = 0; i < parent->children->length; ++i) { 575 for (int i = 0; i < parent->children->length; ++i) {
576 struct sway_container *child = parent->children->items[i]; 576 struct sway_container *child = parent->children->items[i];
@@ -580,22 +580,22 @@ static struct sway_container *container_at_linear(struct sway_container *parent,
580 .width = child->width, 580 .width = child->width,
581 .height = child->height, 581 .height = child->height,
582 }; 582 };
583 if (wlr_box_contains_point(&box, ox, oy)) { 583 if (wlr_box_contains_point(&box, lx, ly)) {
584 return container_at(child, ox, oy, surface, sx, sy); 584 return container_at(child, lx, ly, surface, sx, sy);
585 } 585 }
586 } 586 }
587 return NULL; 587 return NULL;
588} 588}
589 589
590struct sway_container *container_at(struct sway_container *parent, 590struct sway_container *container_at(struct sway_container *parent,
591 double ox, double oy, 591 double lx, double ly,
592 struct wlr_surface **surface, double *sx, double *sy) { 592 struct wlr_surface **surface, double *sx, double *sy) {
593 if (!sway_assert(parent->type >= C_WORKSPACE, 593 if (!sway_assert(parent->type >= C_WORKSPACE,
594 "Expected workspace or deeper")) { 594 "Expected workspace or deeper")) {
595 return NULL; 595 return NULL;
596 } 596 }
597 if (parent->type == C_VIEW) { 597 if (parent->type == C_VIEW) {
598 return container_at_view(parent, ox, oy, surface, sx, sy); 598 return container_at_view(parent, lx, ly, surface, sx, sy);
599 } 599 }
600 if (!parent->children->length) { 600 if (!parent->children->length) {
601 return NULL; 601 return NULL;
@@ -604,11 +604,11 @@ struct sway_container *container_at(struct sway_container *parent,
604 switch (parent->layout) { 604 switch (parent->layout) {
605 case L_HORIZ: 605 case L_HORIZ:
606 case L_VERT: 606 case L_VERT:
607 return container_at_linear(parent, ox, oy, surface, sx, sy); 607 return container_at_linear(parent, lx, ly, surface, sx, sy);
608 case L_TABBED: 608 case L_TABBED:
609 return container_at_tabbed(parent, ox, oy, surface, sx, sy); 609 return container_at_tabbed(parent, lx, ly, surface, sx, sy);
610 case L_STACKED: 610 case L_STACKED:
611 return container_at_stacked(parent, ox, oy, surface, sx, sy); 611 return container_at_stacked(parent, lx, ly, surface, sx, sy);
612 case L_FLOATING: 612 case L_FLOATING:
613 sway_assert(false, "Didn't expect to see floating here"); 613 sway_assert(false, "Didn't expect to see floating here");
614 return NULL; 614 return NULL;
@@ -837,7 +837,7 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe
837 lenient_strcat(buffer, "S["); 837 lenient_strcat(buffer, "S[");
838 break; 838 break;
839 case L_FLOATING: 839 case L_FLOATING:
840 strcpy(buffer, "F["); 840 lenient_strcat(buffer, "F[");
841 break; 841 break;
842 case L_NONE: 842 case L_NONE:
843 lenient_strcat(buffer, "D["); 843 lenient_strcat(buffer, "D[");
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 3de9879e..065d00db 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -119,10 +119,10 @@ const char *view_get_shell(struct sway_view *view) {
119 return "unknown"; 119 return "unknown";
120} 120}
121 121
122void view_configure(struct sway_view *view, double ox, double oy, int width, 122void view_configure(struct sway_view *view, double lx, double ly, int width,
123 int height) { 123 int height) {
124 if (view->impl->configure) { 124 if (view->impl->configure) {
125 view->impl->configure(view, ox, oy, width, height); 125 view->impl->configure(view, lx, ly, width, height);
126 } 126 }
127} 127}
128 128
@@ -134,9 +134,8 @@ static void view_autoconfigure_floating(struct sway_view *view) {
134 view->natural_width > max_width ? max_width : view->natural_width; 134 view->natural_width > max_width ? max_width : view->natural_width;
135 int height = 135 int height =
136 view->natural_height > max_height ? max_height : view->natural_height; 136 view->natural_height > max_height ? max_height : view->natural_height;
137 struct sway_container *output = ws->parent; 137 int lx = ws->x + (ws->width - width) / 2;
138 int lx = output->x + (ws->width - width) / 2; 138 int ly = ws->y + (ws->height - height) / 2;
139 int ly = output->y + (ws->height - height) / 2;
140 139
141 view->border_left = view->border_right = view->border_bottom = true; 140 view->border_left = view->border_right = view->border_bottom = true;
142 view_set_tiled(view, false); 141 view_set_tiled(view, false);
@@ -152,8 +151,7 @@ void view_autoconfigure(struct sway_view *view) {
152 struct sway_container *output = container_parent(view->swayc, C_OUTPUT); 151 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
153 152
154 if (view->is_fullscreen) { 153 if (view->is_fullscreen) {
155 view_configure(view, 0, 0, output->width, output->height); 154 view_configure(view, output->x, output->y, output->width, output->height);
156 view->x = view->y = 0;
157 return; 155 return;
158 } 156 }
159 157
@@ -560,6 +558,9 @@ void view_unmap(struct sway_view *view) {
560} 558}
561 559
562void view_update_position(struct sway_view *view, double lx, double ly) { 560void view_update_position(struct sway_view *view, double lx, double ly) {
561 if (view->x == lx && view->y == ly) {
562 return;
563 }
563 if (!container_is_floating(view->swayc)) { 564 if (!container_is_floating(view->swayc)) {
564 return; 565 return;
565 } 566 }