mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-04 13:29:56 -05:00
format code
This commit is contained in:
parent
bb0e360f27
commit
2a60dd433b
2 changed files with 344 additions and 311 deletions
|
|
@ -90,7 +90,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int id; // 标签ID (1-9)
|
int id; // 标签ID (1-9)
|
||||||
char* layout_name; // 布局名称
|
char *layout_name; // 布局名称
|
||||||
int no_render_border;
|
int no_render_border;
|
||||||
} ConfigTagRule;
|
} ConfigTagRule;
|
||||||
|
|
||||||
|
|
@ -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;
|
FuncType func = NULL;
|
||||||
(*arg).v = 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;
|
func = resizewin;
|
||||||
(*arg).ui = parse_num_type(arg_value);
|
(*arg).ui = parse_num_type(arg_value);
|
||||||
(*arg).ui2 = parse_num_type(arg_value2);
|
(*arg).ui2 = parse_num_type(arg_value2);
|
||||||
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
|
(*arg).i =
|
||||||
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
|
(*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) {
|
} else if (strcmp(func_name, "movewin") == 0) {
|
||||||
func = movewin;
|
func = movewin;
|
||||||
(*arg).ui = parse_num_type(arg_value);
|
(*arg).ui = parse_num_type(arg_value);
|
||||||
(*arg).ui2 = parse_num_type(arg_value2);
|
(*arg).ui2 = parse_num_type(arg_value2);
|
||||||
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
|
(*arg).i =
|
||||||
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
|
(*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) {
|
} else if (strcmp(func_name, "toggle_named_scratch") == 0) {
|
||||||
func = toggle_named_scratch;
|
func = toggle_named_scratch;
|
||||||
(*arg).v = strdup(arg_value);
|
(*arg).v = strdup(arg_value);
|
||||||
|
|
@ -580,7 +585,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_v
|
||||||
void run_exec() {
|
void run_exec() {
|
||||||
Arg arg;
|
Arg arg;
|
||||||
|
|
||||||
for(int i = 0; i < config.exec_count; i++) {
|
for (int i = 0; i < config.exec_count; i++) {
|
||||||
arg.v = config.exec[i];
|
arg.v = config.exec[i];
|
||||||
spawn(&arg);
|
spawn(&arg);
|
||||||
}
|
}
|
||||||
|
|
@ -589,7 +594,7 @@ void run_exec() {
|
||||||
void run_exec_once() {
|
void run_exec_once() {
|
||||||
Arg arg;
|
Arg arg;
|
||||||
|
|
||||||
for(int i = 0; i < config.exec_once_count; i++) {
|
for (int i = 0; i < config.exec_once_count; i++) {
|
||||||
arg.v = config.exec_once[i];
|
arg.v = config.exec_once[i];
|
||||||
spawn(&arg);
|
spawn(&arg);
|
||||||
}
|
}
|
||||||
|
|
@ -917,7 +922,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
fprintf(stderr, "Error: Invalid autostart format: %s\n", value);
|
fprintf(stderr, "Error: Invalid autostart format: %s\n", value);
|
||||||
}
|
}
|
||||||
} else if (strcmp(key, "tags") == 0) {
|
} 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));
|
(config->tag_rules_count + 1) * sizeof(ConfigTagRule));
|
||||||
if (!config->tag_rules) {
|
if (!config->tag_rules) {
|
||||||
fprintf(stderr, "Error: Failed to allocate memory for tag rules\n");
|
fprintf(stderr, "Error: Failed to allocate memory for tag rules\n");
|
||||||
|
|
@ -1078,14 +1084,15 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
} else if (strncmp(key, "env", 3) == 0) {
|
} else if (strncmp(key, "env", 3) == 0) {
|
||||||
|
|
||||||
char env_type[256], env_value[256];
|
char env_type[256], env_value[256];
|
||||||
if (sscanf(value, "%[^,],%[^\n]", env_type,env_value) < 2) {
|
if (sscanf(value, "%[^,],%[^\n]", env_type, env_value) < 2) {
|
||||||
fprintf(stderr, "Error: Invalid bind format: %s\n", value);
|
fprintf(stderr, "Error: Invalid bind format: %s\n", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setenv(env_type, env_value, 1);
|
setenv(env_type, env_value, 1);
|
||||||
|
|
||||||
} else if (strncmp(key, "exec", 9) == 0) {
|
} 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) {
|
if (!new_exec) {
|
||||||
fprintf(stderr, "Error: Failed to allocate memory for exec\n");
|
fprintf(stderr, "Error: Failed to allocate memory for exec\n");
|
||||||
return;
|
return;
|
||||||
|
|
@ -1102,7 +1109,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
|
|
||||||
} else if (strncmp(key, "exec-once", 9) == 0) {
|
} 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) {
|
if (!new_exec_once) {
|
||||||
fprintf(stderr, "Error: Failed to allocate memory for exec_once\n");
|
fprintf(stderr, "Error: Failed to allocate memory for exec_once\n");
|
||||||
return;
|
return;
|
||||||
|
|
@ -1129,9 +1137,12 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
KeyBinding *binding = &config->key_bindings[config->key_bindings_count];
|
KeyBinding *binding = &config->key_bindings[config->key_bindings_count];
|
||||||
memset(binding, 0, sizeof(KeyBinding));
|
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";
|
char mod_str[256], keysym_str[256], func_name[256],
|
||||||
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, keysym_str,
|
arg_value[256] = "none", arg_value2[256] = "none",
|
||||||
func_name, arg_value, arg_value2, arg_value3, arg_value4) < 3) {
|
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);
|
fprintf(stderr, "Error: Invalid bind format: %s\n", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1140,7 +1151,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
binding->keysym = parse_keysym(keysym_str);
|
binding->keysym = parse_keysym(keysym_str);
|
||||||
binding->arg.v = NULL;
|
binding->arg.v = NULL;
|
||||||
binding->arg.v2 = 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->func) {
|
||||||
if (binding->arg.v) {
|
if (binding->arg.v) {
|
||||||
free(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];
|
&config->mouse_bindings[config->mouse_bindings_count];
|
||||||
memset(binding, 0, sizeof(MouseBinding));
|
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";
|
char mod_str[256], button_str[256], func_name[256],
|
||||||
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, button_str,
|
arg_value[256] = "none", arg_value2[256] = "none",
|
||||||
func_name, arg_value, arg_value2, arg_value3, arg_value4) < 3) {
|
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);
|
fprintf(stderr, "Error: Invalid mousebind format: %s\n", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1179,7 +1194,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
binding->button = parse_button(button_str);
|
binding->button = parse_button(button_str);
|
||||||
binding->arg.v = NULL;
|
binding->arg.v = NULL;
|
||||||
binding->arg.v2 = 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->func) {
|
||||||
if (binding->arg.v) {
|
if (binding->arg.v) {
|
||||||
free(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];
|
AxisBinding *binding = &config->axis_bindings[config->axis_bindings_count];
|
||||||
memset(binding, 0, sizeof(AxisBinding));
|
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";
|
char mod_str[256], dir_str[256], func_name[256],
|
||||||
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, dir_str, func_name,
|
arg_value[256] = "none", arg_value2[256] = "none",
|
||||||
arg_value, arg_value2, arg_value3, arg_value4) < 3) {
|
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);
|
fprintf(stderr, "Error: Invalid axisbind format: %s\n", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1216,7 +1235,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
binding->dir = parse_direction(dir_str);
|
binding->dir = parse_direction(dir_str);
|
||||||
binding->arg.v = NULL;
|
binding->arg.v = NULL;
|
||||||
binding->arg.v2 = 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->func) {
|
||||||
if (binding->arg.v) {
|
if (binding->arg.v) {
|
||||||
|
|
@ -1247,9 +1267,11 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
memset(binding, 0, sizeof(GestureBinding));
|
memset(binding, 0, sizeof(GestureBinding));
|
||||||
|
|
||||||
char mod_str[256], motion_str[256], fingers_count_str[256], func_name[256],
|
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";
|
arg_value[256] = "none", arg_value2[256] = "none",
|
||||||
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, motion_str,
|
arg_value3[256] = "none", arg_value4[256] = "none";
|
||||||
fingers_count_str, func_name, arg_value, arg_value2, arg_value3, arg_value4) < 4) {
|
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);
|
fprintf(stderr, "Error: Invalid gesturebind format: %s\n", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1259,7 +1281,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
binding->fingers_count = atoi(fingers_count_str);
|
binding->fingers_count = atoi(fingers_count_str);
|
||||||
binding->arg.v = NULL;
|
binding->arg.v = NULL;
|
||||||
binding->arg.v2 = 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->func) {
|
||||||
if (binding->arg.v) {
|
if (binding->arg.v) {
|
||||||
|
|
@ -1471,7 +1494,7 @@ void free_config(void) {
|
||||||
config.scroller_proportion_preset_count = 0;
|
config.scroller_proportion_preset_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.cursor_theme) {
|
if (config.cursor_theme) {
|
||||||
free(config.cursor_theme);
|
free(config.cursor_theme);
|
||||||
config.cursor_theme = NULL;
|
config.cursor_theme = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1481,7 +1504,6 @@ void free_config(void) {
|
||||||
|
|
||||||
// 释放动画资源
|
// 释放动画资源
|
||||||
free_baked_points();
|
free_baked_points();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void override_config(void) {
|
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) {
|
if (i > 0 && strlen(config.tag_rules[i - 1].layout_name) > 0) {
|
||||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
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];
|
m->pertag->ltidxs[i] = &layouts[jk];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
196
src/maomao.c
196
src/maomao.c
|
|
@ -203,8 +203,8 @@ typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
/* Must keep these three elements in this order */
|
/* Must keep these three elements in this order */
|
||||||
unsigned int type; /* XDGShell or X11* */
|
unsigned int type; /* XDGShell or X11* */
|
||||||
struct wlr_box geom, pending, oldgeom,scratch_geom, animainit_geom, overview_backup_geom,
|
struct wlr_box geom, pending, oldgeom, scratch_geom, animainit_geom,
|
||||||
current; /* layout-relative, includes border */
|
overview_backup_geom, current; /* layout-relative, includes border */
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
struct wlr_scene_tree *scene;
|
struct wlr_scene_tree *scene;
|
||||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||||
|
|
@ -421,7 +421,7 @@ arrange(Monitor *m,
|
||||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||||
struct wlr_box *usable_area, int exclusive);
|
struct wlr_box *usable_area, int exclusive);
|
||||||
static void arrangelayers(Monitor *m);
|
static void arrangelayers(Monitor *m);
|
||||||
static char* get_autostart_path(char*, size_t); // 自启动命令执行
|
static char *get_autostart_path(char *, size_t); // 自启动命令执行
|
||||||
static void axisnotify(struct wl_listener *listener,
|
static void axisnotify(struct wl_listener *listener,
|
||||||
void *data); // 滚轮事件处理
|
void *data); // 滚轮事件处理
|
||||||
static void buttonpress(struct wl_listener *listener,
|
static void buttonpress(struct wl_listener *listener,
|
||||||
|
|
@ -497,11 +497,9 @@ static void dwl_ipc_output_quit(struct wl_client *client,
|
||||||
struct wl_resource *resource);
|
struct wl_resource *resource);
|
||||||
static void dwl_ipc_output_dispatch(struct wl_client *client,
|
static void dwl_ipc_output_dispatch(struct wl_client *client,
|
||||||
struct wl_resource *resource,
|
struct wl_resource *resource,
|
||||||
const char *dispatch,
|
const char *dispatch, const char *arg1,
|
||||||
const char* arg1,
|
const char *arg2, const char *arg3,
|
||||||
const char* arg2,
|
const char *arg4);
|
||||||
const char* arg3,
|
|
||||||
const char* arg4);
|
|
||||||
static void dwl_ipc_output_release(struct wl_client *client,
|
static void dwl_ipc_output_release(struct wl_client *client,
|
||||||
struct wl_resource *resource);
|
struct wl_resource *resource);
|
||||||
static void focusclient(Client *c, int lift);
|
static void focusclient(Client *c, int lift);
|
||||||
|
|
@ -1058,15 +1056,15 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
||||||
if (c->iskilling || !client_surface(c)->mapped)
|
if (c->iskilling || !client_surface(c)->mapped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(clip_box.width > c->animation.current.width) {
|
if (clip_box.width > c->animation.current.width) {
|
||||||
clip_box.width = c->animation.current.width;
|
clip_box.width = c->animation.current.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(clip_box.height > c->animation.current.height) {
|
if (clip_box.height > c->animation.current.height) {
|
||||||
clip_box.height = c->animation.current.height;
|
clip_box.height = c->animation.current.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!render_border) {
|
if (!render_border) {
|
||||||
set_rect_size(c->border[0], 0, 0);
|
set_rect_size(c->border[0], 0, 0);
|
||||||
set_rect_size(c->border[1], 0, 0);
|
set_rect_size(c->border[1], 0, 0);
|
||||||
set_rect_size(c->border[2], 0, 0);
|
set_rect_size(c->border[2], 0, 0);
|
||||||
|
|
@ -1074,8 +1072,9 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0;i< config.tag_rules_count;i++) {
|
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[0], 0, 0);
|
||||||
set_rect_size(c->border[1], 0, 0);
|
set_rect_size(c->border[1], 0, 0);
|
||||||
set_rect_size(c->border[2], 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);
|
clip_box.height - 2 * c->bw);
|
||||||
} else if (c->animation.current.x + c->animation.current.width >
|
} else if (c->animation.current.x + c->animation.current.width >
|
||||||
c->mon->m.x + c->mon->m.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);
|
clip_box.height - 2 * c->bw);
|
||||||
} else if (c->animation.current.y < c->mon->m.y) {
|
} else if (c->animation.current.y < c->mon->m.y) {
|
||||||
set_rect_size(c->border[0], clip_box.width, GEZERO(c->bw - offsety));
|
set_rect_size(c->border[0], clip_box.width, GEZERO(c->bw - offsety));
|
||||||
} else if (c->animation.current.y + c->animation.current.height >
|
} else if (c->animation.current.y + c->animation.current.height >
|
||||||
c->mon->m.y + c->mon->m.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[0]->node, offsetx, offsety);
|
||||||
wlr_scene_node_set_position(&c->border[2]->node, offsetx, c->bw + 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[1]->node, offsetx,
|
||||||
wlr_scene_node_set_position(&c->border[3]->node, clip_box.width - c->bw + offsetx,
|
clip_box.height - c->bw + offsety);
|
||||||
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) {
|
struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
||||||
|
|
@ -1169,11 +1175,11 @@ struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
||||||
wlr_scene_node_set_enabled(&c->scene->node, true);
|
wlr_scene_node_set_enabled(&c->scene->node, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(clip_box->width > c->animation.current.width) {
|
if (clip_box->width > c->animation.current.width) {
|
||||||
clip_box->width = c->animation.current.width;
|
clip_box->width = c->animation.current.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(clip_box->height > c->animation.current.height) {
|
if (clip_box->height > c->animation.current.height) {
|
||||||
clip_box->height = c->animation.current.height;
|
clip_box->height = c->animation.current.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1341,23 +1347,30 @@ void show_scratchpad(Client *c) {
|
||||||
c->bw = borderpx; // 恢复非全屏的border
|
c->bw = borderpx; // 恢复非全屏的border
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c->oldgeom.width)
|
if (c->oldgeom.width)
|
||||||
c->scratch_geom.width = c->oldgeom.width;
|
c->scratch_geom.width = c->oldgeom.width;
|
||||||
if(c->oldgeom.height)
|
if (c->oldgeom.height)
|
||||||
c->scratch_geom.height = c->oldgeom.height;
|
c->scratch_geom.height = c->oldgeom.height;
|
||||||
|
|
||||||
/* return if fullscreen */
|
/* return if fullscreen */
|
||||||
if (!c->isfloating) {
|
if (!c->isfloating) {
|
||||||
setfloating(c, 1);
|
setfloating(c, 1);
|
||||||
c->geom.width = c->scratch_geom.width ? c->scratch_geom.width: c->mon->w.width * 0.7;
|
c->geom.width =
|
||||||
c->geom.height = c->scratch_geom.height? c->scratch_geom.height : c->mon->w.height * 0.8;
|
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);
|
resize(c, c->geom, 0);
|
||||||
} else if(c->geom.width != c->scratch_geom.width || c->geom.height != c->scratch_geom.height) {
|
} else if (c->geom.width != c->scratch_geom.width ||
|
||||||
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->geom.height = c->scratch_geom.height? c->scratch_geom.height : c->mon->w.height * 0.8;
|
c->geom.width =
|
||||||
c->geom = c->animainit_geom = c->animation.current = setclient_coordinate_center(c->geom, 0, 0);
|
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);
|
resize(c, c->geom, 0);
|
||||||
}
|
}
|
||||||
c->oldtags = selmon->tagset[selmon->seltags];
|
c->oldtags = selmon->tagset[selmon->seltags];
|
||||||
|
|
@ -1540,7 +1553,7 @@ void toggle_named_scratch(const Arg *arg) {
|
||||||
if (c->mon != selmon) {
|
if (c->mon != selmon) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(c->is_in_scratchpad && c->is_scratchpad_show && c != target_client) {
|
if (c->is_in_scratchpad && c->is_scratchpad_show && c != target_client) {
|
||||||
set_minized(c);
|
set_minized(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1548,7 +1561,7 @@ void toggle_named_scratch(const Arg *arg) {
|
||||||
target_client->scratch_geom.width = arg->ui;
|
target_client->scratch_geom.width = arg->ui;
|
||||||
target_client->scratch_geom.height = arg->ui2;
|
target_client->scratch_geom.height = arg->ui2;
|
||||||
|
|
||||||
if(!target_client->is_in_scratchpad)
|
if (!target_client->is_in_scratchpad)
|
||||||
set_minized(target_client);
|
set_minized(target_client);
|
||||||
else
|
else
|
||||||
switch_scratch_client_state(target_client);
|
switch_scratch_client_state(target_client);
|
||||||
|
|
@ -1561,8 +1574,8 @@ void toggle_scratchpad(const Arg *arg) {
|
||||||
if (c->mon != selmon) {
|
if (c->mon != selmon) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hit =switch_scratch_client_state(c);
|
hit = switch_scratch_client_state(c);
|
||||||
if(hit)
|
if (hit)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1593,11 +1606,10 @@ void gpureset(struct wl_listener *listener, void *data) {
|
||||||
wlr_renderer_destroy(old_drw);
|
wlr_renderer_destroy(old_drw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void handlesig(int signo) {
|
||||||
handlesig(int signo)
|
|
||||||
{
|
|
||||||
if (signo == SIGCHLD)
|
if (signo == SIGCHLD)
|
||||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||||
|
;
|
||||||
else if (signo == SIGINT || signo == SIGTERM)
|
else if (signo == SIGINT || signo == SIGTERM)
|
||||||
quit(NULL);
|
quit(NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -1752,8 +1764,10 @@ applyrules(Client *c) {
|
||||||
strstr(title, r->title))) {
|
strstr(title, r->title))) {
|
||||||
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
|
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
|
||||||
c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow;
|
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.width =
|
||||||
c->scratch_geom.height = r->scratch_height > 0 ? r->scratch_height : c->scratch_geom.height;
|
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->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating;
|
||||||
c->isfullscreen = r->isfullscreen > 0 ? r->isfullscreen : c->isfullscreen;
|
c->isfullscreen = r->isfullscreen > 0 ? r->isfullscreen : c->isfullscreen;
|
||||||
c->animation_type_open = r->animation_type_open == NULL
|
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_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_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_up_mon = c->geom.y - c->mon->m.y;
|
||||||
snap_down_mon =
|
snap_down_mon = c->mon->m.y + c->mon->m.height - c->geom.y - c->geom.height;
|
||||||
c->mon->m.y + c->mon->m.height - c->geom.y - c->geom.height;
|
|
||||||
|
|
||||||
if (snap_up_mon > 0 && snap_up_mon < snap_up)
|
if (snap_up_mon > 0 && snap_up_mon < snap_up)
|
||||||
snap_up = snap_up_mon;
|
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)
|
if (snap_right_mon > 0 && snap_right_mon < snap_right)
|
||||||
snap_right = snap_right_mon;
|
snap_right = snap_right_mon;
|
||||||
|
|
||||||
|
|
||||||
snap_left_screen = c->geom.x - c->mon->w.x;
|
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_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;
|
snap_up_screen = c->geom.y - c->mon->w.y;
|
||||||
|
|
@ -2298,7 +2310,7 @@ void arrangelayers(Monitor *m) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* get_autostart_path(char *autostart_path, size_t buf_size) {
|
char *get_autostart_path(char *autostart_path, size_t buf_size) {
|
||||||
const char *maomaoconfig = getenv("MAOMAOCONFIG");
|
const char *maomaoconfig = getenv("MAOMAOCONFIG");
|
||||||
|
|
||||||
if (maomaoconfig && maomaoconfig[0] != '\0') {
|
if (maomaoconfig && maomaoconfig[0] != '\0') {
|
||||||
|
|
@ -2309,7 +2321,8 @@ char* get_autostart_path(char *autostart_path, size_t buf_size) {
|
||||||
fprintf(stderr, "Error: HOME environment variable not set.\n");
|
fprintf(stderr, "Error: HOME environment variable not set.\n");
|
||||||
return NULL;
|
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;
|
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) {
|
if (i > 0 && strlen(config.tag_rules[i - 1].layout_name) > 0) {
|
||||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
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];
|
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,
|
void dwl_ipc_output_dispatch(struct wl_client *client,
|
||||||
struct wl_resource *resource,
|
struct wl_resource *resource, const char *dispatch,
|
||||||
const char *dispatch, const char *arg1,
|
const char *arg1, const char *arg2,
|
||||||
const char *arg2, const char *arg3, const char *arg4) {
|
const char *arg3, const char *arg4) {
|
||||||
|
|
||||||
void (*func)(const Arg *);
|
void (*func)(const Arg *);
|
||||||
Arg 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,
|
||||||
if(func) {
|
(char *)arg3, (char *)arg4);
|
||||||
|
if (func) {
|
||||||
func(&arg);
|
func(&arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwl_ipc_output_release(struct wl_client *client,
|
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
|
// decide whether need to re-arrange
|
||||||
if (c && selmon->prevsel && !selmon->prevsel->isfloating &&
|
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 &&
|
!c->isfullscreen &&
|
||||||
strcmp(selmon->pertag->ltidxs[selmon->pertag->curtag]->name,
|
strcmp(selmon->pertag->ltidxs[selmon->pertag->curtag]->name,
|
||||||
"scroller") == 0) {
|
"scroller") == 0) {
|
||||||
|
|
@ -5148,8 +5163,9 @@ run(char *startup_cmd) {
|
||||||
|
|
||||||
/* Now that the socket exists and the backend is started, run the startup
|
/* Now that the socket exists and the backend is started, run the startup
|
||||||
* command */
|
* command */
|
||||||
if(!startup_cmd)
|
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) {
|
if (startup_cmd) {
|
||||||
int piperw[2];
|
int piperw[2];
|
||||||
if (pipe(piperw) < 0)
|
if (pipe(piperw) < 0)
|
||||||
|
|
@ -5228,7 +5244,7 @@ setfloating(Client *c, int floating) {
|
||||||
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
|
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(c->isoverlay) {
|
if (c->isoverlay) {
|
||||||
wlr_scene_node_reparent(&c->scene->node, layers[LyrOverlay]);
|
wlr_scene_node_reparent(&c->scene->node, layers[LyrOverlay]);
|
||||||
} else {
|
} else {
|
||||||
wlr_scene_node_reparent(&c->scene->node,
|
wlr_scene_node_reparent(&c->scene->node,
|
||||||
|
|
@ -5348,7 +5364,7 @@ void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带
|
||||||
|
|
||||||
client_set_fullscreen(c, fullscreen);
|
client_set_fullscreen(c, fullscreen);
|
||||||
|
|
||||||
if(c->isoverlay) {
|
if (c->isoverlay) {
|
||||||
wlr_scene_node_reparent(&c->scene->node, layers[LyrOverlay]);
|
wlr_scene_node_reparent(&c->scene->node, layers[LyrOverlay]);
|
||||||
} else {
|
} else {
|
||||||
wlr_scene_node_reparent(&c->scene->node, layers[fullscreen ? LyrFloat
|
wlr_scene_node_reparent(&c->scene->node, layers[fullscreen ? LyrFloat
|
||||||
|
|
@ -5999,9 +6015,7 @@ void tagmon(const Arg *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void overview(Monitor *m) {
|
void overview(Monitor *m) { grid(m); }
|
||||||
grid(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
void fibonacci(Monitor *mon, int s) {
|
void fibonacci(Monitor *mon, int s) {
|
||||||
unsigned int i = 0, n = 0, nx, ny, nw, nh;
|
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;
|
unsigned int cur_gappov = enablegaps ? mon->gappov : 0;
|
||||||
|
|
||||||
// Count visible clients
|
// Count visible clients
|
||||||
wl_list_for_each(c, &clients, link)
|
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && !c->isfloating &&
|
||||||
if (VISIBLEON(c, mon) && !c->isfloating && !c->iskilling &&
|
!c->iskilling && !c->isfullscreen &&
|
||||||
!c->isfullscreen && !c->ismaxmizescreen && !c->animation.tagouting)
|
!c->ismaxmizescreen &&
|
||||||
n++;
|
!c->animation.tagouting) n++;
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -6068,7 +6082,8 @@ void fibonacci(Monitor *mon, int s) {
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (n != 1)
|
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;
|
ny = mon->w.y + cur_gappov;
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
nw = mon->w.width - 2 * cur_gappoh - nw - cur_gappih;
|
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)
|
nc->isfullscreen || nc->ismaxmizescreen || nc->animation.tagouting)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (c == nc) continue;
|
if (c == nc)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Check for right neighbor
|
// Check for right neighbor
|
||||||
if (c->geom.y == nc->geom.y &&
|
if (c->geom.y == nc->geom.y && c->geom.x + c->geom.width == nc->geom.x) {
|
||||||
c->geom.x + c->geom.width == nc->geom.x) {
|
|
||||||
right_gap = cur_gappih;
|
right_gap = cur_gappih;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for bottom neighbor
|
// Check for bottom neighbor
|
||||||
if (c->geom.x == nc->geom.x &&
|
if (c->geom.x == nc->geom.x && c->geom.y + c->geom.height == nc->geom.y) {
|
||||||
c->geom.y + c->geom.height == nc->geom.y) {
|
|
||||||
bottom_gap = cur_gappiv;
|
bottom_gap = cur_gappiv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(c,
|
resize(c,
|
||||||
(struct wlr_box){
|
(struct wlr_box){.x = c->geom.x,
|
||||||
.x = c->geom.x,
|
|
||||||
.y = c->geom.y,
|
.y = c->geom.y,
|
||||||
.width = c->geom.width - right_gap,
|
.width = c->geom.width - right_gap,
|
||||||
.height = c->geom.height - bottom_gap
|
.height = c->geom.height - bottom_gap},
|
||||||
},
|
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwindle(Monitor *mon) {
|
void dwindle(Monitor *mon) { fibonacci(mon, 1); }
|
||||||
fibonacci(mon, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void spiral(Monitor *mon) {
|
void spiral(Monitor *mon) { fibonacci(mon, 0); }
|
||||||
fibonacci(mon, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 网格布局窗口大小和位置计算
|
// 网格布局窗口大小和位置计算
|
||||||
void grid(Monitor *m) {
|
void grid(Monitor *m) {
|
||||||
|
|
@ -6208,7 +6216,8 @@ void grid(Monitor *m) {
|
||||||
// 处理多余的列
|
// 处理多余的列
|
||||||
overcols = n % cols;
|
overcols = n % cols;
|
||||||
if (overcols) {
|
if (overcols) {
|
||||||
dx = (m->w.width - overcols * cw - (overcols - 1) * overviewgappi) / 2 - overviewgappo;
|
dx = (m->w.width - overcols * cw - (overcols - 1) * overviewgappi) / 2 -
|
||||||
|
overviewgappo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调整每个客户端的位置和大小
|
// 调整每个客户端的位置和大小
|
||||||
|
|
@ -6241,11 +6250,12 @@ void scroller(Monitor *m) {
|
||||||
struct wlr_box target_geom;
|
struct wlr_box target_geom;
|
||||||
int focus_client_index = 0;
|
int focus_client_index = 0;
|
||||||
bool need_scroller = false;
|
bool need_scroller = false;
|
||||||
unsigned int cur_gappih = enablegaps? m->gappih : 0;
|
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
|
||||||
unsigned int cur_gappoh = enablegaps? m->gappoh : 0;
|
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||||
unsigned int cur_gappov = enablegaps? m->gappov : 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 的值
|
// 第一次遍历,计算 n 的值
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
|
@ -6349,15 +6359,16 @@ void scroller(Monitor *m) {
|
||||||
for (i = 1; i <= focus_client_index; i++) {
|
for (i = 1; i <= focus_client_index; i++) {
|
||||||
c = tempClients[focus_client_index - i];
|
c = tempClients[focus_client_index - i];
|
||||||
target_geom.width = max_client_width * c->scroller_proportion;
|
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 -
|
||||||
target_geom.width;
|
cur_gappih - target_geom.width;
|
||||||
resize(c, target_geom, 0);
|
resize(c, target_geom, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < n - focus_client_index; i++) {
|
for (i = 1; i < n - focus_client_index; i++) {
|
||||||
c = tempClients[focus_client_index + i];
|
c = tempClients[focus_client_index + i];
|
||||||
target_geom.width = max_client_width * c->scroller_proportion;
|
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;
|
tempClients[focus_client_index + i - 1]->geom.width;
|
||||||
resize(c, target_geom, 0);
|
resize(c, target_geom, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -7026,7 +7037,7 @@ void view_in_mon(const Arg *arg, bool want_animation, Monitor *m) {
|
||||||
if (arg->ui == ~0)
|
if (arg->ui == ~0)
|
||||||
m->pertag->curtag = 0;
|
m->pertag->curtag = 0;
|
||||||
else {
|
else {
|
||||||
for (i = 0; !(arg->ui & 1 << i) && i <LENGTH(tags) && arg->ui != 0; i++)
|
for (i = 0; !(arg->ui & 1 << i) && i < LENGTH(tags) && arg->ui != 0; i++)
|
||||||
;
|
;
|
||||||
m->pertag->curtag = i >= LENGTH(tags) ? LENGTH(tags) : i + 1;
|
m->pertag->curtag = i >= LENGTH(tags) ? LENGTH(tags) : i + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -7362,7 +7373,7 @@ void resizewin(const Arg *arg) {
|
||||||
if (!c->isfloating)
|
if (!c->isfloating)
|
||||||
togglefloating(NULL);
|
togglefloating(NULL);
|
||||||
|
|
||||||
switch(arg->ui) {
|
switch (arg->ui) {
|
||||||
case NUM_TYPE_MINUS:
|
case NUM_TYPE_MINUS:
|
||||||
c->geom.width -= arg->i;
|
c->geom.width -= arg->i;
|
||||||
break;
|
break;
|
||||||
|
|
@ -7374,7 +7385,7 @@ void resizewin(const Arg *arg) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(arg->ui2) {
|
switch (arg->ui2) {
|
||||||
case NUM_TYPE_MINUS:
|
case NUM_TYPE_MINUS:
|
||||||
c->geom.height -= arg->i2;
|
c->geom.height -= arg->i2;
|
||||||
break;
|
break;
|
||||||
|
|
@ -7398,7 +7409,7 @@ void movewin(const Arg *arg) {
|
||||||
if (!c->isfloating)
|
if (!c->isfloating)
|
||||||
togglefloating(NULL);
|
togglefloating(NULL);
|
||||||
|
|
||||||
switch(arg->ui) {
|
switch (arg->ui) {
|
||||||
case NUM_TYPE_MINUS:
|
case NUM_TYPE_MINUS:
|
||||||
c->geom.x -= arg->i;
|
c->geom.x -= arg->i;
|
||||||
break;
|
break;
|
||||||
|
|
@ -7410,7 +7421,7 @@ void movewin(const Arg *arg) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(arg->ui2) {
|
switch (arg->ui2) {
|
||||||
case NUM_TYPE_MINUS:
|
case NUM_TYPE_MINUS:
|
||||||
c->geom.y -= arg->i2;
|
c->geom.y -= arg->i2;
|
||||||
break;
|
break;
|
||||||
|
|
@ -7426,7 +7437,6 @@ void movewin(const Arg *arg) {
|
||||||
resize(c, c->geom, 0);
|
resize(c, c->geom, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void smartmovewin(const Arg *arg) {
|
void smartmovewin(const Arg *arg) {
|
||||||
Client *c, *tc;
|
Client *c, *tc;
|
||||||
int nx, ny;
|
int nx, ny;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue