Store swayc coordinates as layout-local

This commit is contained in:
Ryan Dwyer 2018-05-26 16:26:10 +10:00
parent 00f6e179cd
commit e4e912ea91
10 changed files with 71 additions and 130 deletions

View file

@ -79,8 +79,7 @@ struct sway_container {
bool is_sticky; bool is_sticky;
// For C_ROOT, this has no meaning // For C_ROOT, this has no meaning
// For C_OUTPUT, this is the output position in layout coordinates // For other types, this is the position in layout coordinates
// For other types, this is the position in output-local coordinates
// Includes borders // Includes borders
double x, y; double x, y;
double width, height; double width, height;

View file

@ -29,7 +29,7 @@ struct sway_view_impl {
const char *(*get_string_prop)(struct sway_view *view, const char *(*get_string_prop)(struct sway_view *view,
enum sway_view_prop prop); enum sway_view_prop prop);
uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
void (*configure)(struct sway_view *view, double ox, double oy, int width, void (*configure)(struct sway_view *view, double lx, double ly, int width,
int height); int height);
void (*set_activated)(struct sway_view *view, bool activated); void (*set_activated)(struct sway_view *view, bool activated);
void (*set_tiled)(struct sway_view *view, bool tiled); void (*set_tiled)(struct sway_view *view, bool tiled);
@ -48,7 +48,7 @@ struct sway_view {
struct sway_container *swayc; // NULL for unmapped views struct sway_container *swayc; // NULL for unmapped views
struct wlr_surface *surface; // NULL for unmapped views struct wlr_surface *surface; // NULL for unmapped views
// Geometry of the view itself (excludes borders) // Geometry of the view itself (excludes borders) in layout coordinates
double x, y; double x, y;
int width, height; int width, height;

View file

@ -65,6 +65,13 @@ struct root_geometry {
float rotation; float rotation;
}; };
struct render_data {
struct root_geometry root_geo;
struct sway_output *output;
pixman_region32_t *damage;
float alpha;
};
static bool get_surface_box(struct root_geometry *geo, static bool get_surface_box(struct root_geometry *geo,
struct sway_output *output, struct wlr_surface *surface, int sx, int sy, struct sway_output *output, struct wlr_surface *surface, int sx, int sy,
struct wlr_box *surface_box) { struct wlr_box *surface_box) {
@ -116,8 +123,9 @@ static void surface_for_each_surface(struct wlr_surface *surface,
static void output_view_for_each_surface(struct sway_view *view, static void output_view_for_each_surface(struct sway_view *view,
struct root_geometry *geo, wlr_surface_iterator_func_t iterator, struct root_geometry *geo, wlr_surface_iterator_func_t iterator,
void *user_data) { void *user_data) {
geo->x = view->x; struct render_data *data = user_data;
geo->y = view->y; geo->x = view->x - data->output->wlr_output->lx;
geo->y = view->y - data->output->wlr_output->ly;
geo->width = view->surface->current->width; geo->width = view->surface->current->width;
geo->height = view->surface->current->height; geo->height = view->surface->current->height;
geo->rotation = 0; // TODO geo->rotation = 0; // TODO
@ -160,13 +168,6 @@ static void scale_box(struct wlr_box *box, float scale) {
box->height *= scale; box->height *= scale;
} }
struct render_data {
struct root_geometry root_geo;
struct sway_output *output;
pixman_region32_t *damage;
float alpha;
};
static void scissor_output(struct wlr_output *wlr_output, static void scissor_output(struct wlr_output *wlr_output,
pixman_box32_t *rect) { pixman_box32_t *rect) {
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
@ -275,7 +276,10 @@ static void render_rect(struct wlr_output *wlr_output,
struct wlr_renderer *renderer = struct wlr_renderer *renderer =
wlr_backend_get_renderer(wlr_output->backend); wlr_backend_get_renderer(wlr_output->backend);
struct wlr_box box = *_box; struct wlr_box box;
memcpy(&box, _box, sizeof(struct wlr_box));
box.x -= wlr_output->lx * wlr_output->scale;
box.y -= wlr_output->ly * wlr_output->scale;
pixman_region32_t damage; pixman_region32_t damage;
pixman_region32_init(&damage); pixman_region32_init(&damage);
@ -450,8 +454,10 @@ static void render_titlebar(struct sway_output *output,
wlr_texture_get_size(marks_texture, wlr_texture_get_size(marks_texture,
&texture_box.width, &texture_box.height); &texture_box.width, &texture_box.height);
texture_box.x = texture_box.x =
(x + width - TITLEBAR_H_PADDING) * output_scale - texture_box.width; (x - output->wlr_output->lx + width - TITLEBAR_H_PADDING)
texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; * output_scale - texture_box.width;
texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING)
* output_scale;
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, &texture_box, wlr_matrix_project_box(matrix, &texture_box,
@ -472,8 +478,10 @@ static void render_titlebar(struct sway_output *output,
struct wlr_box texture_box; struct wlr_box texture_box;
wlr_texture_get_size(title_texture, wlr_texture_get_size(title_texture,
&texture_box.width, &texture_box.height); &texture_box.width, &texture_box.height);
texture_box.x = (x + TITLEBAR_H_PADDING) * output_scale; texture_box.x = (x - output->wlr_output->lx + TITLEBAR_H_PADDING)
texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; * output_scale;
texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING)
* output_scale;
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, &texture_box, wlr_matrix_project_box(matrix, &texture_box,
@ -771,28 +779,8 @@ static bool floater_intersects_output(struct sway_container *floater,
output->sway_output->wlr_output, &box); output->sway_output->wlr_output, &box);
} }
static void container_translate(struct sway_container *con, int x, int y) {
con->x += x;
con->y += y;
if (con->type == C_VIEW) {
con->sway_view->x += x;
con->sway_view->y += y;
} else {
for (int i = 0; i < con->children->length; ++i) {
struct sway_container *child = con->children->items[i];
container_translate(child, x, y);
}
}
}
static void render_floating_container(struct sway_output *soutput, static void render_floating_container(struct sway_output *soutput,
pixman_region32_t *damage, struct sway_container *con) { pixman_region32_t *damage, struct sway_container *con) {
// We need to translate the floating container's coordinates from layout
// coordinates into output-local coordinates. This needs to happen for all
// children of the floating container too.
struct sway_container *output = container_parent(con, C_OUTPUT);
container_translate(con, -output->x, -output->y);
if (con->type == C_VIEW) { if (con->type == C_VIEW) {
struct sway_view *view = con->sway_view; struct sway_view *view = con->sway_view;
struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_seat *seat = input_manager_current_seat(input_manager);
@ -821,8 +809,6 @@ static void render_floating_container(struct sway_output *soutput,
} else { } else {
render_container(soutput, damage, con, false); render_container(soutput, damage, con, false);
} }
// Undo the translation
container_translate(con, output->x, output->y);
} }
static void render_floating(struct sway_output *soutput, static void render_floating(struct sway_output *soutput,
@ -1123,15 +1109,7 @@ static void output_damage_view(struct sway_output *output,
void output_damage_from_view(struct sway_output *output, void output_damage_from_view(struct sway_output *output,
struct sway_view *view) { struct sway_view *view) {
if (container_self_or_parent_floating(view->swayc)) { output_damage_view(output, view, false);
view->x -= output->swayc->x;
view->y -= output->swayc->y;
output_damage_view(output, view, false);
view->x += output->swayc->x;
view->y += output->swayc->y;
} else {
output_damage_view(output, view, false);
}
} }
static void output_damage_whole_container_iterator(struct sway_container *con, 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,
void output_damage_whole_container(struct sway_output *output, void output_damage_whole_container(struct sway_output *output,
struct sway_container *con) { struct sway_container *con) {
struct wlr_box box = { struct wlr_box box = {
.x = con->x, .x = con->x - output->wlr_output->lx,
.y = con->y, .y = con->y - output->wlr_output->ly,
.width = con->width, .width = con->width,
.height = con->height, .height = con->height,
}; };
if (container_is_floating(con)) {
box.x -= output->wlr_output->lx;
box.y -= output->wlr_output->ly;
}
scale_box(&box, output->wlr_output->scale); scale_box(&box, output->wlr_output->scale);
wlr_output_damage_add_box(output->damage, &box); wlr_output_damage_add_box(output->damage, &box);
if (con->type == C_VIEW) {
output_damage_whole_container_iterator(con, output);
} else {
container_descendants(con, C_VIEW,
output_damage_whole_container_iterator, output);
}
} }
static void damage_handle_destroy(struct wl_listener *listener, void *data) { static void damage_handle_destroy(struct wl_listener *listener, void *data) {

View file

@ -87,7 +87,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
} }
} }
static void configure(struct sway_view *view, double ox, double oy, int width, static void configure(struct sway_view *view, double lx, double ly, int width,
int height) { int height) {
struct sway_xdg_shell_view *xdg_shell_view = struct sway_xdg_shell_view *xdg_shell_view =
xdg_shell_view_from_view(view); xdg_shell_view_from_view(view);
@ -98,7 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
xdg_shell_view->pending_width = width; xdg_shell_view->pending_width = width;
xdg_shell_view->pending_height = height; xdg_shell_view->pending_height = height;
wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
view_update_position(view, ox, oy); view_update_position(view, lx, ly);
} }
static void set_activated(struct sway_view *view, bool activated) { static void set_activated(struct sway_view *view, bool activated) {

View file

@ -86,7 +86,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
} }
} }
static void configure(struct sway_view *view, double ox, double oy, int width, static void configure(struct sway_view *view, double lx, double ly, int width,
int height) { int height) {
struct sway_xdg_shell_v6_view *xdg_shell_v6_view = struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
xdg_shell_v6_view_from_view(view); xdg_shell_v6_view_from_view(view);
@ -97,7 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
xdg_shell_v6_view->pending_width = width; xdg_shell_v6_view->pending_width = width;
xdg_shell_v6_view->pending_height = height; xdg_shell_v6_view->pending_height = height;
wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
view_update_position(view, ox, oy); view_update_position(view, lx, ly);
} }
static void set_activated(struct sway_view *view, bool activated) { static void set_activated(struct sway_view *view, bool activated) {

View file

@ -152,9 +152,7 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
} }
} }
// The x and y arguments are output-local for tiled views, and layout static void configure(struct sway_view *view, double lx, double ly, int width,
// coordinates for floating views.
static void configure(struct sway_view *view, double x, double y, int width,
int height) { int height) {
struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
if (xwayland_view == NULL) { if (xwayland_view == NULL) {
@ -162,30 +160,6 @@ static void configure(struct sway_view *view, double x, double y, int width,
} }
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
double lx, ly;
if (container_is_floating(view->swayc)) {
lx = x;
ly = y;
} else {
struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
if (!sway_assert(output, "view must be within tree to set position")) {
return;
}
struct sway_container *root = container_parent(output, C_ROOT);
if (!sway_assert(root, "output must be within tree to set position")) {
return;
}
struct wlr_output_layout *layout = root->sway_root->output_layout;
struct wlr_output_layout_output *loutput =
wlr_output_layout_get(layout, output->sway_output->wlr_output);
if (!sway_assert(loutput,
"output must be within layout to set position")) {
return;
}
lx = x + loutput->x;
ly = y + loutput->y;
}
xwayland_view->pending_width = width; xwayland_view->pending_width = width;
xwayland_view->pending_height = height; xwayland_view->pending_height = height;
wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); wlr_xwayland_surface_configure(xsurface, lx, ly, width, height);

View file

@ -46,7 +46,7 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output,
* location, it is stored in **surface (it may not be a view). * location, it is stored in **surface (it may not be a view).
*/ */
static struct sway_container *container_at_coords( static struct sway_container *container_at_coords(
struct sway_seat *seat, double x, double y, struct sway_seat *seat, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
// check for unmanaged views first // check for unmanaged views first
struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged;
@ -55,8 +55,8 @@ static struct sway_container *container_at_coords(
struct wlr_xwayland_surface *xsurface = struct wlr_xwayland_surface *xsurface =
unmanaged_surface->wlr_xwayland_surface; unmanaged_surface->wlr_xwayland_surface;
double _sx = x - unmanaged_surface->lx; double _sx = lx - unmanaged_surface->lx;
double _sy = y - unmanaged_surface->ly; double _sy = ly - unmanaged_surface->ly;
if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) {
*surface = xsurface->surface; *surface = xsurface->surface;
*sx = _sx; *sx = _sx;
@ -69,12 +69,12 @@ static struct sway_container *container_at_coords(
struct wlr_output_layout *output_layout = struct wlr_output_layout *output_layout =
root_container.sway_root->output_layout; root_container.sway_root->output_layout;
struct wlr_output *wlr_output = wlr_output_layout_output_at( struct wlr_output *wlr_output = wlr_output_layout_output_at(
output_layout, x, y); output_layout, lx, ly);
if (wlr_output == NULL) { if (wlr_output == NULL) {
return NULL; return NULL;
} }
struct sway_output *output = wlr_output->data; struct sway_output *output = wlr_output->data;
double ox = x, oy = y; double ox = lx, oy = ly;
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
// find the focused workspace on the output for this seat // find the focused workspace on the output for this seat
@ -108,10 +108,10 @@ static struct sway_container *container_at_coords(
} }
struct sway_container *c; struct sway_container *c;
if ((c = floating_container_at(x, y, surface, sx, sy))) { if ((c = floating_container_at(lx, ly, surface, sx, sy))) {
return c; return c;
} }
if ((c = container_at(ws, ox, oy, surface, sx, sy))) { if ((c = container_at(ws, lx, ly, surface, sx, sy))) {
return c; return c;
} }

View file

@ -73,8 +73,8 @@ void arrange_workspace(struct sway_container *workspace) {
area->width, area->height, area->x, area->y); area->width, area->height, area->x, area->y);
workspace->width = area->width; workspace->width = area->width;
workspace->height = area->height; workspace->height = area->height;
workspace->x = area->x; workspace->x = output->x + area->x;
workspace->y = area->y; workspace->y = output->y + area->y;
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
workspace->name, workspace->x, workspace->y); workspace->name, workspace->x, workspace->y);
arrange_children_of(workspace); arrange_children_of(workspace);

View file

@ -467,14 +467,14 @@ struct sway_container *container_parent(struct sway_container *container,
} }
static struct sway_container *container_at_view(struct sway_container *swayc, static struct sway_container *container_at_view(struct sway_container *swayc,
double ox, double oy, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) { if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) {
return NULL; return NULL;
} }
struct sway_view *sview = swayc->sway_view; struct sway_view *sview = swayc->sway_view;
double view_sx = ox - sview->x; double view_sx = lx - sview->x;
double view_sy = oy - sview->y; double view_sy = ly - sview->y;
double _sx, _sy; double _sx, _sy;
struct wlr_surface *_surface = NULL; struct wlr_surface *_surface = NULL;
@ -516,18 +516,18 @@ static struct sway_container *container_at_view(struct sway_container *swayc,
* container_at for a container with layout L_TABBED. * container_at for a container with layout L_TABBED.
*/ */
static struct sway_container *container_at_tabbed(struct sway_container *parent, static struct sway_container *container_at_tabbed(struct sway_container *parent,
double ox, double oy, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
if (oy < parent->y || oy > parent->y + parent->height) { if (ly < parent->y || ly > parent->y + parent->height) {
return NULL; return NULL;
} }
struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_seat *seat = input_manager_current_seat(input_manager);
// Tab titles // Tab titles
int title_height = container_titlebar_height(); int title_height = container_titlebar_height();
if (oy < parent->y + title_height) { if (ly < parent->y + title_height) {
int tab_width = parent->width / parent->children->length; int tab_width = parent->width / parent->children->length;
int child_index = (ox - parent->x) / tab_width; int child_index = (lx - parent->x) / tab_width;
if (child_index >= parent->children->length) { if (child_index >= parent->children->length) {
child_index = parent->children->length - 1; child_index = parent->children->length - 1;
} }
@ -538,23 +538,23 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent,
// Surfaces // Surfaces
struct sway_container *current = seat_get_active_child(seat, parent); struct sway_container *current = seat_get_active_child(seat, parent);
return container_at(current, ox, oy, surface, sx, sy); return container_at(current, lx, ly, surface, sx, sy);
} }
/** /**
* container_at for a container with layout L_STACKED. * container_at for a container with layout L_STACKED.
*/ */
static struct sway_container *container_at_stacked( static struct sway_container *container_at_stacked(
struct sway_container *parent, double ox, double oy, struct sway_container *parent, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
if (oy < parent->y || oy > parent->y + parent->height) { if (ly < parent->y || ly > parent->y + parent->height) {
return NULL; return NULL;
} }
struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_seat *seat = input_manager_current_seat(input_manager);
// Title bars // Title bars
int title_height = container_titlebar_height(); int title_height = container_titlebar_height();
int child_index = (oy - parent->y) / title_height; int child_index = (ly - parent->y) / title_height;
if (child_index < parent->children->length) { if (child_index < parent->children->length) {
struct sway_container *child = parent->children->items[child_index]; struct sway_container *child = parent->children->items[child_index];
return seat_get_focus_inactive(seat, child); return seat_get_focus_inactive(seat, child);
@ -563,14 +563,14 @@ static struct sway_container *container_at_stacked(
// Surfaces // Surfaces
struct sway_container *current = seat_get_active_child(seat, parent); struct sway_container *current = seat_get_active_child(seat, parent);
return container_at(current, ox, oy, surface, sx, sy); return container_at(current, lx, ly, surface, sx, sy);
} }
/** /**
* container_at for a container with layout L_HORIZ or L_VERT. * container_at for a container with layout L_HORIZ or L_VERT.
*/ */
static struct sway_container *container_at_linear(struct sway_container *parent, static struct sway_container *container_at_linear(struct sway_container *parent,
double ox, double oy, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
for (int i = 0; i < parent->children->length; ++i) { for (int i = 0; i < parent->children->length; ++i) {
struct sway_container *child = parent->children->items[i]; struct sway_container *child = parent->children->items[i];
@ -580,22 +580,22 @@ static struct sway_container *container_at_linear(struct sway_container *parent,
.width = child->width, .width = child->width,
.height = child->height, .height = child->height,
}; };
if (wlr_box_contains_point(&box, ox, oy)) { if (wlr_box_contains_point(&box, lx, ly)) {
return container_at(child, ox, oy, surface, sx, sy); return container_at(child, lx, ly, surface, sx, sy);
} }
} }
return NULL; return NULL;
} }
struct sway_container *container_at(struct sway_container *parent, struct sway_container *container_at(struct sway_container *parent,
double ox, double oy, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) { struct wlr_surface **surface, double *sx, double *sy) {
if (!sway_assert(parent->type >= C_WORKSPACE, if (!sway_assert(parent->type >= C_WORKSPACE,
"Expected workspace or deeper")) { "Expected workspace or deeper")) {
return NULL; return NULL;
} }
if (parent->type == C_VIEW) { if (parent->type == C_VIEW) {
return container_at_view(parent, ox, oy, surface, sx, sy); return container_at_view(parent, lx, ly, surface, sx, sy);
} }
if (!parent->children->length) { if (!parent->children->length) {
return NULL; return NULL;
@ -604,11 +604,11 @@ struct sway_container *container_at(struct sway_container *parent,
switch (parent->layout) { switch (parent->layout) {
case L_HORIZ: case L_HORIZ:
case L_VERT: case L_VERT:
return container_at_linear(parent, ox, oy, surface, sx, sy); return container_at_linear(parent, lx, ly, surface, sx, sy);
case L_TABBED: case L_TABBED:
return container_at_tabbed(parent, ox, oy, surface, sx, sy); return container_at_tabbed(parent, lx, ly, surface, sx, sy);
case L_STACKED: case L_STACKED:
return container_at_stacked(parent, ox, oy, surface, sx, sy); return container_at_stacked(parent, lx, ly, surface, sx, sy);
case L_FLOATING: case L_FLOATING:
sway_assert(false, "Didn't expect to see floating here"); sway_assert(false, "Didn't expect to see floating here");
return NULL; return NULL;
@ -837,7 +837,7 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe
lenient_strcat(buffer, "S["); lenient_strcat(buffer, "S[");
break; break;
case L_FLOATING: case L_FLOATING:
strcpy(buffer, "F["); lenient_strcat(buffer, "F[");
break; break;
case L_NONE: case L_NONE:
lenient_strcat(buffer, "D["); lenient_strcat(buffer, "D[");

View file

@ -119,10 +119,10 @@ const char *view_get_shell(struct sway_view *view) {
return "unknown"; return "unknown";
} }
void view_configure(struct sway_view *view, double ox, double oy, int width, void view_configure(struct sway_view *view, double lx, double ly, int width,
int height) { int height) {
if (view->impl->configure) { if (view->impl->configure) {
view->impl->configure(view, ox, oy, width, height); view->impl->configure(view, lx, ly, width, height);
} }
} }
@ -134,9 +134,8 @@ static void view_autoconfigure_floating(struct sway_view *view) {
view->natural_width > max_width ? max_width : view->natural_width; view->natural_width > max_width ? max_width : view->natural_width;
int height = int height =
view->natural_height > max_height ? max_height : view->natural_height; view->natural_height > max_height ? max_height : view->natural_height;
struct sway_container *output = ws->parent; int lx = ws->x + (ws->width - width) / 2;
int lx = output->x + (ws->width - width) / 2; int ly = ws->y + (ws->height - height) / 2;
int ly = output->y + (ws->height - height) / 2;
view->border_left = view->border_right = view->border_bottom = true; view->border_left = view->border_right = view->border_bottom = true;
view_set_tiled(view, false); view_set_tiled(view, false);
@ -152,8 +151,7 @@ void view_autoconfigure(struct sway_view *view) {
struct sway_container *output = container_parent(view->swayc, C_OUTPUT); struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
if (view->is_fullscreen) { if (view->is_fullscreen) {
view_configure(view, 0, 0, output->width, output->height); view_configure(view, output->x, output->y, output->width, output->height);
view->x = view->y = 0;
return; return;
} }
@ -560,6 +558,9 @@ void view_unmap(struct sway_view *view) {
} }
void view_update_position(struct sway_view *view, double lx, double ly) { void view_update_position(struct sway_view *view, double lx, double ly) {
if (view->x == lx && view->y == ly) {
return;
}
if (!container_is_floating(view->swayc)) { if (!container_is_floating(view->swayc)) {
return; return;
} }