From 68b274628cfeebac1023ca4ce90606d0da56d248 Mon Sep 17 00:00:00 2001 From: speckitor Date: Sun, 26 Apr 2026 22:34:31 +0700 Subject: [PATCH] x11 borders fix --- .gitignore | 2 -- include/focus.h | 5 +++++ include/types.h | 1 + src/absinthe-toplevel.c | 10 +++++++--- src/focus.c | 20 ++++++++++++++++++++ src/keyboard.c | 2 +- src/xdg-toplevel.c | 3 --- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 464e241..6ae1701 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ absinthe xdg-shell-protocol.h -TAGS tags -compile_commands.json diff --git a/include/focus.h b/include/focus.h index 55c2501..15919f5 100644 --- a/include/focus.h +++ b/include/focus.h @@ -3,6 +3,11 @@ #include "types.h" void focus_toplevel(struct absinthe_toplevel *toplevel); + struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server); + +struct absinthe_toplevel *focus_get_first_tiled(struct absinthe_output *output); +struct absinthe_toplevel *focus_get_last_tiled(struct absinthe_output *output); + void focus_next(struct absinthe_server *server); void focus_prev(struct absinthe_server *server); diff --git a/include/types.h b/include/types.h index 0967489..35129ac 100644 --- a/include/types.h +++ b/include/types.h @@ -142,6 +142,7 @@ struct absinthe_toplevel { struct wlr_xdg_toplevel_decoration_v1 *decoration; bool tiled, floating, fullscreen, maximized; + bool urgent; uint32_t resizing; struct wlr_box geometry; diff --git a/src/absinthe-toplevel.c b/src/absinthe-toplevel.c index fd8bcec..9994635 100644 --- a/src/absinthe-toplevel.c +++ b/src/absinthe-toplevel.c @@ -109,10 +109,10 @@ void absinthe_toplevel_unmap(struct wl_listener *listener, void *data) wl_list_remove(&toplevel->link); wl_list_remove(&toplevel->flink); - wlr_scene_node_destroy(&toplevel->scene_tree->node); + if (toplevel->output == toplevel->server->focused_output) + layout_arrange(toplevel->output); - layout_arrange(toplevel->output); - focus_next(toplevel->server); + wlr_scene_node_destroy(&toplevel->scene_tree->node); } void absinthe_toplevel_destroy(struct wl_listener *listener, void *data) @@ -240,6 +240,8 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt absinthe_toplevel_set_position(toplevel, toplevel->geometry.x + toplevel->border_width, toplevel->geometry.y + toplevel->border_width); } #endif + + absinthe_toplevel_update_borders_geometry(toplevel); } void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool fullscreen) @@ -263,6 +265,8 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f absinthe_toplevel_set_size(toplevel, toplevel->prev_geometry.width, toplevel->prev_geometry.height); absinthe_toplevel_set_position(toplevel, toplevel->prev_geometry.x, toplevel->prev_geometry.y); } + + absinthe_toplevel_update_borders_geometry(toplevel); } void absinthe_toplevel_set_border_color(struct absinthe_toplevel *toplevel, const float color[4]) diff --git a/src/focus.c b/src/focus.c index f1fa2c5..9e1ae87 100644 --- a/src/focus.c +++ b/src/focus.c @@ -59,6 +59,26 @@ struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server) return NULL; } +struct absinthe_toplevel *focus_get_first_tiled(struct absinthe_output *output) +{ + struct absinthe_toplevel *toplevel; + wl_list_for_each(toplevel, &output->server->focus_stack, flink) { + if (toplevel->tiled && toplevel->output == output) + return toplevel; + } + return NULL; +} + +struct absinthe_toplevel *focus_get_last_tiled(struct absinthe_output *output) +{ + struct absinthe_toplevel *toplevel; + wl_list_for_each_reverse(toplevel, &output->server->focus_stack, flink) { + if (toplevel->tiled && toplevel->output == output) + return toplevel; + } + return NULL; +} + void focus_next(struct absinthe_server *server) { struct absinthe_toplevel *toplevel = focus_get_topmost(server); diff --git a/src/keyboard.c b/src/keyboard.c index 6bee76a..281c4c3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -28,7 +28,7 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t break; case XKB_KEY_Return: if (fork() == 0) - execl("/bin/sh", "sh", "-c", "foot", NULL); + execl("/bin/sh", "sh", "-c", "alacritty", NULL); break; case XKB_KEY_r: if (fork() == 0) diff --git a/src/xdg-toplevel.c b/src/xdg-toplevel.c index a5029fc..9d207ca 100644 --- a/src/xdg-toplevel.c +++ b/src/xdg-toplevel.c @@ -25,9 +25,6 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data) return; } - /* Update borders and position only after client prepared new buffer */ - absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y); - absinthe_toplevel_update_borders_geometry(toplevel); if (toplevel->resizing && toplevel->resizing <= toplevel->toplevel.xdg->base->current.configure_serial) toplevel->resizing = 0; }