format code index to tab no space

This commit is contained in:
DreamMaoMao 2025-06-07 13:53:12 +08:00
parent 0af8799a2d
commit 5aaf8d7625
11 changed files with 8896 additions and 8749 deletions

4
.clang-format Normal file
View file

@ -0,0 +1,4 @@
BasedOnStyle: LLVM
UseTab: Always
TabWidth: 4
IndentWidth: 4

View file

@ -60,11 +60,12 @@ static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
if (!xdg_surface->popup || !xdg_surface->popup->parent)
return -1;
tmp_xdg_surface =
wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(
xdg_surface->popup->parent);
if (!tmp_xdg_surface)
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc,
pl);
xdg_surface = tmp_xdg_surface;
break;
@ -112,7 +113,8 @@ static inline uint32_t client_set_bounds(Client *c, int32_t width,
(c->bounds.width != width || c->bounds.height != height)) {
c->bounds.width = width;
c->bounds.height = height;
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width,
height);
}
return 0;
}
@ -120,7 +122,8 @@ static inline uint32_t client_set_bounds(Client *c, int32_t width,
static inline const char *client_get_appid(Client *c) {
#ifdef XWAYLAND
if (client_is_x11(c))
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
return c->surface.xwayland->class ? c->surface.xwayland->class
: "broken";
#endif
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id
: "broken";
@ -171,13 +174,14 @@ static inline Client *client_get_parent(Client *c) {
#ifdef XWAYLAND
if (client_is_x11(c)) {
if (c->surface.xwayland->parent)
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p,
NULL);
return p;
}
#endif
if (c->surface.xdg->toplevel->parent)
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface,
&p, NULL);
toplevel_from_wlr_surface(
c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
return p;
}
@ -194,7 +198,8 @@ static inline int client_has_children(Client *c) {
static inline const char *client_get_title(Client *c) {
#ifdef XWAYLAND
if (client_is_x11(c))
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
return c->surface.xwayland->title ? c->surface.xwayland->title
: "broken";
#endif
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title
: "broken";
@ -258,7 +263,8 @@ static inline int client_is_stopped(Client *c) {
#endif
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
if (waitid(P_PID, pid, &in, WNOHANG | WCONTINUED | WSTOPPED | WNOWAIT) < 0) {
if (waitid(P_PID, pid, &in, WNOHANG | WCONTINUED | WSTOPPED | WNOWAIT) <
0) {
/* This process is not our child process, while is very unluckely that
* it is stopped, in order to do not skip frames assume that it is. */
if (errno == ECHILD)
@ -341,8 +347,9 @@ static inline uint32_t client_set_size(Client *c, uint32_t width,
static inline void client_set_tiled(Client *c, uint32_t edges) {
#ifdef XWAYLAND
if (client_is_x11(c)) {
wlr_xwayland_surface_set_maximized(
c->surface.xwayland, edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
edges != WLR_EDGE_NONE,
edges != WLR_EDGE_NONE);
return;
}
#endif
@ -381,9 +388,10 @@ static inline int client_should_ignore_focus(Client *c) {
WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLTIP,
WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY};
// 检查窗口类型是否需要禁止焦点
for (size_t i = 0; i < sizeof(no_focus_types) / sizeof(no_focus_types[0]);
++i) {
if (wlr_xwayland_surface_has_window_type(surface, no_focus_types[i])) {
for (size_t i = 0;
i < sizeof(no_focus_types) / sizeof(no_focus_types[0]); ++i) {
if (wlr_xwayland_surface_has_window_type(surface,
no_focus_types[i])) {
return 1;
}
}

View file

@ -61,4 +61,3 @@ char *xstrdup(const char *str);
free(ptr); \
(ptr) = NULL; \
} while (0)

View file

@ -52,12 +52,9 @@ int fd_set_nonblock(int fd) {
int regex_match(const char *pattern, const char *str) {
int errnum;
PCRE2_SIZE erroffset;
pcre2_code *re = pcre2_compile(
(PCRE2_SPTR)pattern,
PCRE2_ZERO_TERMINATED,
pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED,
PCRE2_UTF, // 启用 UTF-8 支持
&errnum, &erroffset, NULL
);
&errnum, &erroffset, NULL);
if (!re) {
PCRE2_UCHAR errbuf[256];
pcre2_get_error_message(errnum, errbuf, sizeof(errbuf));
@ -65,15 +62,10 @@ int regex_match(const char *pattern, const char *str) {
return 0;
}
pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(re, NULL);
int ret = pcre2_match(
re,
(PCRE2_SPTR)str,
strlen(str),
0, 0,
match_data,
NULL
);
pcre2_match_data *match_data =
pcre2_match_data_create_from_pattern(re, NULL);
int ret =
pcre2_match(re, (PCRE2_SPTR)str, strlen(str), 0, 0, match_data, NULL);
pcre2_match_data_free(match_data);
pcre2_code_free(re);

View file

@ -1,6 +1,5 @@
/* See LICENSE.dwm file for copyright and license details. */
void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size);
int fd_set_nonblock(int fd);

View file

@ -63,7 +63,8 @@ typedef struct {
// 定义一个宏来简化默认按键绑定的添加
#define CHVT(n) \
{ \
WLR_MODIFIER_CTRL | WLR_MODIFIER_ALT, XKB_KEY_XF86Switch_VT_##n, chvt, { \
WLR_MODIFIER_CTRL | WLR_MODIFIER_ALT, XKB_KEY_XF86Switch_VT_##n, chvt, \
{ \
.ui = (n) \
} \
}
@ -663,16 +664,16 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
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).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).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_scratchpad") == 0) {
@ -720,11 +721,13 @@ void parse_config_line(Config *config, const char *line) {
if (strcmp(key, "animations") == 0) {
config->animations = atoi(value);
} else if (strcmp(key, "animation_type_open") == 0) {
snprintf(config->animation_type_open, sizeof(config->animation_type_open),
"%.9s", value); // string limit to 9 char
snprintf(config->animation_type_open,
sizeof(config->animation_type_open), "%.9s",
value); // string limit to 9 char
} else if (strcmp(key, "animation_type_close") == 0) {
snprintf(config->animation_type_close, sizeof(config->animation_type_close),
"%.9s", value); // string limit to 9 char
snprintf(config->animation_type_close,
sizeof(config->animation_type_close), "%.9s",
value); // string limit to 9 char
} else if (strcmp(key, "animation_fade_in") == 0) {
config->animation_fade_in = atoi(value);
} else if (strcmp(key, "animation_fade_out") == 0) {
@ -766,7 +769,8 @@ void parse_config_line(Config *config, const char *line) {
} else if (strcmp(key, "animation_curve_close") == 0) {
int num = parse_double_array(value, config->animation_curve_close, 4);
if (num != 4) {
fprintf(stderr, "Error: Failed to parse animation_curve_close: %s\n",
fprintf(stderr,
"Error: Failed to parse animation_curve_close: %s\n",
value);
}
} else if (strcmp(key, "scroller_structs") == 0) {
@ -815,15 +819,17 @@ void parse_config_line(Config *config, const char *line) {
}
// 3. 解析 value 中的浮点数
char *value_copy = strdup(value); // 复制 value因为 strtok 会修改原字符串
char *value_copy =
strdup(value); // 复制 value因为 strtok 会修改原字符串
char *token = strtok(value_copy, ",");
int i = 0;
while (token != NULL && i < float_count) {
if (sscanf(token, "%f", &config->scroller_proportion_preset[i]) != 1) {
fprintf(
stderr,
"Error: Invalid float value in scroller_proportion_preset: %s\n",
if (sscanf(token, "%f", &config->scroller_proportion_preset[i]) !=
1) {
fprintf(stderr,
"Error: Invalid float value in "
"scroller_proportion_preset: %s\n",
token);
free(value_copy);
free(config->scroller_proportion_preset); // 释放已分配的内存
@ -836,7 +842,8 @@ void parse_config_line(Config *config, const char *line) {
// 4. 检查解析的浮点数数量是否匹配
if (i != float_count) {
fprintf(stderr, "Error: Invalid scroller_proportion_preset format: %s\n",
fprintf(stderr,
"Error: Invalid scroller_proportion_preset format: %s\n",
value);
free(value_copy);
free(config->scroller_proportion_preset); // 释放已分配的内存
@ -866,7 +873,8 @@ void parse_config_line(Config *config, const char *line) {
}
// 3. 解析 value 中的字符串
char *value_copy = strdup(value); // 复制 value因为 strtok 会修改原字符串
char *value_copy =
strdup(value); // 复制 value因为 strtok 会修改原字符串
char *token = strtok(value_copy, ",");
int i = 0;
char *cleaned_token;
@ -875,7 +883,8 @@ void parse_config_line(Config *config, const char *line) {
cleaned_token = sanitize_string(token);
config->circle_layout[i] = strdup(cleaned_token);
if (!config->circle_layout[i]) {
fprintf(stderr, "Error: Memory allocation failed for string: %s\n",
fprintf(stderr,
"Error: Memory allocation failed for string: %s\n",
token);
// 释放之前分配的内存
for (int j = 0; j < i; j++) {
@ -1004,7 +1013,8 @@ void parse_config_line(Config *config, const char *line) {
} else if (strcmp(key, "maxmizescreencolor") == 0) {
long int color = parse_color(value);
if (color == -1) {
fprintf(stderr, "Error: Invalid maxmizescreencolor format: %s\n", value);
fprintf(stderr, "Error: Invalid maxmizescreencolor format: %s\n",
value);
} else {
convert_hex_to_rgba(config->maxmizescreencolor, color);
}
@ -1018,7 +1028,8 @@ void parse_config_line(Config *config, const char *line) {
} else if (strcmp(key, "scratchpadcolor") == 0) {
long int color = parse_color(value);
if (color == -1) {
fprintf(stderr, "Error: Invalid scratchpadcolor format: %s\n", value);
fprintf(stderr, "Error: Invalid scratchpadcolor format: %s\n",
value);
} else {
convert_hex_to_rgba(config->scratchpadcolor, color);
}
@ -1088,7 +1099,8 @@ void parse_config_line(Config *config, const char *line) {
realloc(config->window_rules,
(config->window_rules_count + 1) * sizeof(ConfigWinRule));
if (!config->window_rules) {
fprintf(stderr, "Error: Failed to allocate memory for window rules\n");
fprintf(stderr,
"Error: Failed to allocate memory for window rules\n");
return;
}
@ -1200,10 +1212,11 @@ void parse_config_line(Config *config, const char *line) {
config->window_rules_count++;
} else if (strcmp(key, "monitorrule") == 0) {
config->monitor_rules =
realloc(config->monitor_rules,
(config->monitor_rules_count + 1) * sizeof(ConfigMonitorRule));
realloc(config->monitor_rules, (config->monitor_rules_count + 1) *
sizeof(ConfigMonitorRule));
if (!config->monitor_rules) {
fprintf(stderr, "Error: Failed to allocate memory for monitor rules\n");
fprintf(stderr,
"Error: Failed to allocate memory for monitor rules\n");
return;
}
@ -1217,11 +1230,11 @@ void parse_config_line(Config *config, const char *line) {
char raw_scale[256], raw_x[256], raw_y[256];
// 先读取所有字段为字符串
int parsed = sscanf(
value,
"%255[^,],%255[^,],%255[^,],%255[^,],%255[^,],%255[^,],%255[^,],%255s",
raw_name, raw_mfact, raw_nmaster, raw_layout, raw_rr, raw_scale, raw_x,
raw_y);
int parsed = sscanf(value,
"%255[^,],%255[^,],%255[^,],%255[^,],%255[^,],%255["
"^,],%255[^,],%255s",
raw_name, raw_mfact, raw_nmaster, raw_layout,
raw_rr, raw_scale, raw_x, raw_y);
if (parsed == 8) {
// 修剪每个字段的空格
@ -1249,7 +1262,8 @@ void parse_config_line(Config *config, const char *line) {
free((void *)rule->name);
if (rule->layout)
free((void *)rule->layout);
fprintf(stderr, "Error: Failed to allocate memory for monitor rule\n");
fprintf(stderr,
"Error: Failed to allocate memory for monitor rule\n");
return;
}
@ -1308,7 +1322,8 @@ void parse_config_line(Config *config, const char *line) {
realloc(config->key_bindings,
(config->key_bindings_count + 1) * sizeof(KeyBinding));
if (!config->key_bindings) {
fprintf(stderr, "Error: Failed to allocate memory for key bindings\n");
fprintf(stderr,
"Error: Failed to allocate memory for key bindings\n");
return;
}
@ -1365,7 +1380,8 @@ void parse_config_line(Config *config, const char *line) {
realloc(config->mouse_bindings,
(config->mouse_bindings_count + 1) * sizeof(MouseBinding));
if (!config->mouse_bindings) {
fprintf(stderr, "Error: Failed to allocate memory for mouse bindings\n");
fprintf(stderr,
"Error: Failed to allocate memory for mouse bindings\n");
return;
}
@ -1413,7 +1429,8 @@ void parse_config_line(Config *config, const char *line) {
free(binding->arg.v3);
binding->arg.v3 = NULL;
}
fprintf(stderr, "Error: Unknown function in mousebind: %s\n", func_name);
fprintf(stderr, "Error: Unknown function in mousebind: %s\n",
func_name);
} else {
config->mouse_bindings_count++;
}
@ -1422,11 +1439,13 @@ void parse_config_line(Config *config, const char *line) {
realloc(config->axis_bindings,
(config->axis_bindings_count + 1) * sizeof(AxisBinding));
if (!config->axis_bindings) {
fprintf(stderr, "Error: Failed to allocate memory for axis bindings\n");
fprintf(stderr,
"Error: Failed to allocate memory for axis bindings\n");
return;
}
AxisBinding *binding = &config->axis_bindings[config->axis_bindings_count];
AxisBinding *binding =
&config->axis_bindings[config->axis_bindings_count];
memset(binding, 0, sizeof(AxisBinding));
char mod_str[256], dir_str[256], func_name[256],
@ -1434,8 +1453,8 @@ void parse_config_line(Config *config, const char *line) {
arg_value3[256] = "none", arg_value4[256] = "none",
arg_value5[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, dir_str, func_name, arg_value, arg_value2, arg_value3,
arg_value4, arg_value5) < 3) {
mod_str, dir_str, func_name, arg_value, arg_value2,
arg_value3, arg_value4, arg_value5) < 3) {
fprintf(stderr, "Error: Invalid axisbind format: %s\n", value);
return;
}
@ -1471,14 +1490,15 @@ void parse_config_line(Config *config, const char *line) {
free(binding->arg.v3);
binding->arg.v3 = NULL;
}
fprintf(stderr, "Error: Unknown function in axisbind: %s\n", func_name);
fprintf(stderr, "Error: Unknown function in axisbind: %s\n",
func_name);
} else {
config->axis_bindings_count++;
}
} else if (strncmp(key, "gesturebind", 11) == 0) {
config->gesture_bindings =
realloc(config->gesture_bindings,
config->gesture_bindings = realloc(
config->gesture_bindings,
(config->gesture_bindings_count + 1) * sizeof(GestureBinding));
if (!config->gesture_bindings) {
fprintf(stderr,
@ -1490,11 +1510,12 @@ void parse_config_line(Config *config, const char *line) {
&config->gesture_bindings[config->gesture_bindings_count];
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",
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_value5[256] = "none";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
if (sscanf(value,
"%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, motion_str, fingers_count_str, func_name, arg_value,
arg_value2, arg_value3, arg_value4, arg_value5) < 4) {
fprintf(stderr, "Error: Invalid gesturebind format: %s\n", value);
@ -1534,7 +1555,8 @@ void parse_config_line(Config *config, const char *line) {
free(binding->arg.v3);
binding->arg.v3 = NULL;
}
fprintf(stderr, "Error: Unknown function in axisbind: %s\n", func_name);
fprintf(stderr, "Error: Unknown function in axisbind: %s\n",
func_name);
} else {
config->gesture_bindings_count++;
}
@ -1888,7 +1910,8 @@ void set_value_default() {
animation_duration_move; // Animation move speed
config.animation_duration_open =
animation_duration_open; // Animation open speed
config.animation_duration_tag = animation_duration_tag; // Animation tag speed
config.animation_duration_tag =
animation_duration_tag; // Animation tag speed
config.animation_duration_close =
animation_duration_close; // Animation tag speed
@ -1912,7 +1935,8 @@ void set_value_default() {
config.sloppyfocus = sloppyfocus; /* focus follows mouse */
config.gappih = gappih; /* horiz inner gap between windows */
config.gappiv = gappiv; /* vert inner gap between windows */
config.gappoh = gappoh; /* horiz outer gap between windows and screen edge */
config.gappoh =
gappoh; /* horiz outer gap between windows and screen edge */
config.gappov = gappov; /* vert outer gap between windows and screen edge */
config.scroller_structs = scroller_structs;
@ -1933,7 +1957,8 @@ void set_value_default() {
config.bypass_surface_visibility =
bypass_surface_visibility; /* 1 means idle inhibitors will disable idle
tracking even if it's surface isn't visible
tracking even if it's surface isn't
visible
*/
config.borderpx = borderpx;
@ -2055,7 +2080,8 @@ void parse_config(void) {
// 检查文件是否存在
if (access(filename, F_OK) != 0) {
// 如果文件不存在,则使用 /etc/maomao/config.conf
snprintf(filename, sizeof(filename), "%s/maomao/config.conf", SYSCONFDIR);
snprintf(filename, sizeof(filename), "%s/maomao/config.conf",
SYSCONFDIR);
}
} else {
// 使用 MAOMAOCONFIG 环境变量作为配置文件夹路径
@ -2089,7 +2115,8 @@ void reload_config(const Arg *arg) {
// reset keyboard repeat rate when config change
wl_list_for_each(kb, &keyboards, link) {
wlr_keyboard_set_repeat_info(kb->wlr_keyboard, repeat_rate, repeat_delay);
wlr_keyboard_set_repeat_info(kb->wlr_keyboard, repeat_rate,
repeat_delay);
}
// reset master status when config change
@ -2116,10 +2143,11 @@ void reload_config(const Arg *arg) {
for (i = 0; i <= LENGTH(tags); i++) {
if (i > 0 && config.tag_rules && strlen(config.tag_rules[i - 1].layout_name) > 0) {
if (i > 0 && config.tag_rules &&
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

@ -11,7 +11,8 @@ void fibonacci(Monitor *mon, int s) {
cur_gappoh = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappov;
// Count visible clients
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c)) n++;
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c))
n++;
if (n == 0)
return;
@ -97,12 +98,14 @@ void fibonacci(Monitor *mon, int s) {
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;
}
}
@ -131,7 +134,8 @@ void grid(Monitor *m) {
// 第一次遍历,计算 n 的值
wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, c->mon) && !c->isunglobal && (m->isoverview || ISTILED(c))) {
if (VISIBLEON(c, c->mon) && !c->isunglobal &&
(m->isoverview || ISTILED(c))) {
n++;
}
}
@ -142,10 +146,12 @@ void grid(Monitor *m) {
if (n == 1) {
wl_list_for_each(c, &clients, link) {
c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps
c->bw =
m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, c->mon) && !c->isunglobal && (m->isoverview || ISTILED(c))) {
if (VISIBLEON(c, c->mon) && !c->isunglobal &&
(m->isoverview || ISTILED(c))) {
cw = (m->w.width - 2 * overviewgappo) * 0.7;
ch = (m->w.height - 2 * overviewgappo) * 0.8;
c->geom.x = m->w.x + (m->w.width - cw) / 2;
@ -163,10 +169,12 @@ void grid(Monitor *m) {
ch = (m->w.height - 2 * overviewgappo) * 0.65;
i = 0;
wl_list_for_each(c, &clients, link) {
c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps
c->bw =
m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, c->mon) && !c->isunglobal && (m->isoverview || ISTILED(c))) {
if (VISIBLEON(c, c->mon) && !c->isunglobal &&
(m->isoverview || ISTILED(c))) {
if (i == 0) {
c->geom.x = m->w.x + overviewgappo;
c->geom.y = m->w.y + (m->w.height - ch) / 2 + overviewgappo;
@ -211,7 +219,8 @@ void grid(Monitor *m) {
c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, c->mon) && !c->isunglobal && (m->isoverview || ISTILED(c))) {
if (VISIBLEON(c, c->mon) && !c->isunglobal &&
(m->isoverview || ISTILED(c))) {
cx = m->w.x + (i % cols) * (cw + overviewgappi);
cy = m->w.y + (i / cols) * (ch + overviewgappi);
if (overcols && i >= n - overcols) {
@ -261,11 +270,11 @@ void deck(Monitor *m) {
if (i < m->nmaster) {
// Master area clients
resize(c,
(struct wlr_box){.x = m->w.x + cur_gappoh,
(struct wlr_box){
.x = m->w.x + cur_gappoh,
.y = m->w.y + cur_gappov + my,
.width = mw,
.height =
(m->w.height - cur_gappov - my - cur_gappiv) /
.height = (m->w.height - cur_gappov - my - cur_gappiv) /
(MIN(n, m->nmaster) - i)},
0);
my += c->geom.height + cur_gappiv;
@ -274,8 +283,8 @@ void deck(Monitor *m) {
resize(c,
(struct wlr_box){.x = m->w.x + mw + cur_gappoh + cur_gappih,
.y = m->w.y + cur_gappov,
.width =
m->w.width - mw - 2 * cur_gappoh - cur_gappih,
.width = m->w.width - mw - 2 * cur_gappoh -
cur_gappih,
.height = m->w.height - 2 * cur_gappov},
0);
if (c == focustop(m))
@ -364,8 +373,10 @@ void scroller(Monitor *m) {
for (i = 0; i < n; i++) {
c = tempClients[i];
if (root_client == c) {
if (!c->is_open_animation && c->geom.x >= m->w.x + scroller_structs &&
c->geom.x + c->geom.width <= m->w.x + m->w.width - scroller_structs) {
if (!c->is_open_animation &&
c->geom.x >= m->w.x + scroller_structs &&
c->geom.x + c->geom.width <=
m->w.x + m->w.width - scroller_structs) {
need_scroller = false;
} else {
need_scroller = true;
@ -388,10 +399,10 @@ void scroller(Monitor *m) {
scroller_prefer_center)) {
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
} else {
target_geom.x =
root_client->geom.x > m->w.x + (m->w.width) / 2
target_geom.x = root_client->geom.x > m->w.x + (m->w.width) / 2
? m->w.x + (m->w.width -
root_client->scroller_proportion * max_client_width -
root_client->scroller_proportion *
max_client_width -
scroller_structs)
: m->w.x + scroller_structs;
}
@ -425,8 +436,7 @@ void tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c;
wl_list_for_each(c, &clients,
link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
if (n == 0)
return;

File diff suppressed because it is too large Load diff

View file

@ -221,7 +221,8 @@ bool input_method_keyboard_grab_forward_modifiers(KeyboardGroup *keyboard) {
*forwarded_modifiers = keyboard->wlr_group->keyboard.modifiers;
wlr_input_method_keyboard_grab_v2_set_keyboard(
keyboard_grab, &keyboard->wlr_group->keyboard);
wlr_input_method_keyboard_grab_v2_send_modifiers(keyboard_grab, modifiers);
wlr_input_method_keyboard_grab_v2_send_modifiers(keyboard_grab,
modifiers);
return true;
} else {
return false;
@ -250,8 +251,8 @@ bool input_method_keyboard_grab_forward_key(
}
wlr_input_method_keyboard_grab_v2_set_keyboard(
keyboard_grab, &keyboard->wlr_group->keyboard);
wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab, event->time_msec,
event->keycode, event->state);
wlr_input_method_keyboard_grab_v2_send_key(
keyboard_grab, event->time_msec, event->keycode, event->state);
return true;
} else {
return false;
@ -481,7 +482,8 @@ static void handle_input_method_grab_keyboard(struct wl_listener *listener,
relay->forwarded_modifiers = (struct wlr_keyboard_modifiers){0};
relay->keyboard_grab_destroy.notify = handle_keyboard_grab_destroy;
wl_signal_add(&keyboard_grab->events.destroy, &relay->keyboard_grab_destroy);
wl_signal_add(&keyboard_grab->events.destroy,
&relay->keyboard_grab_destroy);
}
static void handle_input_method_destroy(struct wl_listener *listener,
@ -501,7 +503,8 @@ static void handle_input_method_destroy(struct wl_listener *listener,
static void handle_popup_surface_destroy(struct wl_listener *listener,
void *data) {
struct input_method_popup *popup = wl_container_of(listener, popup, destroy);
struct input_method_popup *popup =
wl_container_of(listener, popup, destroy);
wlr_scene_node_destroy(&popup->tree->node);
wl_list_remove(&popup->destroy.link);
wl_list_remove(&popup->commit.link);
@ -528,11 +531,13 @@ static void handle_input_method_new_popup_surface(struct wl_listener *listener,
wl_signal_add(&popup->popup_surface->events.destroy, &popup->destroy);
popup->commit.notify = handle_popup_surface_commit;
wl_signal_add(&popup->popup_surface->surface->events.commit, &popup->commit);
wl_signal_add(&popup->popup_surface->surface->events.commit,
&popup->commit);
// popup->tree = wlr_scene_subsurface_tree_create(
// relay->popup_tree, popup->popup_surface->surface);
// node_descriptor_create(&popup->tree->node, dwl_NODE_DESC_IME_POPUP, NULL);
// node_descriptor_create(&popup->tree->node, dwl_NODE_DESC_IME_POPUP,
// NULL);
popup->tree = wlr_scene_tree_create(layers[LyrIMPopup]);
popup->scene_surface = wlr_scene_subsurface_tree_create(
@ -564,7 +569,8 @@ static void handle_new_input_method(struct wl_listener *listener, void *data) {
wl_signal_add(&relay->input_method->events.commit,
&relay->input_method_commit);
relay->input_method_grab_keyboard.notify = handle_input_method_grab_keyboard;
relay->input_method_grab_keyboard.notify =
handle_input_method_grab_keyboard;
wl_signal_add(&relay->input_method->events.grab_keyboard,
&relay->input_method_grab_keyboard);
@ -592,20 +598,22 @@ static void send_state_to_input_method(struct input_method_relay *relay) {
if (input->active_features & WLR_TEXT_INPUT_V3_FEATURE_SURROUNDING_TEXT) {
wlr_input_method_v2_send_surrounding_text(
input_method, input->current.surrounding.text,
input->current.surrounding.cursor, input->current.surrounding.anchor);
input->current.surrounding.cursor,
input->current.surrounding.anchor);
}
wlr_input_method_v2_send_text_change_cause(input_method,
input->current.text_change_cause);
wlr_input_method_v2_send_text_change_cause(
input_method, input->current.text_change_cause);
if (input->active_features & WLR_TEXT_INPUT_V3_FEATURE_CONTENT_TYPE) {
wlr_input_method_v2_send_content_type(input_method,
input->current.content_type.hint,
wlr_input_method_v2_send_content_type(
input_method, input->current.content_type.hint,
input->current.content_type.purpose);
}
wlr_input_method_v2_send_done(input_method);
}
static void handle_text_input_enable(struct wl_listener *listener, void *data) {
struct text_input *text_input = wl_container_of(listener, text_input, enable);
struct text_input *text_input =
wl_container_of(listener, text_input, enable);
struct input_method_relay *relay = text_input->relay;
update_active_text_input(relay);
@ -628,7 +636,8 @@ static void handle_text_input_disable(struct wl_listener *listener,
}
static void handle_text_input_commit(struct wl_listener *listener, void *data) {
struct text_input *text_input = wl_container_of(listener, text_input, commit);
struct text_input *text_input =
wl_container_of(listener, text_input, commit);
struct input_method_relay *relay = text_input->relay;
if (relay->active_text_input == text_input) {
@ -699,7 +708,8 @@ struct input_method_relay *input_method_relay_create() {
relay->popup_tree = wlr_scene_tree_create(&scene->tree);
relay->new_text_input.notify = handle_new_text_input;
wl_signal_add(&text_input_manager->events.text_input, &relay->new_text_input);
wl_signal_add(&text_input_manager->events.text_input,
&relay->new_text_input);
relay->new_input_method.notify = handle_new_input_method;
wl_signal_add(&input_method_manager->events.input_method,
@ -728,7 +738,8 @@ void input_method_relay_set_focus(struct input_method_relay *relay,
}
relay->focused_surface = surface;
if (surface) {
wl_signal_add(&surface->events.destroy, &relay->focused_surface_destroy);
wl_signal_add(&surface->events.destroy,
&relay->focused_surface_destroy);
}
update_text_inputs_focused_surface(relay);