fixing borders

This commit is contained in:
2026-04-23 11:40:48 +07:00
parent f5b2e4e674
commit adef719782
6 changed files with 27 additions and 22 deletions
+2 -2
View File
@@ -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_SIZE 1;
#define ABSINTHE_MAIN_STACK_WIDTH 0.5; #define ABSINTHE_MAIN_STACK_WIDTH 0.5;
#define ABSINTHE_OUTPUT_GAP 10 #define ABSINTHE_OUTPUT_GAP 0
#define ABSINTHE_LAYOUT_GAP 10 #define ABSINTHE_LAYOUT_GAP 0
+3
View File
@@ -0,0 +1,3 @@
#pragma once
void run_command();
+9 -7
View File
@@ -74,10 +74,9 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data)
toplevel->scene_surface->node.data = toplevel; toplevel->scene_surface->node.data = toplevel;
absinthe_toplevel_update_geometry(toplevel); absinthe_toplevel_update_geometry(toplevel);
toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH; toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel)
int32_t borders_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH * 2; ? 0
toplevel->geometry.width += borders_width; : ABSINTHE_TOPLEVEL_BORDER_WIDTH;
toplevel->geometry.height += borders_width;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
toplevel->border[i] = wlr_scene_rect_create(toplevel->scene_tree, 0, 0, unfocused_border_color); 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) if (width < 0 || height < 0)
return; return;
if (toplevel->type == ABSINTHE_TOPLEVEL_XDG) { 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 #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,
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_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
absinthe_toplevel_update_borders_geometry(toplevel);
} }
#endif #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); absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height);
} else { } else {
toplevel->geometry = toplevel->prev_geometry; 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); absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height);
} }
} }
View File
+10 -13
View File
@@ -18,7 +18,6 @@ void layout_arrange(struct absinthe_output *output)
if (toplevels_count < 1) if (toplevels_count < 1)
return; return;
int32_t borders_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH * 2;
int32_t output_gap = ABSINTHE_OUTPUT_GAP; int32_t output_gap = ABSINTHE_OUTPUT_GAP;
if (toplevels_count == 1) { if (toplevels_count == 1) {
@@ -26,20 +25,19 @@ void layout_arrange(struct absinthe_output *output)
if (toplevel->output == output) if (toplevel->output == output)
break; break;
} }
toplevel->geometry.x = output->geometry.x + output_gap; toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + output_gap; toplevel->geometry.y = output->geometry.y + output_gap;
absinthe_toplevel_set_size(toplevel, absinthe_toplevel_set_size(toplevel,
output->geometry.width - borders_width - 2 * output_gap, output->geometry.width - 2 * output_gap,
output->geometry.height - borders_width - 2 * output_gap); output->geometry.height - 2 * output_gap);
return; return;
} }
int32_t layout_gap = ABSINTHE_LAYOUT_GAP; int32_t layout_gap = ABSINTHE_LAYOUT_GAP;
int32_t main_stack_width = (toplevels_count <= output->main_stack_size) 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); : 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 height;
int32_t dy = output_gap; int32_t dy = output_gap;
size_t i = 0; size_t i = 0;
@@ -49,11 +47,11 @@ void layout_arrange(struct absinthe_output *output)
if (toplevel->output != output || !toplevel->tiled) 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) / (toplevels_count - i);
toplevel->geometry.x = output->geometry.x + output_gap; toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + dy; toplevel->geometry.y = output->geometry.y + dy;
absinthe_toplevel_set_size(toplevel, main_stack_width, height); absinthe_toplevel_set_size(toplevel, main_stack_width, height);
dy += height + borders_width + layout_gap; dy += height + layout_gap;
i++; i++;
} }
@@ -64,21 +62,20 @@ void layout_arrange(struct absinthe_output *output)
if (toplevel->output != output || !toplevel->tiled) if (toplevel->output != output || !toplevel->tiled)
continue; continue;
if (i < output->main_stack_size) { 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.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + dy; toplevel->geometry.y = output->geometry.y + dy;
absinthe_toplevel_set_size(toplevel, main_stack_width, height); absinthe_toplevel_set_size(toplevel, main_stack_width, height);
dy += height + borders_width + layout_gap; dy += height + layout_gap;
} else { } else {
if (i == output->main_stack_size) if (i == output->main_stack_size)
dy = output_gap; 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.x = output->geometry.x + main_stack_width + layout_gap + output_gap;
toplevel->geometry.y = output->geometry.y + dy; toplevel->geometry.y = output->geometry.y + dy;
absinthe_toplevel_set_size(toplevel, width, height); absinthe_toplevel_set_size(toplevel, width, height);
dy += height + borders_width + layout_gap; dy += height + layout_gap;
} }
i++; i++;
+3
View File
@@ -153,6 +153,9 @@ void server_xwayland_new_surface(struct wl_listener *listener, void *data)
toplevel->type = ABSINTHE_TOPLEVEL_X11; toplevel->type = ABSINTHE_TOPLEVEL_X11;
toplevel->server = server; toplevel->server = server;
toplevel->toplevel.x11 = surface; toplevel->toplevel.x11 = surface;
toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel)
? 0
: ABSINTHE_TOPLEVEL_BORDER_WIDTH;
toplevel->destroy.notify = absinthe_toplevel_destroy; toplevel->destroy.notify = absinthe_toplevel_destroy;
wl_signal_add(&surface->events.destroy, &toplevel->destroy); wl_signal_add(&surface->events.destroy, &toplevel->destroy);