mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-20 05:34:39 -04:00
opt: opt ct layout resize action
This commit is contained in:
parent
0e233f6756
commit
9b2e01f8b4
1 changed files with 27 additions and 2 deletions
29
src/mango.c
29
src/mango.c
|
|
@ -343,6 +343,7 @@ struct Client {
|
||||||
double old_scroller_pproportion;
|
double old_scroller_pproportion;
|
||||||
bool ismaster;
|
bool ismaster;
|
||||||
bool cursor_in_upper_half, cursor_in_left_half;
|
bool cursor_in_upper_half, cursor_in_left_half;
|
||||||
|
bool isleftslave;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -1499,9 +1500,11 @@ arrange(Monitor *m, bool want_animation) {
|
||||||
stack_index = i - nmasters;
|
stack_index = i - nmasters;
|
||||||
if ((stack_index % 2) ^
|
if ((stack_index % 2) ^
|
||||||
(m->visible_tiling_clients % 2 == 0)) {
|
(m->visible_tiling_clients % 2 == 0)) {
|
||||||
|
c->isleftslave = false;
|
||||||
total_right_slave_hight_percent +=
|
total_right_slave_hight_percent +=
|
||||||
c->slave_height_per;
|
c->slave_height_per;
|
||||||
} else {
|
} else {
|
||||||
|
c->isleftslave = true;
|
||||||
total_left_slave_hight_percent +=
|
total_left_slave_hight_percent +=
|
||||||
c->slave_height_per;
|
c->slave_height_per;
|
||||||
}
|
}
|
||||||
|
|
@ -3938,7 +3941,7 @@ void motionabsolute(struct wl_listener *listener, void *data) {
|
||||||
motionnotify(event->time_msec, &event->pointer->base, dx, dy, dx, dy);
|
motionnotify(event->time_msec, &event->pointer->base, dx, dy, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize_tile_master(Client *grabc, unsigned int time) {
|
void resize_tile_master(Client *grabc, unsigned int time, int type) {
|
||||||
Client *tc = NULL;
|
Client *tc = NULL;
|
||||||
float delta_x, delta_y;
|
float delta_x, delta_y;
|
||||||
Client *next = NULL;
|
Client *next = NULL;
|
||||||
|
|
@ -3974,6 +3977,8 @@ void resize_tile_master(Client *grabc, unsigned int time) {
|
||||||
grabc->old_slave_height_per = grabc->slave_height_per;
|
grabc->old_slave_height_per = grabc->slave_height_per;
|
||||||
grabc->cursor_in_upper_half =
|
grabc->cursor_in_upper_half =
|
||||||
cursor->y < grabc->geom.y + grabc->geom.height / 2;
|
cursor->y < grabc->geom.y + grabc->geom.height / 2;
|
||||||
|
grabc->cursor_in_left_half =
|
||||||
|
cursor->x < grabc->geom.x + grabc->geom.width / 2;
|
||||||
// 记录初始几何信息
|
// 记录初始几何信息
|
||||||
grabc->begin_geom = grabc->geom;
|
grabc->begin_geom = grabc->geom;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -3993,6 +3998,8 @@ void resize_tile_master(Client *grabc, unsigned int time) {
|
||||||
|
|
||||||
bool moving_up = cursor->y < begin_cursory;
|
bool moving_up = cursor->y < begin_cursory;
|
||||||
bool moving_down = cursor->y > begin_cursory;
|
bool moving_down = cursor->y > begin_cursory;
|
||||||
|
bool moving_left = cursor->x < begin_cursorx;
|
||||||
|
bool moving_right = cursor->x > begin_cursorx;
|
||||||
|
|
||||||
if (grabc->ismaster && !prev) {
|
if (grabc->ismaster && !prev) {
|
||||||
if (moving_up) {
|
if (moving_up) {
|
||||||
|
|
@ -4027,6 +4034,24 @@ void resize_tile_master(Client *grabc, unsigned int time) {
|
||||||
delta_y = -fabsf(delta_y);
|
delta_y = -fabsf(delta_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grabc->ismaster &&
|
||||||
|
((grabc->cursor_in_left_half && moving_left) ||
|
||||||
|
(!grabc->cursor_in_left_half && moving_right))) {
|
||||||
|
// 光标在窗口左侧且向右移动 → 增加宽度
|
||||||
|
delta_x = fabsf(delta_x);
|
||||||
|
} else if (grabc->ismaster) {
|
||||||
|
// 其他情况 → 减小宽度
|
||||||
|
delta_x = -fabsf(delta_x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!grabc->ismaster && grabc->isleftslave && type == CENTER_TILE) {
|
||||||
|
delta_x = delta_x * -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grabc->ismaster && type == CENTER_TILE) {
|
||||||
|
delta_x = delta_x * 2;
|
||||||
|
}
|
||||||
|
|
||||||
// 直接设置新的比例,基于初始值 + 变化量
|
// 直接设置新的比例,基于初始值 + 变化量
|
||||||
float new_master_width_per = grabc->old_master_width_per + delta_x;
|
float new_master_width_per = grabc->old_master_width_per + delta_x;
|
||||||
float new_master_height_per = grabc->old_master_height_per + delta_y;
|
float new_master_height_per = grabc->old_master_height_per + delta_y;
|
||||||
|
|
@ -4131,7 +4156,7 @@ void resize_tile_client(Client *grabc, unsigned int time) {
|
||||||
current_layout->id == CENTER_TILE
|
current_layout->id == CENTER_TILE
|
||||||
|
|
||||||
) {
|
) {
|
||||||
resize_tile_master(grabc, time);
|
resize_tile_master(grabc, time, current_layout->id);
|
||||||
} else if (current_layout->id == SCROLLER) {
|
} else if (current_layout->id == SCROLLER) {
|
||||||
resize_tile_scroller(grabc, time, false);
|
resize_tile_scroller(grabc, time, false);
|
||||||
} else if (current_layout->id == VERTICAL_SCROLLER) {
|
} else if (current_layout->id == VERTICAL_SCROLLER) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue