resizing serial

This commit is contained in:
2026-04-23 10:47:42 +07:00
parent 30dbaced7a
commit f5b2e4e674
6 changed files with 25 additions and 15 deletions
+2 -4
View File
@@ -139,10 +139,8 @@ struct absinthe_toplevel {
struct wlr_scene_rect *border[4]; struct wlr_scene_rect *border[4];
struct wlr_xdg_toplevel_decoration_v1 *decoration; struct wlr_xdg_toplevel_decoration_v1 *decoration;
bool floating; bool tiled, floating, fullscreen, maximized;
bool tiled; uint32_t resizing;
bool fullscreen;
bool performing_resize;
struct wlr_box geometry; struct wlr_box geometry;
struct wlr_box prev_geometry; struct wlr_box prev_geometry;
+5 -2
View File
@@ -57,6 +57,8 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data)
toplevel->scene_tree->node.data = toplevel; toplevel->scene_tree->node.data = toplevel;
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, false); wlr_scene_node_set_enabled(&toplevel->scene_tree->node, false);
toplevel->tiled = true;
toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel) toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel)
? 0 ? 0
: ABSINTHE_TOPLEVEL_BORDER_WIDTH; : ABSINTHE_TOPLEVEL_BORDER_WIDTH;
@@ -201,8 +203,9 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt
{ {
if (width < 0 || height < 0) if (width < 0 || height < 0)
return; return;
if (toplevel->type == ABSINTHE_TOPLEVEL_XDG) if (toplevel->type == ABSINTHE_TOPLEVEL_XDG) {
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height); toplevel->resizing = wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
}
#ifdef XWAYLAND #ifdef XWAYLAND
else if (toplevel->type == ABSINTHE_TOPLEVEL_X11) { else if (toplevel->type == ABSINTHE_TOPLEVEL_X11) {
wlr_xwayland_surface_configure(toplevel->toplevel.x11, wlr_xwayland_surface_configure(toplevel->toplevel.x11,
+5 -4
View File
@@ -41,6 +41,7 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new
int32_t max_width = toplevel->toplevel.xdg->current.max_width; int32_t max_width = toplevel->toplevel.xdg->current.max_width;
int32_t max_height = toplevel->toplevel.xdg->current.max_height; int32_t max_height = toplevel->toplevel.xdg->current.max_height;
bool resize = false;
if (max_width == 0) if (max_width == 0)
max_width = 10000; max_width = 10000;
@@ -51,16 +52,16 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new
if (new_geometry->width - borders_width >= min_width && new_geometry->width - borders_width <= max_width) { if (new_geometry->width - borders_width >= min_width && new_geometry->width - borders_width <= max_width) {
toplevel->geometry.x = new_geometry->x; toplevel->geometry.x = new_geometry->x;
toplevel->geometry.width = new_geometry->width; toplevel->geometry.width = new_geometry->width;
toplevel->performing_resize = true; resize = true;
} }
if (new_geometry->height - borders_width >= min_height && new_geometry->height - borders_width <= max_height) { if (new_geometry->height - borders_width >= min_height && new_geometry->height - borders_width <= max_height) {
toplevel->geometry.y = new_geometry->y; toplevel->geometry.y = new_geometry->y;
toplevel->geometry.height = new_geometry->height; toplevel->geometry.height = new_geometry->height;
toplevel->performing_resize = true; resize = true;
} }
if (toplevel->performing_resize) if (resize)
absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - borders_width, toplevel->geometry.height - borders_width); absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - borders_width, toplevel->geometry.height - borders_width);
} }
@@ -70,7 +71,7 @@ static void process_cursor_resize(struct absinthe_server *server) {
if (!toplevel) if (!toplevel)
return; return;
if (toplevel->performing_resize == true) if (toplevel->resizing)
return; return;
if (toplevel->fullscreen) if (toplevel->fullscreen)
+3 -3
View File
@@ -9,7 +9,7 @@ void layout_arrange(struct absinthe_output *output)
struct absinthe_toplevel *toplevel; struct absinthe_toplevel *toplevel;
size_t toplevels_count = 0; size_t toplevels_count = 0;
wl_list_for_each(toplevel, &output->server->toplevels, link) { wl_list_for_each(toplevel, &output->server->toplevels, link) {
if (toplevel->output == output) { if (toplevel->tiled && toplevel->output == output) {
toplevels_count++; toplevels_count++;
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true); wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true);
} }
@@ -46,7 +46,7 @@ void layout_arrange(struct absinthe_output *output)
if (toplevels_count <= output->main_stack_size) { if (toplevels_count <= output->main_stack_size) {
wl_list_for_each(toplevel, &output->server->toplevels, link) { wl_list_for_each(toplevel, &output->server->toplevels, link) {
if (toplevel->output != output) if (toplevel->output != output || !toplevel->tiled)
continue; continue;
height = (output->geometry.height - dy - output_gap) / (output->main_stack_size - i) - borders_width; height = (output->geometry.height - dy - output_gap) / (output->main_stack_size - i) - borders_width;
@@ -61,7 +61,7 @@ void layout_arrange(struct absinthe_output *output)
} }
wl_list_for_each(toplevel, &output->server->toplevels, link) { wl_list_for_each(toplevel, &output->server->toplevels, link) {
if (toplevel->output != output) if (toplevel->output != output || !toplevel->tiled)
continue; continue;
+7
View File
@@ -11,8 +11,15 @@ void output_frame(struct wl_listener *listener, void *data)
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(scene, output->wlr_output); struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(scene, output->wlr_output);
struct absinthe_toplevel *toplevel;
wl_list_for_each(toplevel, &output->server->toplevels, link) {
if (toplevel->resizing && toplevel->output == output)
goto skip;
}
wlr_scene_output_commit(scene_output, NULL); wlr_scene_output_commit(scene_output, NULL);
skip:
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
wlr_scene_output_send_frame_done(scene_output, &now); wlr_scene_output_send_frame_done(scene_output, &now);
+3 -2
View File
@@ -18,13 +18,13 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data)
if (toplevel->toplevel.xdg->base->initial_commit) { if (toplevel->toplevel.xdg->base->initial_commit) {
/* Let toplevel set preferred size */ /* Let toplevel set preferred size */
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, 0, 0);
toplevel->geometry.width = toplevel->toplevel.xdg->base->geometry.width + borders_width; toplevel->geometry.width = toplevel->toplevel.xdg->base->geometry.width + borders_width;
toplevel->geometry.height = toplevel->toplevel.xdg->base->geometry.height + borders_width; toplevel->geometry.height = toplevel->toplevel.xdg->base->geometry.height + borders_width;
/* Forse server side decoration mode */ /* Forse server side decoration mode */
if (toplevel->decoration) if (toplevel->decoration)
xdg_decoration_request_mode(&toplevel->decoration_request_mode, toplevel->decoration); xdg_decoration_request_mode(&toplevel->decoration_request_mode, toplevel->decoration);
toplevel->resizing = wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, 0, 0);
return; return;
} }
/* Check for size because we did't set it on initial commit */ /* Check for size because we did't set it on initial commit */
@@ -34,5 +34,6 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data)
/* Update borders and position only after client prepared new buffer */ /* Update borders and position only after client prepared new buffer */
absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y); absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
absinthe_toplevel_update_borders_geometry(toplevel); absinthe_toplevel_update_borders_geometry(toplevel);
toplevel->performing_resize = false; if (toplevel->resizing && toplevel->resizing <= toplevel->toplevel.xdg->base->current.configure_serial)
toplevel->resizing = 0;
} }