fix: different action for drag and keybind move

This commit is contained in:
DreamMaoMao 2025-10-11 09:20:45 +08:00
parent 67bebc2e53
commit a8834a78a6
3 changed files with 26 additions and 26 deletions

View file

@ -411,7 +411,7 @@ void resizewin(const Arg *arg) {
offsety = arg->i2; offsety = arg->i2;
break; break;
} }
resize_tile_client(c, offsetx, offsety, 0); resize_tile_client(c, false, offsetx, offsety, 0);
return; return;
} }

View file

@ -18,8 +18,8 @@ void set_size_per(Monitor *m, Client *c) {
} }
} }
void resize_tile_master_horizontal(Client *grabc, int offsetx, int offsety, void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
unsigned int time, int type) { int offsety, 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;
@ -64,7 +64,7 @@ void resize_tile_master_horizontal(Client *grabc, int offsetx, int offsety,
} }
} }
if (!start_drag_window && offsetx == 0 && offsety == 0) { if (!start_drag_window && isdrag) {
drag_begin_cursorx = cursor->x; drag_begin_cursorx = cursor->x;
drag_begin_cursory = cursor->y; drag_begin_cursory = cursor->y;
start_drag_window = true; start_drag_window = true;
@ -80,7 +80,7 @@ void resize_tile_master_horizontal(Client *grabc, int offsetx, int offsety,
grabc->drag_begin_geom = grabc->geom; grabc->drag_begin_geom = grabc->geom;
} else { } else {
// 计算相对于屏幕尺寸的比例变化 // 计算相对于屏幕尺寸的比例变化
if (!offsetx && !offsety) { if (isdrag) {
offsetx = cursor->x - drag_begin_cursorx; offsetx = cursor->x - drag_begin_cursorx;
offsety = cursor->y - drag_begin_cursory; offsety = cursor->y - drag_begin_cursory;
@ -107,7 +107,7 @@ void resize_tile_master_horizontal(Client *grabc, int offsetx, int offsety,
bool moving_up; bool moving_up;
bool moving_down; bool moving_down;
if (offsetx || offsety) { if (!isdrag) {
moving_up = offsety < 0 ? true : false; moving_up = offsety < 0 ? true : false;
moving_down = offsety > 0 ? true : false; moving_down = offsety > 0 ? true : false;
} else { } else {
@ -196,7 +196,7 @@ void resize_tile_master_horizontal(Client *grabc, int offsetx, int offsety,
grabc->master_inner_per = new_master_inner_per; grabc->master_inner_per = new_master_inner_per;
grabc->slave_innder_per = new_slave_innder_per; grabc->slave_innder_per = new_slave_innder_per;
if (offsetx || offsety) { if (!isdrag) {
arrange(grabc->mon, false); arrange(grabc->mon, false);
return; return;
} }
@ -209,8 +209,8 @@ void resize_tile_master_horizontal(Client *grabc, int offsetx, int offsety,
} }
} }
void resize_tile_master_vertical(Client *grabc, int offsetx, int offsety, void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
unsigned int time, int type) { int offsety, 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;
@ -240,7 +240,7 @@ void resize_tile_master_vertical(Client *grabc, int offsetx, int offsety,
} }
} }
if (!start_drag_window && offsetx == 0 && offsety == 0) { if (!start_drag_window && isdrag) {
drag_begin_cursorx = cursor->x; drag_begin_cursorx = cursor->x;
drag_begin_cursory = cursor->y; drag_begin_cursory = cursor->y;
start_drag_window = true; start_drag_window = true;
@ -258,7 +258,7 @@ void resize_tile_master_vertical(Client *grabc, int offsetx, int offsety,
} else { } else {
// 计算相对于屏幕尺寸的比例变化 // 计算相对于屏幕尺寸的比例变化
// 计算相对于屏幕尺寸的比例变化 // 计算相对于屏幕尺寸的比例变化
if (!offsetx && !offsety) { if (isdrag) {
offsetx = cursor->x - drag_begin_cursorx; offsetx = cursor->x - drag_begin_cursorx;
offsety = cursor->y - drag_begin_cursory; offsety = cursor->y - drag_begin_cursory;
@ -287,7 +287,7 @@ void resize_tile_master_vertical(Client *grabc, int offsetx, int offsety,
bool moving_left; bool moving_left;
bool moving_right; bool moving_right;
if (offsetx || offsety) { if (!isdrag) {
moving_left = offsetx < 0 ? true : false; moving_left = offsetx < 0 ? true : false;
moving_right = offsetx > 0 ? true : false; moving_right = offsetx > 0 ? true : false;
} else { } else {
@ -358,7 +358,7 @@ void resize_tile_master_vertical(Client *grabc, int offsetx, int offsety,
grabc->master_inner_per = new_master_inner_per; grabc->master_inner_per = new_master_inner_per;
grabc->slave_innder_per = new_slave_innder_per; grabc->slave_innder_per = new_slave_innder_per;
if (offsetx || offsety) { if (!isdrag) {
arrange(grabc->mon, false); arrange(grabc->mon, false);
return; return;
} }
@ -371,13 +371,13 @@ void resize_tile_master_vertical(Client *grabc, int offsetx, int offsety,
} }
} }
void resize_tile_scroller(Client *grabc, int offsetx, int offsety, void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
unsigned int time, bool isvertical) { unsigned int time, bool isvertical) {
float delta_x, delta_y; float delta_x, delta_y;
float new_scroller_proportion; float new_scroller_proportion;
double refresh_interval = 1000000.0 / grabc->mon->wlr_output->refresh; double refresh_interval = 1000000.0 / grabc->mon->wlr_output->refresh;
if (!start_drag_window && offsetx == 0 && offsety == 0) { if (!start_drag_window && isdrag) {
drag_begin_cursorx = cursor->x; drag_begin_cursorx = cursor->x;
drag_begin_cursory = cursor->y; drag_begin_cursory = cursor->y;
start_drag_window = true; start_drag_window = true;
@ -394,7 +394,7 @@ void resize_tile_scroller(Client *grabc, int offsetx, int offsety,
} else { } else {
// 计算相对于屏幕尺寸的比例变化 // 计算相对于屏幕尺寸的比例变化
// 计算相对于屏幕尺寸的比例变化 // 计算相对于屏幕尺寸的比例变化
if (!offsetx && !offsety) { if (isdrag) {
offsetx = cursor->x - drag_begin_cursorx; offsetx = cursor->x - drag_begin_cursorx;
offsety = cursor->y - drag_begin_cursory; offsety = cursor->y - drag_begin_cursory;
@ -418,7 +418,7 @@ void resize_tile_scroller(Client *grabc, int offsetx, int offsety,
bool moving_left; bool moving_left;
bool moving_right; bool moving_right;
if (offsetx || offsety) { if (!isdrag) {
moving_up = offsety < 0 ? true : false; moving_up = offsety < 0 ? true : false;
moving_down = offsety > 0 ? true : false; moving_down = offsety > 0 ? true : false;
moving_left = offsetx < 0 ? true : false; moving_left = offsetx < 0 ? true : false;
@ -459,7 +459,7 @@ void resize_tile_scroller(Client *grabc, int offsetx, int offsety,
grabc->scroller_proportion = new_scroller_proportion; grabc->scroller_proportion = new_scroller_proportion;
if (offsetx || offsety) { if (!isdrag) {
arrange(grabc->mon, false); arrange(grabc->mon, false);
return; return;
} }
@ -472,7 +472,7 @@ void resize_tile_scroller(Client *grabc, int offsetx, int offsety,
} }
} }
void resize_tile_client(Client *grabc, int offsetx, int offsety, void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
unsigned int time) { unsigned int time) {
const Layout *current_layout = const Layout *current_layout =
grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag]; grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag];
@ -480,15 +480,15 @@ void resize_tile_client(Client *grabc, int offsetx, int offsety,
current_layout->id == CENTER_TILE current_layout->id == CENTER_TILE
) { ) {
resize_tile_master_horizontal(grabc, offsetx, offsety, time, resize_tile_master_horizontal(grabc, isdrag, offsetx, offsety, time,
current_layout->id); current_layout->id);
} else if (current_layout->id == VERTICAL_TILE) { } else if (current_layout->id == VERTICAL_TILE) {
resize_tile_master_vertical(grabc, offsetx, offsety, time, resize_tile_master_vertical(grabc, isdrag, offsetx, offsety, time,
current_layout->id); current_layout->id);
} else if (current_layout->id == SCROLLER) { } else if (current_layout->id == SCROLLER) {
resize_tile_scroller(grabc, offsetx, offsety, time, false); resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, false);
} else if (current_layout->id == VERTICAL_SCROLLER) { } else if (current_layout->id == VERTICAL_SCROLLER) {
resize_tile_scroller(grabc, offsetx, offsety, time, true); resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, true);
} }
} }

View file

@ -715,8 +715,8 @@ static void enable_adaptive_sync(Monitor *m, struct wlr_output_state *state);
static Client *get_next_stack_client(Client *c, bool reverse); static Client *get_next_stack_client(Client *c, bool reverse);
static void set_float_malposition(Client *tc); static void set_float_malposition(Client *tc);
static void set_size_per(Monitor *m, Client *c); static void set_size_per(Monitor *m, Client *c);
static void resize_tile_client(Client *grabc, int offsetx, int offsety, static void resize_tile_client(Client *grabc, bool isdrag, int offsetx,
unsigned int time); int offsety, unsigned int time);
#include "data/static_keymap.h" #include "data/static_keymap.h"
#include "dispatch/bind_declare.h" #include "dispatch/bind_declare.h"
@ -3847,7 +3847,7 @@ void motionnotify(unsigned int time, struct wlr_input_device *device, double dx,
resize(grabc, grabc->float_geom, 1); resize(grabc, grabc->float_geom, 1);
return; return;
} else { } else {
resize_tile_client(grabc, 0, 0, time); resize_tile_client(grabc, true, 0, 0, time);
} }
} }