shells: Only center tiled views on size change
The size of a tiled container cannot change in response to new buffer sizes, so there is no need to commit a new transaction. Instead, simply recenter the view with the new geometry, leaving the full transaction flow for floating containers.
This commit is contained in:
parent
50205ade9d
commit
90fa6953ea
|
@ -295,17 +295,20 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
if (new_size) {
|
if (new_size) {
|
||||||
// The view has unexpectedly sent a new size
|
// The view has unexpectedly sent a new size
|
||||||
desktop_damage_view(view);
|
desktop_damage_view(view);
|
||||||
view_update_size(view, new_geo.width, new_geo.height);
|
|
||||||
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
||||||
|
if (container_is_floating(view->container)) {
|
||||||
|
view_update_size(view, new_geo.width, new_geo.height);
|
||||||
|
transaction_commit_dirty();
|
||||||
|
transaction_notify_view_ready_immediately(view);
|
||||||
|
} else {
|
||||||
|
view_center_surface(view);
|
||||||
|
}
|
||||||
desktop_damage_view(view);
|
desktop_damage_view(view);
|
||||||
transaction_commit_dirty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view->container->node.instruction) {
|
if (view->container->node.instruction) {
|
||||||
transaction_notify_view_ready_by_serial(view,
|
transaction_notify_view_ready_by_serial(view,
|
||||||
xdg_surface->configure_serial);
|
xdg_surface->configure_serial);
|
||||||
} else if (new_size) {
|
|
||||||
transaction_notify_view_ready_immediately(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view_damage_from(view);
|
view_damage_from(view);
|
||||||
|
|
|
@ -406,22 +406,25 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
} else {
|
} else {
|
||||||
struct wlr_box new_geo;
|
struct wlr_box new_geo;
|
||||||
get_geometry(view, &new_geo);
|
get_geometry(view, &new_geo);
|
||||||
|
bool new_size = new_geo.width != view->geometry.width ||
|
||||||
|
new_geo.height != view->geometry.height ||
|
||||||
|
new_geo.x != view->geometry.x ||
|
||||||
|
new_geo.y != view->geometry.y;
|
||||||
|
|
||||||
if ((new_geo.width != view->geometry.width ||
|
if (new_size) {
|
||||||
new_geo.height != view->geometry.height ||
|
|
||||||
new_geo.x != view->geometry.x ||
|
|
||||||
new_geo.y != view->geometry.y)) {
|
|
||||||
// The view has unexpectedly sent a new size
|
// The view has unexpectedly sent a new size
|
||||||
// eg. The Firefox "Save As" dialog when downloading a file
|
// eg. The Firefox "Save As" dialog when downloading a file
|
||||||
desktop_damage_view(view);
|
desktop_damage_view(view);
|
||||||
view_update_size(view, new_geo.width, new_geo.height);
|
|
||||||
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
||||||
desktop_damage_view(view);
|
if (container_is_floating(view->container)) {
|
||||||
transaction_commit_dirty();
|
view_update_size(view, new_geo.width, new_geo.height);
|
||||||
transaction_notify_view_ready_by_geometry(view,
|
transaction_commit_dirty();
|
||||||
|
transaction_notify_view_ready_by_geometry(view,
|
||||||
xsurface->x, xsurface->y, new_geo.width, new_geo.height);
|
xsurface->x, xsurface->y, new_geo.width, new_geo.height);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
view_center_surface(view);
|
||||||
|
}
|
||||||
|
desktop_damage_view(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -874,17 +874,9 @@ void view_unmap(struct sway_view *view) {
|
||||||
|
|
||||||
void view_update_size(struct sway_view *view, int width, int height) {
|
void view_update_size(struct sway_view *view, int width, int height) {
|
||||||
struct sway_container *con = view->container;
|
struct sway_container *con = view->container;
|
||||||
|
con->content_width = width;
|
||||||
if (container_is_floating(con)) {
|
con->content_height = height;
|
||||||
con->content_width = width;
|
container_set_geometry_from_content(con);
|
||||||
con->content_height = height;
|
|
||||||
container_set_geometry_from_content(con);
|
|
||||||
} else {
|
|
||||||
con->surface_x = con->content_x + (con->content_width - width) / 2;
|
|
||||||
con->surface_y = con->content_y + (con->content_height - height) / 2;
|
|
||||||
con->surface_x = fmax(con->surface_x, con->content_x);
|
|
||||||
con->surface_y = fmax(con->surface_y, con->content_y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_center_surface(struct sway_view *view) {
|
void view_center_surface(struct sway_view *view) {
|
||||||
|
|
Loading…
Reference in a new issue