From adef719782cfee444dda36b0d1abaf30942e7cd4 Mon Sep 17 00:00:00 2001 From: speckitor Date: Thu, 23 Apr 2026 11:40:48 +0700 Subject: [PATCH] fixing borders --- include/config.h | 4 ++-- include/keybinds-callbacks.h | 3 +++ src/absinthe-toplevel.c | 16 +++++++++------- src/keybinds-callbacks.c | 0 src/layout.c | 23 ++++++++++------------- src/server.c | 3 +++ 6 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 include/keybinds-callbacks.h create mode 100644 src/keybinds-callbacks.c diff --git a/include/config.h b/include/config.h index 0b6a8d2..38f2d20 100644 --- a/include/config.h +++ b/include/config.h @@ -13,5 +13,5 @@ static const float unfocused_border_color[4] = {0.39, 0.42, 0.46, 1.0}; #define ABSINTHE_MAIN_STACK_SIZE 1; #define ABSINTHE_MAIN_STACK_WIDTH 0.5; -#define ABSINTHE_OUTPUT_GAP 10 -#define ABSINTHE_LAYOUT_GAP 10 +#define ABSINTHE_OUTPUT_GAP 0 +#define ABSINTHE_LAYOUT_GAP 0 diff --git a/include/keybinds-callbacks.h b/include/keybinds-callbacks.h new file mode 100644 index 0000000..3f82483 --- /dev/null +++ b/include/keybinds-callbacks.h @@ -0,0 +1,3 @@ +#pragma once + +void run_command(); diff --git a/src/absinthe-toplevel.c b/src/absinthe-toplevel.c index 93c90b7..17ff7ae 100644 --- a/src/absinthe-toplevel.c +++ b/src/absinthe-toplevel.c @@ -74,10 +74,9 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data) toplevel->scene_surface->node.data = toplevel; absinthe_toplevel_update_geometry(toplevel); - toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH; - int32_t borders_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH * 2; - toplevel->geometry.width += borders_width; - toplevel->geometry.height += borders_width; + toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel) + ? 0 + : ABSINTHE_TOPLEVEL_BORDER_WIDTH; for (int i = 0; i < 4; ++i) { toplevel->border[i] = wlr_scene_rect_create(toplevel->scene_tree, 0, 0, unfocused_border_color); @@ -204,13 +203,14 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt if (width < 0 || height < 0) return; if (toplevel->type == ABSINTHE_TOPLEVEL_XDG) { - toplevel->resizing = wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height); + toplevel->resizing = wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width - 2 * toplevel->border_width, height - 2 * toplevel->border_width); } #ifdef XWAYLAND else if (toplevel->type == ABSINTHE_TOPLEVEL_X11) { wlr_xwayland_surface_configure(toplevel->toplevel.x11, - toplevel->geometry.x, toplevel->geometry.y, width, height); + toplevel->geometry.x, toplevel->geometry.y, width - 2 * toplevel->border_width, height - 2 * toplevel->border_width); absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y); + absinthe_toplevel_update_borders_geometry(toplevel); } #endif } @@ -231,7 +231,9 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height); } else { toplevel->geometry = toplevel->prev_geometry; - toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH; + toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel) + ? 0 + : ABSINTHE_TOPLEVEL_BORDER_WIDTH; absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height); } } diff --git a/src/keybinds-callbacks.c b/src/keybinds-callbacks.c new file mode 100644 index 0000000..e69de29 diff --git a/src/layout.c b/src/layout.c index f9fc193..2ab73e5 100644 --- a/src/layout.c +++ b/src/layout.c @@ -18,7 +18,6 @@ void layout_arrange(struct absinthe_output *output) if (toplevels_count < 1) return; - int32_t borders_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH * 2; int32_t output_gap = ABSINTHE_OUTPUT_GAP; if (toplevels_count == 1) { @@ -26,20 +25,19 @@ void layout_arrange(struct absinthe_output *output) if (toplevel->output == output) break; } - toplevel->geometry.x = output->geometry.x + output_gap; toplevel->geometry.y = output->geometry.y + output_gap; absinthe_toplevel_set_size(toplevel, - output->geometry.width - borders_width - 2 * output_gap, - output->geometry.height - borders_width - 2 * output_gap); + output->geometry.width - 2 * output_gap, + output->geometry.height - 2 * output_gap); return; } int32_t layout_gap = ABSINTHE_LAYOUT_GAP; int32_t main_stack_width = (toplevels_count <= output->main_stack_size) - ? output->geometry.width - borders_width - 2 * output_gap + ? output->geometry.width - 2 * output_gap : output->main_stack_width * (output->geometry.width - 2 * output_gap); - int32_t width = output->geometry.width - main_stack_width - borders_width - 2 * output_gap - layout_gap; + int32_t width = output->geometry.width - main_stack_width - 2 * output_gap - layout_gap; int32_t height; int32_t dy = output_gap; size_t i = 0; @@ -49,11 +47,11 @@ void layout_arrange(struct absinthe_output *output) if (toplevel->output != output || !toplevel->tiled) continue; - height = (output->geometry.height - dy - output_gap) / (output->main_stack_size - i) - borders_width; + height = (output->geometry.height - dy - output_gap) / (toplevels_count - i); toplevel->geometry.x = output->geometry.x + output_gap; toplevel->geometry.y = output->geometry.y + dy; absinthe_toplevel_set_size(toplevel, main_stack_width, height); - dy += height + borders_width + layout_gap; + dy += height + layout_gap; i++; } @@ -64,21 +62,20 @@ void layout_arrange(struct absinthe_output *output) if (toplevel->output != output || !toplevel->tiled) continue; - if (i < output->main_stack_size) { - 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); toplevel->geometry.x = output->geometry.x + output_gap; toplevel->geometry.y = output->geometry.y + dy; absinthe_toplevel_set_size(toplevel, main_stack_width, height); - dy += height + borders_width + layout_gap; + dy += height + layout_gap; } else { if (i == output->main_stack_size) dy = output_gap; - height = (output->geometry.height - dy - output_gap) / (toplevels_count - i) - borders_width; + height = (output->geometry.height - dy - output_gap) / (toplevels_count - i); toplevel->geometry.x = output->geometry.x + main_stack_width + layout_gap + output_gap; toplevel->geometry.y = output->geometry.y + dy; absinthe_toplevel_set_size(toplevel, width, height); - dy += height + borders_width + layout_gap; + dy += height + layout_gap; } i++; diff --git a/src/server.c b/src/server.c index bf8b295..c7d980e 100644 --- a/src/server.c +++ b/src/server.c @@ -153,6 +153,9 @@ void server_xwayland_new_surface(struct wl_listener *listener, void *data) toplevel->type = ABSINTHE_TOPLEVEL_X11; toplevel->server = server; toplevel->toplevel.x11 = surface; + toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel) + ? 0 + : ABSINTHE_TOPLEVEL_BORDER_WIDTH; toplevel->destroy.notify = absinthe_toplevel_destroy; wl_signal_add(&surface->events.destroy, &toplevel->destroy);