Squashed commit

This commit is contained in:
killertofus 2026-02-24 13:02:34 -07:00
parent 290c27f25c
commit 922ad166d8
29 changed files with 3545 additions and 1671 deletions

View file

@ -1,8 +1,59 @@
void restore_size_per(Monitor *m, Client *c) {
Client *fc = NULL;
double total_master_inner_per = 0;
double total_stack_inner_per = 0;
if (!m || !c)
return;
const Layout *current_layout = m->pertag->ltidxs[m->pertag->curtag];
if (current_layout->id == SCROLLER ||
current_layout->id == VERTICAL_SCROLLER || current_layout->id == GRID ||
current_layout->id == VERTICAL_GRID || current_layout->id == DECK ||
current_layout->id == VERTICAL_DECK || current_layout->id == MONOCLE) {
return;
}
if (current_layout->id == CENTER_TILE || c->ismaster) {
wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc) && !c->ismaster) {
set_size_per(m, fc);
}
}
return;
}
wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc) && fc != c) {
if (fc->ismaster) {
total_master_inner_per += fc->master_inner_per;
} else {
total_stack_inner_per += fc->stack_inner_per;
}
}
}
if (!c->ismaster && total_stack_inner_per) {
c->stack_inner_per = total_stack_inner_per * c->stack_inner_per /
(1 - c->stack_inner_per);
}
}
void set_size_per(Monitor *m, Client *c) {
Client *fc = NULL;
bool found = false;
if (!m || !c)
return;
const Layout *current_layout = m->pertag->ltidxs[m->pertag->curtag];
wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc) && fc != c) {
if (current_layout->id == CENTER_TILE &&
!(fc->isleftstack ^ c->isleftstack))
continue;
c->master_mfact_per = fc->master_mfact_per;
c->master_inner_per = fc->master_inner_per;
c->stack_inner_per = fc->stack_inner_per;
@ -18,8 +69,9 @@ void set_size_per(Monitor *m, Client *c) {
}
}
void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
int offsety, uint32_t time, int type) {
void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx,
int32_t offsety, uint32_t time,
int32_t type) {
Client *tc = NULL;
float delta_x, delta_y;
Client *next = NULL;
@ -200,20 +252,20 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
grabc->stack_inner_per = new_stack_inner_per;
if (!isdrag) {
arrange(grabc->mon, false);
arrange(grabc->mon, false, false);
return;
}
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_refresh_interval) {
arrange(grabc->mon, false);
time - last_apply_drap_time > drag_tile_refresh_interval) {
arrange(grabc->mon, false, false);
last_apply_drap_time = time;
}
}
}
void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
int offsety, uint32_t time, int type) {
void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx,
int32_t offsety, uint32_t time, int32_t type) {
Client *tc = NULL;
float delta_x, delta_y;
Client *next = NULL;
@ -357,22 +409,24 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
grabc->stack_inner_per = new_stack_inner_per;
if (!isdrag) {
arrange(grabc->mon, false);
arrange(grabc->mon, false, false);
return;
}
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_refresh_interval) {
arrange(grabc->mon, false);
time - last_apply_drap_time > drag_tile_refresh_interval) {
arrange(grabc->mon, false, false);
last_apply_drap_time = time;
}
}
}
void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
uint32_t time, bool isvertical) {
void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
int32_t offsety, uint32_t time, bool isvertical) {
float delta_x, delta_y;
float new_scroller_proportion;
float new_stack_proportion;
Client *stack_head = get_scroll_stack_head(grabc);
if (grabc && grabc->mon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
@ -384,7 +438,8 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
start_drag_window = true;
// 记录初始状态
grabc->old_scroller_pproportion = grabc->scroller_proportion;
stack_head->old_scroller_pproportion = stack_head->scroller_proportion;
grabc->old_stack_proportion = grabc->stack_proportion;
grabc->cursor_in_left_half =
cursor->x < grabc->geom.x + grabc->geom.width / 2;
@ -404,15 +459,26 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
grabc->old_master_inner_per = grabc->master_inner_per;
grabc->old_stack_inner_per = grabc->stack_inner_per;
grabc->drag_begin_geom = grabc->geom;
grabc->old_scroller_pproportion = grabc->scroller_proportion;
stack_head->old_scroller_pproportion =
stack_head->scroller_proportion;
grabc->old_stack_proportion = grabc->stack_proportion;
grabc->cursor_in_upper_half = false;
grabc->cursor_in_left_half = false;
}
delta_x = (float)(offsetx) * (grabc->old_scroller_pproportion) /
grabc->drag_begin_geom.width;
delta_y = (float)(offsety) * (grabc->old_scroller_pproportion) /
grabc->drag_begin_geom.height;
if (isvertical) {
delta_y = (float)(offsety) *
(stack_head->old_scroller_pproportion) /
grabc->drag_begin_geom.height;
delta_x = (float)(offsetx) * (grabc->old_stack_proportion) /
grabc->drag_begin_geom.width;
} else {
delta_x = (float)(offsetx) *
(stack_head->old_scroller_pproportion) /
grabc->drag_begin_geom.width;
delta_y = (float)(offsety) * (grabc->old_stack_proportion) /
grabc->drag_begin_geom.height;
}
bool moving_up;
bool moving_down;
@ -447,34 +513,97 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
delta_x = -fabsf(delta_x);
}
if (isvertical) {
if (!grabc->next_in_stack && grabc->prev_in_stack && !isdrag) {
delta_x = delta_x * -1.0f;
}
if (!grabc->next_in_stack && grabc->prev_in_stack && isdrag) {
if (moving_right) {
delta_x = -fabsf(delta_x);
} else {
delta_x = fabsf(delta_x);
}
}
if (!grabc->prev_in_stack && grabc->next_in_stack && isdrag) {
if (moving_left) {
delta_x = -fabsf(delta_x);
} else {
delta_x = fabsf(delta_x);
}
}
if (isdrag) {
if (moving_up) {
delta_y = -fabsf(delta_y);
} else {
delta_y = fabsf(delta_y);
}
}
} else {
if (!grabc->next_in_stack && grabc->prev_in_stack && !isdrag) {
delta_y = delta_y * -1.0f;
}
if (!grabc->next_in_stack && grabc->prev_in_stack && isdrag) {
if (moving_down) {
delta_y = -fabsf(delta_y);
} else {
delta_y = fabsf(delta_y);
}
}
if (!grabc->prev_in_stack && grabc->next_in_stack && isdrag) {
if (moving_up) {
delta_y = -fabsf(delta_y);
} else {
delta_y = fabsf(delta_y);
}
}
if (isdrag) {
if (moving_left) {
delta_x = -fabsf(delta_x);
} else {
delta_x = fabsf(delta_x);
}
}
}
// 直接设置新的比例,基于初始值 + 变化量
if (isvertical) {
new_scroller_proportion = grabc->old_scroller_pproportion + delta_y;
new_scroller_proportion =
stack_head->old_scroller_pproportion + delta_y;
new_stack_proportion = grabc->old_stack_proportion + delta_x;
} else {
new_scroller_proportion = grabc->old_scroller_pproportion + delta_x;
new_scroller_proportion =
stack_head->old_scroller_pproportion + delta_x;
new_stack_proportion = grabc->old_stack_proportion + delta_y;
}
// 应用限制,确保比例在合理范围内
new_scroller_proportion =
fmaxf(0.1f, fminf(1.0f, new_scroller_proportion));
new_stack_proportion = fmaxf(0.1f, fminf(1.0f, new_stack_proportion));
grabc->scroller_proportion = new_scroller_proportion;
grabc->stack_proportion = new_stack_proportion;
stack_head->scroller_proportion = new_scroller_proportion;
if (!isdrag) {
arrange(grabc->mon, false);
arrange(grabc->mon, false, false);
return;
}
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_refresh_interval) {
arrange(grabc->mon, false);
time - last_apply_drap_time > drag_tile_refresh_interval) {
arrange(grabc->mon, false, false);
last_apply_drap_time = time;
}
}
}
void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
uint32_t time) {
void resize_tile_client(Client *grabc, bool isdrag, int32_t offsetx,
int32_t offsety, uint32_t time) {
if (!grabc || grabc->isfullscreen || grabc->ismaximizescreen)
return;
@ -502,14 +631,14 @@ void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
}
}
void reset_size_per_mon(Monitor *m, int tile_cilent_num,
void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
double total_left_stack_hight_percent,
double total_right_stack_hight_percent,
double total_stack_hight_percent,
double total_master_inner_percent, int master_num,
int stack_num) {
double total_master_inner_percent, int32_t master_num,
int32_t stack_num) {
Client *c = NULL;
int i = 0;
int32_t i = 0;
uint32_t stack_index = 0;
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
@ -577,17 +706,17 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
}
void // 17
arrange(Monitor *m, bool want_animation) {
arrange(Monitor *m, bool want_animation, bool from_view) {
Client *c = NULL;
double total_stack_inner_percent = 0;
double total_master_inner_percent = 0;
double total_right_stack_hight_percent = 0;
double total_left_stack_hight_percent = 0;
int i = 0;
int nmasters = 0;
int stack_index = 0;
int master_num = 0;
int stack_num = 0;
int32_t i = 0;
int32_t nmasters = 0;
int32_t stack_index = 0;
int32_t master_num = 0;
int32_t stack_num = 0;
if (!m)
return;
@ -600,13 +729,27 @@ arrange(Monitor *m, bool want_animation) {
wl_list_for_each(c, &clients, link) {
if (!client_only_in_one_tag(c) || c->isglobal || c->isunglobal) {
exit_scroller_stack(c);
}
if (from_view && (c->isglobal || c->isunglobal)) {
set_size_per(m, c);
}
if (c->mon == m && (c->isglobal || c->isunglobal)) {
c->tags = m->tagset[m->seltags];
if (c->mon->sel == NULL)
focusclient(c, 0);
}
if (from_view && m->sel == NULL && c->isglobal && VISIBLEON(c, m)) {
focusclient(c, 1);
}
if (VISIBLEON(c, m)) {
if (from_view && !client_only_in_one_tag(c)) {
set_size_per(m, c);
}
if (!c->isunglobal)
m->visible_clients++;
@ -614,7 +757,7 @@ arrange(Monitor *m, bool want_animation) {
m->visible_tiling_clients++;
}
if (ISSCROLLTILED(c)) {
if (ISSCROLLTILED(c) && !c->prev_in_stack) {
m->visible_scroll_tiling_clients++;
}
}