opt: first version that need to check layout switch

This commit is contained in:
DreamMaoMao 2025-10-10 07:01:23 +08:00
parent fe427f6917
commit 43881077bf

View file

@ -3874,7 +3874,24 @@ void motionabsolute(struct wl_listener *listener, void *data) {
}
void resize_tile_client(Client *grabc) {
Client *tc;
Client *tc = NULL;
float delta_x, delta_y;
Client *next = NULL;
Client *prev = NULL;
// 查找 grabc 在链表中的前一个和后一个客户端
wl_list_for_each(tc, &clients, link) {
if (tc == grabc) {
// 找到当前客户端,下一个节点就是 next
if (tc->link.next != &clients) {
next = wl_container_of(tc->link.next, next, link);
}
// 前一个节点就是 prev
if (tc->link.prev != &clients) {
prev = wl_container_of(tc->link.prev, prev, link);
}
break;
}
}
if (!start_drag_window) {
begin_cursorx = cursor->x;
@ -3891,18 +3908,52 @@ void resize_tile_client(Client *grabc) {
grabc->begin_geom = grabc->geom;
} else {
// 计算相对于屏幕尺寸的比例变化
float delta_x = (float)(cursor->x - begin_cursorx) *
(1 - grabc->old_master_width_per) /
grabc->begin_geom.width;
float delta_y = (float)(cursor->y - begin_cursory) *
(grabc->old_slave_height_per) /
grabc->begin_geom.height;
if(grabc->ismaster) {
delta_x = (float)(cursor->x - begin_cursorx) *
(grabc->old_master_width_per) /
grabc->begin_geom.width;
delta_y = (float)(cursor->y - begin_cursory) *
(grabc->old_master_height_per) /
grabc->begin_geom.height;
} else {
delta_x = (float)(cursor->x - begin_cursorx) *
(1 - grabc->old_master_width_per) /
grabc->begin_geom.width;
delta_y = (float)(cursor->y - begin_cursory) *
(grabc->old_slave_height_per) /
grabc->begin_geom.height;
}
bool moving_up = cursor->y < begin_cursory;
bool moving_down = cursor->y > begin_cursory;
if ((grabc->cursor_in_upper_half && moving_up) ||
if(grabc->ismaster && !prev) {
if(moving_up) {
delta_y = -fabsf(delta_y);
} else {
delta_y = fabsf(delta_y);
}
} else if(grabc->ismaster && !next->ismaster) {
if(moving_up) {
delta_y = fabsf(delta_y);
} else {
delta_y = -fabsf(delta_y);
}
} else if(!grabc->ismaster && prev->ismaster) {
if(moving_up) {
delta_y = -fabsf(delta_y);
} else {
delta_y = fabsf(delta_y);
}
} else if(!grabc->ismaster && !next) {
if(moving_up) {
delta_y = fabsf(delta_y);
} else {
delta_y = -fabsf(delta_y);
}
} else if ((grabc->cursor_in_upper_half && moving_up) ||
(!grabc->cursor_in_upper_half && moving_down)) {
// 光标在窗口上方且向上移动,或在窗口下方且向下移动 → 增加高度
delta_y = fabsf(delta_y);