This commit is contained in:
2026-05-12 13:19:16 +07:00
parent 0bb721e52b
commit 2653237be8
3 changed files with 128 additions and 1 deletions
+1
View File
@@ -58,6 +58,7 @@ static const absn_keybind keybinds[] = {
{ ALT | SHIFT, XKB_KEY_l, increase_master_width, { .f = +0.05 } },
{ ALT, XKB_KEY_t, set_layout, { .i = LAYOUT_TILE } },
{ ALT, XKB_KEY_r, set_layout, { .i = LAYOUT_TILELEFT } },
{ ALT, XKB_KEY_m, set_layout, { .i = LAYOUT_MONOCLE } },
{ ALT, XKB_KEY_1, switch_workspace, { .v = "1" } },
+1 -1
View File
@@ -79,10 +79,10 @@ static const int layermap[] = {
enum {
LAYOUT_TILE,
LAYOUT_MONOCLE,
LAYOUT_TILELEFT,
LAYOUT_TILETOP,
LAYOUT_TILEBOTTOM,
LAYOUT_MONOCLE,
LAYOUT_SPIRAL,
LAYOUT_DWINDLE,
LAYOUT_VGRID,
+126
View File
@@ -151,6 +151,129 @@ tile(struct absn_output *output)
}
}
static void
tile_left(struct absn_output *output)
{
int toplevels_count = prepare_output(output);
if (toplevels_count < 1)
return;
int32_t og = OUTPUT_GAP;
struct wlr_box new_geom;
absn_toplevel *toplevel;
if (toplevels_count == 1) {
wl_list_for_each(toplevel, &output->server->toplevels, link)
{
if (toplevel->workspace == output->workspace &&
!toplevel->floating && !toplevel->fullscreen)
break;
}
new_geom.x = output->geom.x + og,
new_geom.y = output->geom.y + og,
new_geom.width = output->geom.width - 2 * og,
new_geom.height = output->geom.height - 2 * og,
toplevel_set_geom(toplevel, &new_geom);
return;
}
int32_t lg = LAYOUT_GAP;
int32_t total_lg;
int mcount = output->workspace->count;
float msize = output->workspace->size;
int32_t main_stack_width = (toplevels_count <= mcount) ?
output->geom.width - 2 * og :
msize * (output->geom.width - 2 * og);
int32_t w = output->geom.width - main_stack_width - 2 * og - lg;
int32_t pure_h;
int32_t h;
int32_t cur_h;
int32_t r;
int32_t dy = og;
int i = 0;
if (toplevels_count <= mcount) {
total_lg = (toplevels_count - 1) * lg;
pure_h = output->geom.height - 2 * og - total_lg;
h = pure_h / toplevels_count;
r = pure_h % toplevels_count;
wl_list_for_each(toplevel, &output->server->toplevels, link)
{
if (toplevel->workspace != output->workspace ||
toplevel->floating || toplevel->fullscreen)
continue;
cur_h = h + (i < r ? 1 : 0);
new_geom.x = output->geom.x + og;
new_geom.y = output->geom.y + dy;
new_geom.width = main_stack_width;
new_geom.height = cur_h;
toplevel_set_geom(toplevel, &new_geom);
dy += cur_h + lg;
i++;
}
return;
}
wl_list_for_each(toplevel, &output->server->toplevels, link)
{
if (toplevel->workspace != output->workspace ||
toplevel->floating || toplevel->fullscreen)
continue;
if (i < mcount) {
total_lg = (mcount - 1) * lg;
pure_h = output->geom.height - 2 * og - total_lg;
h = pure_h / mcount;
r = pure_h % mcount;
cur_h = h + (i < r ? 1 : 0);
new_geom.x = output->geom.width - og - main_stack_width;
new_geom.y = output->geom.y + dy;
new_geom.width = main_stack_width;
new_geom.height = cur_h;
toplevel_set_geom(toplevel, &new_geom);
dy += cur_h + lg;
} else {
if (i == mcount)
dy = og;
int32_t stack_count = toplevels_count - mcount;
total_lg = (stack_count - 1) * lg;
pure_h = output->geom.height - 2 * og - total_lg;
h = pure_h / stack_count;
r = pure_h % stack_count;
cur_h = h + (i - mcount < r ? 1 : 0);
new_geom.x = output->geom.x + og;
new_geom.y = output->geom.y + dy;
new_geom.width = w;
new_geom.height = cur_h;
toplevel_set_geom(toplevel, &new_geom);
dy += cur_h + lg;
}
i++;
}
}
static void
monocle(struct absn_output *output)
{
@@ -189,6 +312,9 @@ layout_arrange(struct absn_output *output)
case LAYOUT_TILE:
tile(output);
break;
case LAYOUT_TILELEFT:
tile_left(output);
break;
case LAYOUT_MONOCLE:
monocle(output);
break;