diff --git a/config.conf b/config.conf index 4c8d8d3..e72ee09 100644 --- a/config.conf +++ b/config.conf @@ -57,6 +57,7 @@ scroller_prefer_center=0 edge_scroller_pointer_focus=1 scroller_default_proportion_single=1.0 scroller_proportion_preset=0.5,0.8,1.0 +dual_scroller_default_split_ratio=0.3 # Master-Stack Layout Setting new_is_master=1 @@ -237,6 +238,10 @@ bind=CTRL+ALT,Down,resizewin,+0,+50 bind=CTRL+ALT,Left,resizewin,-50,+0 bind=CTRL+ALT,Right,resizewin,+50,+0 +# dual-scroller split adjustment (increase/decrease top row height) +# bind=SUPER+SHIFT,Equal,adjust_dual_scroller_split,0.05 +# bind=SUPER+SHIFT,Minus,adjust_dual_scroller_split,-0.05 + # Mouse Button Bindings # NONE mode key only work in ov mode mousebind=SUPER,btn_left,moveresize,curmove diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 5cff79b..7c772dc 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -200,6 +200,7 @@ typedef struct { int scroller_focus_center; int scroller_prefer_center; int edge_scroller_pointer_focus; + float dual_scroller_default_split_ratio; int focus_cross_monitor; int exchange_cross_monitor; int scratchpad_cross_monitor; @@ -822,6 +823,9 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, } else if (strcmp(func_name, "setmfact") == 0) { func = setmfact; (*arg).f = atof(arg_value); + } else if (strcmp(func_name, "adjust_dual_scroller_split") == 0) { + func = adjust_dual_scroller_split; + (*arg).f = atof(arg_value); } else if (strcmp(func_name, "zoom") == 0) { func = zoom; } else if (strcmp(func_name, "exchange_client") == 0) { @@ -1167,6 +1171,8 @@ void parse_option(Config *config, char *key, char *value) { config->scroller_prefer_center = atoi(value); } else if (strcmp(key, "edge_scroller_pointer_focus") == 0) { config->edge_scroller_pointer_focus = atoi(value); + } else if (strcmp(key, "dual_scroller_default_split_ratio") == 0) { + config->dual_scroller_default_split_ratio = atof(value); } else if (strcmp(key, "focus_cross_monitor") == 0) { config->focus_cross_monitor = atoi(value); } else if (strcmp(key, "exchange_cross_monitor") == 0) { @@ -2652,6 +2658,8 @@ void override_config(void) { edge_scroller_pointer_focus = CLAMP_INT(config.edge_scroller_pointer_focus, 0, 1); scroller_structs = CLAMP_INT(config.scroller_structs, 0, 1000); + dual_scroller_default_split_ratio = + CLAMP_FLOAT(config.dual_scroller_default_split_ratio, 0.1f, 0.9f); // 主从布局设置 default_mfact = CLAMP_FLOAT(config.default_mfact, 0.1f, 0.9f); @@ -2840,6 +2848,7 @@ void set_value_default() { config.scroller_focus_center = scroller_focus_center; config.scroller_prefer_center = scroller_prefer_center; config.edge_scroller_pointer_focus = edge_scroller_pointer_focus; + config.dual_scroller_default_split_ratio = dual_scroller_default_split_ratio; config.focus_cross_monitor = focus_cross_monitor; config.exchange_cross_monitor = exchange_cross_monitor; config.scratchpad_cross_monitor = scratchpad_cross_monitor; diff --git a/src/config/preset.h b/src/config/preset.h index eaa7be2..a49ec7d 100644 --- a/src/config/preset.h +++ b/src/config/preset.h @@ -63,6 +63,7 @@ float scroller_default_proportion_single = 1.0; int scroller_ignore_proportion_single = 0; int scroller_focus_center = 0; int scroller_prefer_center = 0; +float dual_scroller_default_split_ratio = 0.3; int focus_cross_monitor = 0; int focus_cross_tag = 0; int exchange_cross_monitor = 0; diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index 17f0422..03fc6cc 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -29,6 +29,7 @@ int switch_keyboard_layout(const Arg *arg); int setlayout(const Arg *arg); int switch_layout(const Arg *arg); int setmfact(const Arg *arg); +int adjust_dual_scroller_split(const Arg *arg); int quit(const Arg *arg); int moveresize(const Arg *arg); int exchange_client(const Arg *arg); diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 6f78978..99668bc 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -330,6 +330,28 @@ int setmfact(const Arg *arg) { return 0; } +int adjust_dual_scroller_split(const Arg *arg) { + float new_ratio; + + if (!arg || !selmon) + return 0; + + // Check if we're in a dual-scroller layout + if (!is_row_layout(selmon)) + return 0; + + // Calculate new ratio: if arg->f < 1.0, treat as relative adjustment, otherwise as absolute value + new_ratio = arg->f < 1.0 ? dual_scroller_default_split_ratio + arg->f : arg->f - 1.0; + + // Clamp the ratio between 0.1 and 0.9 + if (new_ratio < 0.1 || new_ratio > 0.9) + return 0; + + dual_scroller_default_split_ratio = new_ratio; + arrange(selmon, false); + return 0; +} + int killclient(const Arg *arg) { Client *c = NULL; c = selmon->sel; diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index 6477186..fcd50ee 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -454,8 +454,8 @@ void dual_scroller(Monitor *m) { } } - // Calculate row heights (30% top, 70% bottom) - unsigned int top_row_height = (unsigned int)((m->w.height - 2 * cur_gappov - cur_gappiv) * 0.3); + // Calculate row heights using configurable split ratio + unsigned int top_row_height = (unsigned int)((m->w.height - 2 * cur_gappov - cur_gappiv) * dual_scroller_default_split_ratio); unsigned int bottom_row_height = m->w.height - 2 * cur_gappov - cur_gappiv - top_row_height; unsigned int top_row_y = m->w.y + cur_gappov; unsigned int bottom_row_y = top_row_y + top_row_height + cur_gappiv;