diff --git a/src/animation/client.h b/src/animation/client.h index 0f4e8e7..b77dd59 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -38,6 +38,15 @@ bool is_horizontal_stack_layout(Monitor *m) { return false; } +bool is_horizontal_right_stack_layout(Monitor *m) { + + if (m->pertag->curtag && + (m->pertag->ltidxs[m->pertag->curtag]->id == RIGHT_TILE)) + return true; + + return false; +} + int is_special_animaiton_rule(Client *c) { if (is_scroller_layout(c->mon) && !c->isfloating) { @@ -50,6 +59,12 @@ int is_special_animaiton_rule(Client *c) { } else if (!c->isfloating && new_is_master && is_horizontal_stack_layout(c->mon)) { return LEFT; + } else if (c->mon->visible_tiling_clients == 2 && !c->isfloating && + !new_is_master && is_horizontal_right_stack_layout(c->mon)) { + return LEFT; + } else if (!c->isfloating && new_is_master && + is_horizontal_right_stack_layout(c->mon)) { + return RIGHT; } else { return UNDIR; } diff --git a/src/layout/arrange.h b/src/layout/arrange.h index a968b52..1f9989b 100644 --- a/src/layout/arrange.h +++ b/src/layout/arrange.h @@ -176,6 +176,10 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx, delta_x = delta_x * 2; } + if (type == RIGHT_TILE) { + delta_x = delta_x * -1.0f; + } + // 直接设置新的比例,基于初始值 + 变化量 float new_master_mfact_per = grabc->old_master_mfact_per + delta_x; float new_master_inner_per = grabc->old_master_inner_per + delta_y; @@ -477,7 +481,7 @@ void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety, const Layout *current_layout = grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag]; if (current_layout->id == TILE || current_layout->id == DECK || - current_layout->id == CENTER_TILE + current_layout->id == CENTER_TILE || current_layout->id == RIGHT_TILE ) { resize_tile_master_horizontal(grabc, isdrag, offsetx, offsety, time, diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index 2820793..6549531 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -631,6 +631,104 @@ void tile(Monitor *m) { } } +void right_tile(Monitor *m) { + unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty; + Client *c = NULL; + Client *fc = NULL; + double mfact = 0; + int master_num = 0; + int stack_num = 0; + + n = m->visible_tiling_clients; + master_num = m->pertag->nmasters[m->pertag->curtag]; + stack_num = n - master_num; + + if (n == 0) + return; + + unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; + unsigned int cur_gappih = enablegaps ? m->gappih : 0; + unsigned int cur_gappov = enablegaps ? m->gappov : 0; + unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; + + cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; + + wl_list_for_each(fc, &clients, link) { + + if (VISIBLEON(fc, m) && ISTILED(fc)) + break; + } + + mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per + : m->pertag->mfacts[m->pertag->curtag]; + + if (n > m->pertag->nmasters[m->pertag->curtag]) + mw = m->pertag->nmasters[m->pertag->curtag] + ? (m->w.width + cur_gappih * ie) * mfact + : 0; + else + mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie; + i = 0; + my = ty = cur_gappov; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || !ISTILED(c)) + continue; + if (i < m->pertag->nmasters[m->pertag->curtag]) { + r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; + if (c->master_inner_per > 0.0f) { + h = (m->w.height - 2 * cur_gappov - + cur_gappiv * ie * (master_num - 1)) * + c->master_inner_per; + c->master_mfact_per = mfact; + } else { + h = (m->w.height - my - cur_gappov - + cur_gappiv * ie * (r - 1)) / + r; + c->master_inner_per = h / (m->w.height - my - cur_gappov - + cur_gappiv * ie * (r - 1)); + c->master_mfact_per = mfact; + } + resize(c, + (struct wlr_box){.x = m->w.x + m->w.width - mw - cur_gappoh + + cur_gappih * ie, + .y = m->w.y + my, + .width = mw - cur_gappih * ie, + .height = h}, + 0); + my += c->geom.height + cur_gappiv * ie; + } else { + r = n - i; + if (c->stack_innder_per > 0.0f) { + h = (m->w.height - 2 * cur_gappov - + cur_gappiv * ie * (stack_num - 1)) * + c->stack_innder_per; + c->master_mfact_per = mfact; + } else { + h = (m->w.height - ty - cur_gappov - + cur_gappiv * ie * (r - 1)) / + r; + c->stack_innder_per = h / (m->w.height - ty - cur_gappov - + cur_gappiv * ie * (r - 1)); + c->master_mfact_per = mfact; + } + + // wlr_log(WLR_ERROR, "stack_innder_per: %f", c->stack_innder_per); + + resize(c, + (struct wlr_box){.x = m->w.x + cur_gappoh, + .y = m->w.y + ty, + .width = m->w.width - mw - 2 * cur_gappoh, + .height = h}, + 0); + ty += c->geom.height + cur_gappiv * ie; + } + i++; + } +} + void // 17 monocle(Monitor *m) { Client *c = NULL; diff --git a/src/layout/layout.h b/src/layout/layout.h index 7731952..62a3227 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -1,5 +1,6 @@ static void tile(Monitor *m); static void center_tile(Monitor *m); +static void right_tile(Monitor *m); static void overview(Monitor *m); static void grid(Monitor *m); static void scroller(Monitor *m); @@ -25,6 +26,7 @@ enum { VERTICAL_TILE, VERTICAL_GRID, VERTICAL_DECK, + RIGHT_TILE, }; Layout layouts[] = { @@ -36,6 +38,7 @@ Layout layouts[] = { {"M", monocle, "monocle", MONOCLE}, // 单屏布局 {"K", deck, "deck", DECK}, // 卡片布局 {"CT", center_tile, "center_tile", CENTER_TILE}, // 居中布局 + {"RT", right_tile, "right_tile", RIGHT_TILE}, // 右布局 {"VS", vertical_scroller, "vertical_scroller", VERTICAL_SCROLLER}, // 垂直滚动布局 {"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局