mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
feat: add layout right_tile
This commit is contained in:
parent
69d68487d6
commit
7b709872f5
4 changed files with 121 additions and 1 deletions
|
|
@ -38,6 +38,15 @@ bool is_horizontal_stack_layout(Monitor *m) {
|
||||||
return false;
|
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) {
|
int is_special_animaiton_rule(Client *c) {
|
||||||
|
|
||||||
if (is_scroller_layout(c->mon) && !c->isfloating) {
|
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 &&
|
} else if (!c->isfloating && new_is_master &&
|
||||||
is_horizontal_stack_layout(c->mon)) {
|
is_horizontal_stack_layout(c->mon)) {
|
||||||
return LEFT;
|
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 {
|
} else {
|
||||||
return UNDIR;
|
return UNDIR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,10 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
|
||||||
delta_x = delta_x * 2;
|
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_mfact_per = grabc->old_master_mfact_per + delta_x;
|
||||||
float new_master_inner_per = grabc->old_master_inner_per + delta_y;
|
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 =
|
const Layout *current_layout =
|
||||||
grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag];
|
grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag];
|
||||||
if (current_layout->id == TILE || current_layout->id == DECK ||
|
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,
|
resize_tile_master_horizontal(grabc, isdrag, offsetx, offsety, time,
|
||||||
|
|
|
||||||
|
|
@ -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
|
void // 17
|
||||||
monocle(Monitor *m) {
|
monocle(Monitor *m) {
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void center_tile(Monitor *m);
|
static void center_tile(Monitor *m);
|
||||||
|
static void right_tile(Monitor *m);
|
||||||
static void overview(Monitor *m);
|
static void overview(Monitor *m);
|
||||||
static void grid(Monitor *m);
|
static void grid(Monitor *m);
|
||||||
static void scroller(Monitor *m);
|
static void scroller(Monitor *m);
|
||||||
|
|
@ -25,6 +26,7 @@ enum {
|
||||||
VERTICAL_TILE,
|
VERTICAL_TILE,
|
||||||
VERTICAL_GRID,
|
VERTICAL_GRID,
|
||||||
VERTICAL_DECK,
|
VERTICAL_DECK,
|
||||||
|
RIGHT_TILE,
|
||||||
};
|
};
|
||||||
|
|
||||||
Layout layouts[] = {
|
Layout layouts[] = {
|
||||||
|
|
@ -36,6 +38,7 @@ Layout layouts[] = {
|
||||||
{"M", monocle, "monocle", MONOCLE}, // 单屏布局
|
{"M", monocle, "monocle", MONOCLE}, // 单屏布局
|
||||||
{"K", deck, "deck", DECK}, // 卡片布局
|
{"K", deck, "deck", DECK}, // 卡片布局
|
||||||
{"CT", center_tile, "center_tile", CENTER_TILE}, // 居中布局
|
{"CT", center_tile, "center_tile", CENTER_TILE}, // 居中布局
|
||||||
|
{"RT", right_tile, "right_tile", RIGHT_TILE}, // 右布局
|
||||||
{"VS", vertical_scroller, "vertical_scroller",
|
{"VS", vertical_scroller, "vertical_scroller",
|
||||||
VERTICAL_SCROLLER}, // 垂直滚动布局
|
VERTICAL_SCROLLER}, // 垂直滚动布局
|
||||||
{"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局
|
{"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue