format code

This commit is contained in:
DreamMaoMao 2025-05-07 17:40:27 +08:00
parent bb0e360f27
commit 2a60dd433b
2 changed files with 344 additions and 311 deletions

View file

@ -429,7 +429,8 @@ unsigned int parse_num_type(char *str) {
}
}
FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_value2, char *arg_value3, char *arg_value4) {
FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
char *arg_value2, char *arg_value3, char *arg_value4) {
FuncType func = NULL;
(*arg).v = NULL;
@ -557,14 +558,18 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_v
func = resizewin;
(*arg).ui = parse_num_type(arg_value);
(*arg).ui2 = parse_num_type(arg_value2);
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
(*arg).i =
(*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value + 1);
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2)
: atoi(arg_value2 + 1);
} else if (strcmp(func_name, "movewin") == 0) {
func = movewin;
(*arg).ui = parse_num_type(arg_value);
(*arg).ui2 = parse_num_type(arg_value2);
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
(*arg).i =
(*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value + 1);
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2)
: atoi(arg_value2 + 1);
} else if (strcmp(func_name, "toggle_named_scratch") == 0) {
func = toggle_named_scratch;
(*arg).v = strdup(arg_value);
@ -917,7 +922,8 @@ void parse_config_line(Config *config, const char *line) {
fprintf(stderr, "Error: Invalid autostart format: %s\n", value);
}
} else if (strcmp(key, "tags") == 0) {
config->tag_rules = realloc(config->tag_rules,
config->tag_rules =
realloc(config->tag_rules,
(config->tag_rules_count + 1) * sizeof(ConfigTagRule));
if (!config->tag_rules) {
fprintf(stderr, "Error: Failed to allocate memory for tag rules\n");
@ -1085,7 +1091,8 @@ void parse_config_line(Config *config, const char *line) {
setenv(env_type, env_value, 1);
} else if (strncmp(key, "exec", 9) == 0) {
char **new_exec = realloc(config->exec, (config->exec_count + 1) * sizeof(char *));
char **new_exec =
realloc(config->exec, (config->exec_count + 1) * sizeof(char *));
if (!new_exec) {
fprintf(stderr, "Error: Failed to allocate memory for exec\n");
return;
@ -1102,7 +1109,8 @@ void parse_config_line(Config *config, const char *line) {
} else if (strncmp(key, "exec-once", 9) == 0) {
char **new_exec_once = realloc(config->exec_once, (config->exec_once_count + 1) * sizeof(char *));
char **new_exec_once = realloc(
config->exec_once, (config->exec_once_count + 1) * sizeof(char *));
if (!new_exec_once) {
fprintf(stderr, "Error: Failed to allocate memory for exec_once\n");
return;
@ -1129,9 +1137,12 @@ void parse_config_line(Config *config, const char *line) {
KeyBinding *binding = &config->key_bindings[config->key_bindings_count];
memset(binding, 0, sizeof(KeyBinding));
char mod_str[256], keysym_str[256], func_name[256], arg_value[256] = "none",arg_value2[256] = "none", arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, keysym_str,
func_name, arg_value, arg_value2, arg_value3, arg_value4) < 3) {
char mod_str[256], keysym_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none",
arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str,
keysym_str, func_name, arg_value, arg_value2, arg_value3,
arg_value4) < 3) {
fprintf(stderr, "Error: Invalid bind format: %s\n", value);
return;
}
@ -1140,7 +1151,8 @@ void parse_config_line(Config *config, const char *line) {
binding->keysym = parse_keysym(keysym_str);
binding->arg.v = NULL;
binding->arg.v2 = NULL;
binding->func = parse_func_name(func_name, &binding->arg, arg_value, arg_value2, arg_value3, arg_value4);
binding->func = parse_func_name(func_name, &binding->arg, arg_value,
arg_value2, arg_value3, arg_value4);
if (!binding->func) {
if (binding->arg.v) {
free(binding->arg.v);
@ -1168,9 +1180,12 @@ void parse_config_line(Config *config, const char *line) {
&config->mouse_bindings[config->mouse_bindings_count];
memset(binding, 0, sizeof(MouseBinding));
char mod_str[256], button_str[256], func_name[256], arg_value[256] = "none", arg_value2[256] = "none", arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, button_str,
func_name, arg_value, arg_value2, arg_value3, arg_value4) < 3) {
char mod_str[256], button_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none",
arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str,
button_str, func_name, arg_value, arg_value2, arg_value3,
arg_value4) < 3) {
fprintf(stderr, "Error: Invalid mousebind format: %s\n", value);
return;
}
@ -1179,7 +1194,8 @@ void parse_config_line(Config *config, const char *line) {
binding->button = parse_button(button_str);
binding->arg.v = NULL;
binding->arg.v2 = NULL;
binding->func = parse_func_name(func_name, &binding->arg, arg_value, arg_value2, arg_value3, arg_value4);
binding->func = parse_func_name(func_name, &binding->arg, arg_value,
arg_value2, arg_value3, arg_value4);
if (!binding->func) {
if (binding->arg.v) {
free(binding->arg.v);
@ -1205,9 +1221,12 @@ void parse_config_line(Config *config, const char *line) {
AxisBinding *binding = &config->axis_bindings[config->axis_bindings_count];
memset(binding, 0, sizeof(AxisBinding));
char mod_str[256], dir_str[256], func_name[256], arg_value[256] = "none", arg_value2[256] = "none", arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, dir_str, func_name,
arg_value, arg_value2, arg_value3, arg_value4) < 3) {
char mod_str[256], dir_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none",
arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str,
dir_str, func_name, arg_value, arg_value2, arg_value3,
arg_value4) < 3) {
fprintf(stderr, "Error: Invalid axisbind format: %s\n", value);
return;
}
@ -1216,7 +1235,8 @@ void parse_config_line(Config *config, const char *line) {
binding->dir = parse_direction(dir_str);
binding->arg.v = NULL;
binding->arg.v2 = NULL;
binding->func = parse_func_name(func_name, &binding->arg, arg_value, arg_value2, arg_value3, arg_value4);
binding->func = parse_func_name(func_name, &binding->arg, arg_value,
arg_value2, arg_value3, arg_value4);
if (!binding->func) {
if (binding->arg.v) {
@ -1247,9 +1267,11 @@ void parse_config_line(Config *config, const char *line) {
memset(binding, 0, sizeof(GestureBinding));
char mod_str[256], motion_str[256], fingers_count_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none", arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, motion_str,
fingers_count_str, func_name, arg_value, arg_value2, arg_value3, arg_value4) < 4) {
arg_value[256] = "none", arg_value2[256] = "none",
arg_value3[256] = "none", arg_value4[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, motion_str, fingers_count_str, func_name, arg_value,
arg_value2, arg_value3, arg_value4) < 4) {
fprintf(stderr, "Error: Invalid gesturebind format: %s\n", value);
return;
}
@ -1259,7 +1281,8 @@ void parse_config_line(Config *config, const char *line) {
binding->fingers_count = atoi(fingers_count_str);
binding->arg.v = NULL;
binding->arg.v2 = NULL;
binding->func = parse_func_name(func_name, &binding->arg, arg_value, arg_value2, arg_value3, arg_value4);
binding->func = parse_func_name(func_name, &binding->arg, arg_value,
arg_value2, arg_value3, arg_value4);
if (!binding->func) {
if (binding->arg.v) {
@ -1481,7 +1504,6 @@ void free_config(void) {
// 释放动画资源
free_baked_points();
}
void override_config(void) {
@ -1800,7 +1822,8 @@ void reload_config(const Arg *arg) {
if (i > 0 && strlen(config.tag_rules[i - 1].layout_name) > 0) {
for (jk = 0; jk < LENGTH(layouts); jk++) {
if (strcmp(layouts[jk].name, config.tag_rules[i - 1].layout_name) == 0) {
if (strcmp(layouts[jk].name, config.tag_rules[i - 1].layout_name) ==
0) {
m->pertag->ltidxs[i] = &layouts[jk];
}
}

View file

@ -203,8 +203,8 @@ typedef struct Client Client;
struct Client {
/* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */
struct wlr_box geom, pending, oldgeom,scratch_geom, animainit_geom, overview_backup_geom,
current; /* layout-relative, includes border */
struct wlr_box geom, pending, oldgeom, scratch_geom, animainit_geom,
overview_backup_geom, current; /* layout-relative, includes border */
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
@ -497,10 +497,8 @@ static void dwl_ipc_output_quit(struct wl_client *client,
struct wl_resource *resource);
static void dwl_ipc_output_dispatch(struct wl_client *client,
struct wl_resource *resource,
const char *dispatch,
const char* arg1,
const char* arg2,
const char* arg3,
const char *dispatch, const char *arg1,
const char *arg2, const char *arg3,
const char *arg4);
static void dwl_ipc_output_release(struct wl_client *client,
struct wl_resource *resource);
@ -1075,7 +1073,8 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
}
for (i = 0; i < config.tag_rules_count; i++) {
if(c->tags & (1 << (config.tag_rules[i].id - 1)) && config.tag_rules[i].no_render_border) {
if (c->tags & (1 << (config.tag_rules[i].id - 1)) &&
config.tag_rules[i].no_render_border) {
set_rect_size(c->border[0], 0, 0);
set_rect_size(c->border[1], 0, 0);
set_rect_size(c->border[2], 0, 0);
@ -1102,21 +1101,28 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
clip_box.height - 2 * c->bw);
} else if (c->animation.current.x + c->animation.current.width >
c->mon->m.x + c->mon->m.width) {
set_rect_size(c->border[3], GEZERO(c->bw - (c->animation.current.x + c->animation.current.width - c->mon->m.x + c->mon->m.width)),
set_rect_size(
c->border[3],
GEZERO(c->bw - (c->animation.current.x + c->animation.current.width -
c->mon->m.x + c->mon->m.width)),
clip_box.height - 2 * c->bw);
} else if (c->animation.current.y < c->mon->m.y) {
set_rect_size(c->border[0], clip_box.width, GEZERO(c->bw - offsety));
} else if (c->animation.current.y + c->animation.current.height >
c->mon->m.y + c->mon->m.height) {
set_rect_size(c->border[1], clip_box.width, GEZERO(c->bw - (c->animation.current.y + c->animation.current.height - c->mon->m.y + c->mon->m.height)));
set_rect_size(
c->border[1], clip_box.width,
GEZERO(c->bw - (c->animation.current.y + c->animation.current.height -
c->mon->m.y + c->mon->m.height)));
}
}
wlr_scene_node_set_position(&c->border[0]->node, offsetx, offsety);
wlr_scene_node_set_position(&c->border[2]->node, offsetx, c->bw + offsety);
wlr_scene_node_set_position(&c->border[1]->node, offsetx, clip_box.height - c->bw + offsety);
wlr_scene_node_set_position(&c->border[3]->node, clip_box.width - c->bw + offsetx,
c->bw + offsety);
wlr_scene_node_set_position(&c->border[1]->node, offsetx,
clip_box.height - c->bw + offsety);
wlr_scene_node_set_position(
&c->border[3]->node, clip_box.width - c->bw + offsetx, c->bw + offsety);
}
struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
@ -1349,15 +1355,22 @@ void show_scratchpad(Client *c) {
/* return if fullscreen */
if (!c->isfloating) {
setfloating(c, 1);
c->geom.width = c->scratch_geom.width ? c->scratch_geom.width: c->mon->w.width * 0.7;
c->geom.height = c->scratch_geom.height? c->scratch_geom.height : c->mon->w.height * 0.8;
c->geom.width =
c->scratch_geom.width ? c->scratch_geom.width : c->mon->w.width * 0.7;
c->geom.height = c->scratch_geom.height ? c->scratch_geom.height
: c->mon->w.height * 0.8;
// 重新计算居中的坐标
c->geom = c->animainit_geom = c->animation.current = setclient_coordinate_center(c->geom, 0, 0);
c->geom = c->animainit_geom = c->animation.current =
setclient_coordinate_center(c->geom, 0, 0);
resize(c, c->geom, 0);
} else if(c->geom.width != c->scratch_geom.width || c->geom.height != c->scratch_geom.height) {
c->geom.width = c->scratch_geom.width ? c->scratch_geom.width: c->mon->w.width * 0.7;
c->geom.height = c->scratch_geom.height? c->scratch_geom.height : c->mon->w.height * 0.8;
c->geom = c->animainit_geom = c->animation.current = setclient_coordinate_center(c->geom, 0, 0);
} else if (c->geom.width != c->scratch_geom.width ||
c->geom.height != c->scratch_geom.height) {
c->geom.width =
c->scratch_geom.width ? c->scratch_geom.width : c->mon->w.width * 0.7;
c->geom.height = c->scratch_geom.height ? c->scratch_geom.height
: c->mon->w.height * 0.8;
c->geom = c->animainit_geom = c->animation.current =
setclient_coordinate_center(c->geom, 0, 0);
resize(c, c->geom, 0);
}
c->oldtags = selmon->tagset[selmon->seltags];
@ -1593,11 +1606,10 @@ void gpureset(struct wl_listener *listener, void *data) {
wlr_renderer_destroy(old_drw);
}
void
handlesig(int signo)
{
void handlesig(int signo) {
if (signo == SIGCHLD)
while (waitpid(-1, NULL, WNOHANG) > 0);
while (waitpid(-1, NULL, WNOHANG) > 0)
;
else if (signo == SIGINT || signo == SIGTERM)
quit(NULL);
}
@ -1752,8 +1764,10 @@ applyrules(Client *c) {
strstr(title, r->title))) {
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow;
c->scratch_geom.width = r->scratch_width > 0 ? r->scratch_width : c->scratch_geom.width;
c->scratch_geom.height = r->scratch_height > 0 ? r->scratch_height : c->scratch_geom.height;
c->scratch_geom.width =
r->scratch_width > 0 ? r->scratch_width : c->scratch_geom.width;
c->scratch_geom.height =
r->scratch_height > 0 ? r->scratch_height : c->scratch_geom.height;
c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating;
c->isfullscreen = r->isfullscreen > 0 ? r->isfullscreen : c->isfullscreen;
c->animation_type_open = r->animation_type_open == NULL
@ -2021,8 +2035,7 @@ void apply_window_snap(Client *c) {
snap_left_mon = c->geom.x - c->mon->m.x;
snap_right_mon = c->mon->m.x + c->mon->m.width - c->geom.x - c->geom.width;
snap_up_mon = c->geom.y - c->mon->m.y;
snap_down_mon =
c->mon->m.y + c->mon->m.height - c->geom.y - c->geom.height;
snap_down_mon = c->mon->m.y + c->mon->m.height - c->geom.y - c->geom.height;
if (snap_up_mon > 0 && snap_up_mon < snap_up)
snap_up = snap_up_mon;
@ -2033,7 +2046,6 @@ void apply_window_snap(Client *c) {
if (snap_right_mon > 0 && snap_right_mon < snap_right)
snap_right = snap_right_mon;
snap_left_screen = c->geom.x - c->mon->w.x;
snap_right_screen = c->mon->w.x + c->mon->w.width - c->geom.x - c->geom.width;
snap_up_screen = c->geom.y - c->mon->w.y;
@ -2309,7 +2321,8 @@ char* get_autostart_path(char *autostart_path, size_t buf_size) {
fprintf(stderr, "Error: HOME environment variable not set.\n");
return NULL;
}
snprintf(autostart_path, buf_size, "%s/.config/maomao/autostart.sh", homedir);
snprintf(autostart_path, buf_size, "%s/.config/maomao/autostart.sh",
homedir);
}
return autostart_path;
@ -3143,7 +3156,8 @@ void createmon(struct wl_listener *listener, void *data) {
if (i > 0 && strlen(config.tag_rules[i - 1].layout_name) > 0) {
for (jk = 0; jk < LENGTH(layouts); jk++) {
if (strcmp(layouts[jk].name, config.tag_rules[i - 1].layout_name) == 0) {
if (strcmp(layouts[jk].name, config.tag_rules[i - 1].layout_name) ==
0) {
m->pertag->ltidxs[i] = &layouts[jk];
}
}
@ -3616,17 +3630,17 @@ void dwl_ipc_output_quit(struct wl_client *client,
}
void dwl_ipc_output_dispatch(struct wl_client *client,
struct wl_resource *resource,
const char *dispatch, const char *arg1,
const char *arg2, const char *arg3, const char *arg4) {
struct wl_resource *resource, const char *dispatch,
const char *arg1, const char *arg2,
const char *arg3, const char *arg4) {
void (*func)(const Arg *);
Arg arg;
func = parse_func_name((char*)dispatch, &arg, (char*)arg1, (char*)arg2, (char*)arg3, (char*)arg4);
func = parse_func_name((char *)dispatch, &arg, (char *)arg1, (char *)arg2,
(char *)arg3, (char *)arg4);
if (func) {
func(&arg);
}
}
void dwl_ipc_output_release(struct wl_client *client,
@ -3672,7 +3686,8 @@ void focusclient(Client *c, int lift) {
// decide whether need to re-arrange
if (c && selmon->prevsel && !selmon->prevsel->isfloating &&
(selmon->prevsel->tags & selmon->tagset[selmon->seltags]) && (c->tags & selmon->tagset[selmon->seltags]) && !c->isfloating &&
(selmon->prevsel->tags & selmon->tagset[selmon->seltags]) &&
(c->tags & selmon->tagset[selmon->seltags]) && !c->isfloating &&
!c->isfullscreen &&
strcmp(selmon->pertag->ltidxs[selmon->pertag->curtag]->name,
"scroller") == 0) {
@ -5149,7 +5164,8 @@ run(char *startup_cmd) {
/* Now that the socket exists and the backend is started, run the startup
* command */
if (!startup_cmd)
startup_cmd = get_autostart_path(autostart_temp_path, sizeof(autostart_temp_path));
startup_cmd =
get_autostart_path(autostart_temp_path, sizeof(autostart_temp_path));
if (startup_cmd) {
int piperw[2];
if (pipe(piperw) < 0)
@ -5999,9 +6015,7 @@ void tagmon(const Arg *arg) {
}
}
void overview(Monitor *m) {
grid(m);
}
void overview(Monitor *m) { grid(m); }
void fibonacci(Monitor *mon, int s) {
unsigned int i = 0, n = 0, nx, ny, nw, nh;
@ -6012,10 +6026,10 @@ void fibonacci(Monitor *mon, int s) {
unsigned int cur_gappov = enablegaps ? mon->gappov : 0;
// Count visible clients
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, mon) && !c->isfloating && !c->iskilling &&
!c->isfullscreen && !c->ismaxmizescreen && !c->animation.tagouting)
n++;
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && !c->isfloating &&
!c->iskilling && !c->isfullscreen &&
!c->ismaxmizescreen &&
!c->animation.tagouting) n++;
if (n == 0)
return;
@ -6068,7 +6082,8 @@ void fibonacci(Monitor *mon, int s) {
if (i == 0) {
if (n != 1)
nw = (mon->w.width - 2 * cur_gappoh) * mon->pertag->mfacts[mon->pertag->curtag];
nw = (mon->w.width - 2 * cur_gappoh) *
mon->pertag->mfacts[mon->pertag->curtag];
ny = mon->w.y + cur_gappov;
} else if (i == 1) {
nw = mon->w.width - 2 * cur_gappoh - nw - cur_gappih;
@ -6096,39 +6111,32 @@ void fibonacci(Monitor *mon, int s) {
nc->isfullscreen || nc->ismaxmizescreen || nc->animation.tagouting)
continue;
if (c == nc) continue;
if (c == nc)
continue;
// Check for right neighbor
if (c->geom.y == nc->geom.y &&
c->geom.x + c->geom.width == nc->geom.x) {
if (c->geom.y == nc->geom.y && c->geom.x + c->geom.width == nc->geom.x) {
right_gap = cur_gappih;
}
// Check for bottom neighbor
if (c->geom.x == nc->geom.x &&
c->geom.y + c->geom.height == nc->geom.y) {
if (c->geom.x == nc->geom.x && c->geom.y + c->geom.height == nc->geom.y) {
bottom_gap = cur_gappiv;
}
}
resize(c,
(struct wlr_box){
.x = c->geom.x,
(struct wlr_box){.x = c->geom.x,
.y = c->geom.y,
.width = c->geom.width - right_gap,
.height = c->geom.height - bottom_gap
},
.height = c->geom.height - bottom_gap},
0);
}
}
void dwindle(Monitor *mon) {
fibonacci(mon, 1);
}
void dwindle(Monitor *mon) { fibonacci(mon, 1); }
void spiral(Monitor *mon) {
fibonacci(mon, 0);
}
void spiral(Monitor *mon) { fibonacci(mon, 0); }
// 网格布局窗口大小和位置计算
void grid(Monitor *m) {
@ -6208,7 +6216,8 @@ void grid(Monitor *m) {
// 处理多余的列
overcols = n % cols;
if (overcols) {
dx = (m->w.width - overcols * cw - (overcols - 1) * overviewgappi) / 2 - overviewgappo;
dx = (m->w.width - overcols * cw - (overcols - 1) * overviewgappi) / 2 -
overviewgappo;
}
// 调整每个客户端的位置和大小
@ -6245,7 +6254,8 @@ void scroller(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int max_client_width = m->w.width - 2 * scroller_structs - cur_gappih;
unsigned int max_client_width =
m->w.width - 2 * scroller_structs - cur_gappih;
// 第一次遍历,计算 n 的值
wl_list_for_each(c, &clients, link) {
@ -6349,15 +6359,16 @@ void scroller(Monitor *m) {
for (i = 1; i <= focus_client_index; i++) {
c = tempClients[focus_client_index - i];
target_geom.width = max_client_width * c->scroller_proportion;
target_geom.x = tempClients[focus_client_index - i + 1]->geom.x - cur_gappih -
target_geom.width;
target_geom.x = tempClients[focus_client_index - i + 1]->geom.x -
cur_gappih - target_geom.width;
resize(c, target_geom, 0);
}
for (i = 1; i < n - focus_client_index; i++) {
c = tempClients[focus_client_index + i];
target_geom.width = max_client_width * c->scroller_proportion;
target_geom.x = tempClients[focus_client_index + i - 1]->geom.x + cur_gappih +
target_geom.x = tempClients[focus_client_index + i - 1]->geom.x +
cur_gappih +
tempClients[focus_client_index + i - 1]->geom.width;
resize(c, target_geom, 0);
}
@ -7426,7 +7437,6 @@ void movewin(const Arg *arg) {
resize(c, c->geom, 0);
}
void smartmovewin(const Arg *arg) {
Client *c, *tc;
int nx, ny;