diff --git a/src/client/client.h b/src/client/client.h index fd81a800..2da6a42c 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -427,7 +427,7 @@ static inline int32_t client_is_x11_popup(Client *c) { #ifdef XWAYLAND if (client_is_x11(c)) { struct wlr_xwayland_surface *surface = c->surface.xwayland; - // 处理不需要焦点的窗口类型 + // Handle window types that don't need focus const uint32_t no_focus_types[] = { WLR_XWAYLAND_NET_WM_WINDOW_TYPE_COMBO, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DND, @@ -438,7 +438,7 @@ static inline int32_t client_is_x11_popup(Client *c) { WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLTIP, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY}; - // 检查窗口类型是否需要禁止焦点 + // Check if window type needs to disable focus for (size_t i = 0; i < sizeof(no_focus_types) / sizeof(no_focus_types[0]); ++i) { if (wlr_xwayland_surface_has_window_type(surface, diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 0133250f..84f5be61 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -485,7 +485,7 @@ int32_t parse_circle_direction(const char *str) { } lowerStr[i] = '\0'; - // 根据转换后的小写字符串返回对应的枚举值 + // Return corresponding enum value based on converted lowercase string if (strcmp(lowerStr, "next") == 0) { return NEXT; } else { @@ -494,7 +494,7 @@ int32_t parse_circle_direction(const char *str) { } int32_t parse_direction(const char *str) { - // 将输入字符串转换为小写 + // Convert input string to lowercase char lowerStr[10]; int32_t i = 0; while (str[i] && i < 9) { @@ -503,7 +503,7 @@ int32_t parse_direction(const char *str) { } lowerStr[i] = '\0'; - // 根据转换后的小写字符串返回对应的枚举值 + // Return corresponding enum value based on converted lowercase string if (strcmp(lowerStr, "up") == 0) { return UP; } else if (strcmp(lowerStr, "down") == 0) { @@ -518,7 +518,7 @@ int32_t parse_direction(const char *str) { } int32_t parse_fold_state(const char *str) { - // 将输入字符串转换为小写 + // Convert input string to lowercase char lowerStr[10]; int32_t i = 0; while (str[i] && i < 9) { @@ -527,7 +527,7 @@ int32_t parse_fold_state(const char *str) { } lowerStr[i] = '\0'; - // 根据转换后的小写字符串返回对应的枚举值 + // Return corresponding enum value based on converted lowercase string if (strcmp(lowerStr, "fold") == 0) { return FOLD; } else if (strcmp(lowerStr, "unfold") == 0) { @@ -554,7 +554,7 @@ int64_t parse_color(const char *hex_str) { return (int64_t)hex_num; } -// 辅助函数:检查字符串是否以指定的前缀开头(忽略大小写) +// Helper function: check if string starts with specified prefix (case insensitive) static bool starts_with_ignore_case(const char *str, const char *prefix) { while (*prefix) { if (tolower(*str) != tolower(*prefix)) { @@ -632,22 +632,22 @@ uint32_t parse_mod(const char *mod_str) { char *saveptr = NULL; bool match_success = false; - // 复制并转换为小写 + // Copy and convert to lowercase strncpy(input_copy, mod_str, sizeof(input_copy) - 1); input_copy[sizeof(input_copy) - 1] = '\0'; for (char *p = input_copy; *p; p++) { *p = tolower(*p); } - // 分割处理每个部分 + // Split and process each part token = strtok_r(input_copy, "+", &saveptr); while (token != NULL) { - // 去除空白 + // Remove whitespace while (*token == ' ' || *token == '\t') token++; if (strncmp(token, "code:", 5) == 0) { - // 处理 code: 形式 + // Handle code: format char *endptr; errno = 0; long keycode = strtol(token + 5, &endptr, 10); @@ -678,7 +678,7 @@ uint32_t parse_mod(const char *mod_str) { } } } else { - // 完整的 modifier 检查(保留原始所有检查项) + // Complete modifier check (preserve all original checks) if (!strcmp(token, "super") || !strcmp(token, "super_l") || !strcmp(token, "super_r")) { mod |= WLR_MODIFIER_LOGO; @@ -723,7 +723,7 @@ uint32_t parse_mod(const char *mod_str) { return mod; } -// 定义辅助函数:在 keymap 中查找 keysym 对应的多个 keycode +// Define helper function: find multiple keycodes corresponding to keysym in keymap static int32_t find_keycodes_for_keysym(struct xkb_keymap *keymap, xkb_keysym_t sym, MultiKeycode *multi_kc) { @@ -738,7 +738,7 @@ static int32_t find_keycodes_for_keysym(struct xkb_keymap *keymap, for (xkb_keycode_t keycode = min_keycode; keycode <= max_keycode && found_count < 3; keycode++) { - // 使用布局0和层级0 + // Use layout 0 and level 0 const xkb_keysym_t *syms; int32_t num_syms = xkb_keymap_key_get_syms_by_level(keymap, keycode, 0, 0, &syms); @@ -777,7 +777,7 @@ void cleanup_config_keymap(void) { } void create_config_keymap(void) { - // 初始化 xkb 上下文和 keymap + // Initialize xkb context and keymap if (config.ctx == NULL) { config.ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); @@ -790,16 +790,16 @@ void create_config_keymap(void) { } KeySymCode parse_key(const char *key_str, bool isbindsym) { - KeySymCode kc = {0}; // 初始化为0 + KeySymCode kc = {0}; // Initialize to 0 if (config.keymap == NULL || config.ctx == NULL) { - // 处理错误 + // Handle error kc.type = KEY_TYPE_SYM; kc.keysym = XKB_KEY_NoSymbol; return kc; } - // 处理 code: 前缀的情况 + // Handle code: prefix case if (strncmp(key_str, "code:", 5) == 0) { char *endptr; errno = 0; @@ -813,7 +813,7 @@ KeySymCode parse_key(const char *key_str, bool isbindsym) { } kc.type = KEY_TYPE_CODE; - kc.keycode.keycode1 = keycode; // 只设置第一个 + kc.keycode.keycode1 = keycode; // Only set the first one kc.keycode.keycode2 = 0; kc.keycode.keycode3 = 0; return kc; @@ -830,42 +830,42 @@ KeySymCode parse_key(const char *key_str, bool isbindsym) { } if (sym != XKB_KEY_NoSymbol) { - // 尝试找到对应的多个 keycode + // Try to find corresponding multiple keycodes int32_t found_count = find_keycodes_for_keysym(config.keymap, sym, &kc.keycode); if (found_count > 0) { kc.type = KEY_TYPE_CODE; - kc.keysym = sym; // 仍然保存 keysym 供参考 + kc.keysym = sym; // Still save keysym for reference } else { kc.type = KEY_TYPE_SYM; kc.keysym = sym; - // keycode 字段保持为0 + // keycode field remains 0 } } else { - // 无法解析的键名 + // Unable to parse key name kc.type = KEY_TYPE_SYM; kc.keysym = XKB_KEY_NoSymbol; fprintf( stderr, "\033[1m\033[31m[ERROR]:\033[33m Unknown key: \033[1m\033[31m%s\n", key_str); - // keycode 字段保持为0 + // keycode field remains 0 } return kc; } uint32_t parse_button(const char *str) { - // 将输入字符串转换为小写 + // Convert input string to lowercase char lowerStr[20]; int32_t i = 0; while (str[i] && i < 19) { lowerStr[i] = tolower(str[i]); i++; } - lowerStr[i] = '\0'; // 确保字符串正确终止 + lowerStr[i] = '\0'; // Ensure string terminates correctly - // 根据转换后的小写字符串返回对应的按钮编号 + // Return corresponding button number based on converted lowercase string if (strcmp(lowerStr, "btn_left") == 0) { return BTN_LEFT; } else if (strcmp(lowerStr, "btn_right") == 0) { @@ -892,16 +892,16 @@ uint32_t parse_button(const char *str) { } int32_t parse_mouse_action(const char *str) { - // 将输入字符串转换为小写 + // Convert input string to lowercase char lowerStr[20]; int32_t i = 0; while (str[i] && i < 19) { lowerStr[i] = tolower(str[i]); i++; } - lowerStr[i] = '\0'; // 确保字符串正确终止 + lowerStr[i] = '\0'; // Ensure string terminates correctly - // 根据转换后的小写字符串返回对应的按钮编号 + // Return corresponding button number based on converted lowercase string if (strcmp(lowerStr, "curmove") == 0) { return CurMove; } else if (strcmp(lowerStr, "curresize") == 0) { @@ -1006,7 +1006,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, (*arg).v = strdup(arg_value); - // 收集需要拼接的参数 + // Collect parameters that need concatenation const char *non_empty_params[4] = {NULL}; int32_t param_index = 0; @@ -1019,16 +1019,16 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, if (arg_value5 && arg_value5[0] != '\0') non_empty_params[param_index++] = arg_value5; - // 处理拼接 + // Handle concatenation if (param_index == 0) { (*arg).v2 = strdup(""); } else { - // 计算总长度 + // Calculate total length size_t len = 0; for (int32_t i = 0; i < param_index; i++) { len += strlen(non_empty_params[i]); } - len += (param_index - 1) + 1; // 逗号数 + null终止符 + len += (param_index - 1) + 1; // Number of commas + null terminator char *temp = malloc(len); if (temp) { @@ -1104,7 +1104,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, (*arg).v = combine_args_until_empty(values, 5); } else if (strcmp(func_name, "spawn_on_empty") == 0) { func = spawn_on_empty; - (*arg).v = strdup(arg_value); // 注意:之后需要释放这个内存 + (*arg).v = strdup(arg_value); // Note: need to release this memory later (*arg).ui = 1 << (atoi(arg_value2) - 1); } else if (strcmp(func_name, "quit") == 0) { func = quit; @@ -1448,33 +1448,33 @@ bool parse_option(Config *config, char *key, char *value) { } else if (strcmp(key, "xkb_rules_rules") == 0) { strncpy(xkb_rules_rules, value, sizeof(xkb_rules_rules) - 1); xkb_rules_rules[sizeof(xkb_rules_rules) - 1] = - '\0'; // 确保字符串以 null 结尾 + '\0'; // Ensure string ends with null } else if (strcmp(key, "xkb_rules_model") == 0) { strncpy(xkb_rules_model, value, sizeof(xkb_rules_model) - 1); xkb_rules_model[sizeof(xkb_rules_model) - 1] = - '\0'; // 确保字符串以 null 结尾 + '\0'; // Ensure string ends with null } else if (strcmp(key, "xkb_rules_layout") == 0) { strncpy(xkb_rules_layout, value, sizeof(xkb_rules_layout) - 1); xkb_rules_layout[sizeof(xkb_rules_layout) - 1] = - '\0'; // 确保字符串以 null 结尾 + '\0'; // Ensure string ends with null } else if (strcmp(key, "xkb_rules_variant") == 0) { strncpy(xkb_rules_variant, value, sizeof(xkb_rules_variant) - 1); xkb_rules_variant[sizeof(xkb_rules_variant) - 1] = - '\0'; // 确保字符串以 null 结尾 + '\0'; // Ensure string ends with null } else if (strcmp(key, "xkb_rules_options") == 0) { strncpy(xkb_rules_options, value, sizeof(xkb_rules_options) - 1); xkb_rules_options[sizeof(xkb_rules_options) - 1] = - '\0'; // 确保字符串以 null 结尾 + '\0'; // Ensure string ends with null } else if (strcmp(key, "scroller_proportion_preset") == 0) { - // 1. 统计 value 中有多少个逗号,确定需要解析的浮点数个数 - int32_t count = 0; // 初始化为 0 + // 1. Count commas in value to determine number of floats to parse + int32_t count = 0; // Initialize to 0 for (const char *p = value; *p; p++) { if (*p == ',') count++; } - int32_t float_count = count + 1; // 浮点数的数量是逗号数量加 1 + int32_t float_count = count + 1; // Number of floats is comma count plus 1 - // 2. 动态分配内存,存储浮点数 + // 2. Dynamically allocate memory to store floats config->scroller_proportion_preset = (float *)malloc(float_count * sizeof(float)); if (!config->scroller_proportion_preset) { @@ -1483,9 +1483,9 @@ bool parse_option(Config *config, char *key, char *value) { return false; } - // 3. 解析 value 中的浮点数 + // 3. Parse floats in value char *value_copy = - strdup(value); // 复制 value,因为 strtok 会修改原字符串 + strdup(value); // Copy value since strtok modifies original string char *token = strtok(value_copy, ","); int32_t i = 0; float value_set; @@ -1512,7 +1512,7 @@ bool parse_option(Config *config, char *key, char *value) { i++; } - // 4. 检查解析的浮点数数量是否匹配 + // 4. Check if parsed float count matches if (i != float_count) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid " @@ -1527,18 +1527,18 @@ bool parse_option(Config *config, char *key, char *value) { } config->scroller_proportion_preset_count = float_count; - // 5. 释放临时复制的字符串 + // 5. Release temporary copied string free(value_copy); } else if (strcmp(key, "circle_layout") == 0) { - // 1. 统计 value 中有多少个逗号,确定需要解析的字符串个数 - int32_t count = 0; // 初始化为 0 + // 1. Count commas in value to determine number of strings to parse + int32_t count = 0; // Initialize to 0 for (const char *p = value; *p; p++) { if (*p == ',') count++; } - int32_t string_count = count + 1; // 字符串的数量是逗号数量加 1 + int32_t string_count = count + 1; // Number of strings is comma count plus 1 - // 2. 动态分配内存,存储字符串指针 + // 2. Dynamically allocate memory to store string pointers config->circle_layout = (char **)malloc(string_count * sizeof(char *)); memset(config->circle_layout, 0, string_count * sizeof(char *)); if (!config->circle_layout) { @@ -1547,14 +1547,14 @@ bool parse_option(Config *config, char *key, char *value) { return false; } - // 3. 解析 value 中的字符串 + // 3. Parse strings in value char *value_copy = - strdup(value); // 复制 value,因为 strtok 会修改原字符串 + strdup(value); // Copy value since strtok modifies original string char *token = strtok(value_copy, ","); int32_t i = 0; char *cleaned_token; while (token != NULL && i < string_count) { - // 为每个字符串分配内存并复制内容 + // Allocate memory and copy content for each string cleaned_token = sanitize_string(token); config->circle_layout[i] = strdup(cleaned_token); if (!config->circle_layout[i]) { @@ -1563,13 +1563,13 @@ bool parse_option(Config *config, char *key, char *value) { "failed for " "string: %s\n", token); - // 释放之前分配的内存 + // Release previously allocated memory for (int32_t j = 0; j < i; j++) { free(config->circle_layout[j]); } free(config->circle_layout); free(value_copy); - config->circle_layout = NULL; // 防止野指针 + config->circle_layout = NULL; // Prevent dangling pointer config->circle_layout_count = 0; return false; } @@ -1577,25 +1577,25 @@ bool parse_option(Config *config, char *key, char *value) { i++; } - // 4. 检查解析的字符串数量是否匹配 + // 4. Check if parsed string count matches if (i != string_count) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid circle_layout " "format: %s\n", value); - // 释放之前分配的内存 + // Release previously allocated memory for (int32_t j = 0; j < i; j++) { free(config->circle_layout[j]); } free(config->circle_layout); free(value_copy); - config->circle_layout = NULL; // 防止野指针 + config->circle_layout = NULL; // Prevent dangling pointer config->circle_layout_count = 0; return false; } config->circle_layout_count = string_count; - // 5. 释放临时复制的字符串 + // 5. Release temporary copied string free(value_copy); } else if (strcmp(key, "new_is_master") == 0) { config->new_is_master = atoi(value); @@ -1813,7 +1813,7 @@ bool parse_option(Config *config, char *key, char *value) { &config->monitor_rules[config->monitor_rules_count]; memset(rule, 0, sizeof(ConfigMonitorRule)); - // 设置默认值 + // Set default value rule->name = NULL; rule->make = NULL; rule->model = NULL; @@ -1891,7 +1891,7 @@ bool parse_option(Config *config, char *key, char *value) { ConfigTagRule *rule = &config->tag_rules[config->tag_rules_count]; memset(rule, 0, sizeof(ConfigTagRule)); - // 设置默认值 + // Set default value rule->id = 0; rule->layout_name = NULL; rule->monitor_name = NULL; @@ -1963,7 +1963,7 @@ bool parse_option(Config *config, char *key, char *value) { ConfigLayerRule *rule = &config->layer_rules[config->layer_rules_count]; memset(rule, 0, sizeof(ConfigLayerRule)); - // 设置默认值 + // Set default value rule->layer_name = NULL; rule->animation_type_open = NULL; rule->animation_type_close = NULL; @@ -2007,7 +2007,7 @@ bool parse_option(Config *config, char *key, char *value) { token = strtok(NULL, ","); } - // 如果没有指定布局名称,则使用默认值 + // Use default value if no layout name is specified if (rule->layer_name == NULL) { rule->layer_name = strdup("default"); } @@ -2801,18 +2801,18 @@ bool parse_config_file(Config *config, const char *file_path, bool must_exist) { void free_circle_layout(Config *config) { if (config->circle_layout) { - // 释放每个字符串 + // Release each string for (int32_t i = 0; i < config->circle_layout_count; i++) { if (config->circle_layout[i]) { - free(config->circle_layout[i]); // 释放单个字符串 - config->circle_layout[i] = NULL; // 防止野指针 + free(config->circle_layout[i]); // Release individual string + config->circle_layout[i] = NULL; // Prevent dangling pointer } } - // 释放 circle_layout 数组本身 + // Release circle_layout array itself free(config->circle_layout); - config->circle_layout = NULL; // 防止野指针 + config->circle_layout = NULL; // Prevent dangling pointer } - config->circle_layout_count = 0; // 重置计数 + config->circle_layout_count = 0; // Reset count } void free_baked_points(void) { @@ -2847,10 +2847,10 @@ void free_baked_points(void) { } void free_config(void) { - // 释放内存 + // Release memory int32_t i; - // 释放 window_rules + // Release window_rules if (config.window_rules) { for (int32_t i = 0; i < config.window_rules_count; i++) { ConfigWinRule *rule = &config.window_rules[i]; @@ -2869,7 +2869,7 @@ void free_config(void) { rule->animation_type_open = NULL; rule->animation_type_close = NULL; rule->monitor = NULL; - // 释放 globalkeybinding 的 arg.v(如果动态分配) + // Release globalkeybinding arg.v (if dynamically allocated) if (rule->globalkeybinding.arg.v) { free((void *)rule->globalkeybinding.arg.v); } @@ -2879,7 +2879,7 @@ void free_config(void) { config.window_rules_count = 0; } - // 释放 key_bindings + // Release key_bindings if (config.key_bindings) { for (i = 0; i < config.key_bindings_count; i++) { if (config.key_bindings[i].arg.v) { @@ -2900,7 +2900,7 @@ void free_config(void) { config.key_bindings_count = 0; } - // 释放 mouse_bindings + // Release mouse_bindings if (config.mouse_bindings) { for (i = 0; i < config.mouse_bindings_count; i++) { if (config.mouse_bindings[i].arg.v) { @@ -2921,7 +2921,7 @@ void free_config(void) { config.mouse_bindings_count = 0; } - // 释放 axis_bindings + // Release axis_bindings if (config.axis_bindings) { for (i = 0; i < config.axis_bindings_count; i++) { if (config.axis_bindings[i].arg.v) { @@ -2942,7 +2942,7 @@ void free_config(void) { config.axis_bindings_count = 0; } - // 释放 switch_bindings + // Release switch_bindings if (config.switch_bindings) { for (i = 0; i < config.switch_bindings_count; i++) { if (config.switch_bindings[i].arg.v) { @@ -2963,7 +2963,7 @@ void free_config(void) { config.switch_bindings_count = 0; } - // 释放 gesture_bindings + // Release gesture_bindings if (config.gesture_bindings) { for (i = 0; i < config.gesture_bindings_count; i++) { if (config.gesture_bindings[i].arg.v) { @@ -2984,7 +2984,7 @@ void free_config(void) { config.gesture_bindings_count = 0; } - // 释放 tag_rules + // Release tag_rules if (config.tag_rules) { for (int32_t i = 0; i < config.tag_rules_count; i++) { if (config.tag_rules[i].layout_name) @@ -3003,7 +3003,7 @@ void free_config(void) { config.tag_rules_count = 0; } - // 释放 monitor_rules + // Release monitor_rules if (config.monitor_rules) { for (int32_t i = 0; i < config.monitor_rules_count; i++) { if (config.monitor_rules[i].name) @@ -3020,7 +3020,7 @@ void free_config(void) { config.monitor_rules_count = 0; } - // 释放 layer_rules + // Release layer_rules if (config.layer_rules) { for (int32_t i = 0; i < config.layer_rules_count; i++) { if (config.layer_rules[i].layer_name) @@ -3035,7 +3035,7 @@ void free_config(void) { config.layer_rules_count = 0; } - // 释放 env + // Release env if (config.env) { for (int32_t i = 0; i < config.env_count; i++) { if (config.env[i]->type) { @@ -3051,7 +3051,7 @@ void free_config(void) { config.env_count = 0; } - // 释放 exec + // Release exec if (config.exec) { for (i = 0; i < config.exec_count; i++) { free(config.exec[i]); @@ -3061,7 +3061,7 @@ void free_config(void) { config.exec_count = 0; } - // 释放 exec_once + // Release exec_once if (config.exec_once) { for (i = 0; i < config.exec_once_count; i++) { free(config.exec_once[i]); @@ -3071,7 +3071,7 @@ void free_config(void) { config.exec_once_count = 0; } - // 释放 scroller_proportion_preset + // Release scroller_proportion_preset if (config.scroller_proportion_preset) { free(config.scroller_proportion_preset); config.scroller_proportion_preset = NULL; @@ -3083,25 +3083,25 @@ void free_config(void) { config.cursor_theme = NULL; } - // 释放 circle_layout + // Release circle_layout free_circle_layout(&config); - // 释放动画资源 + // Release animation resources free_baked_points(); - // 清理解析按键用的keymap + // Clean up keymap used for parsing keys cleanup_config_keymap(); } void override_config(void) { - // 动画启用 + // Enable animation animations = CLAMP_INT(config.animations, 0, 1); layer_animations = CLAMP_INT(config.layer_animations, 0, 1); - // 标签动画方向 + // Tag animation direction tag_animation_direction = CLAMP_INT(config.tag_animation_direction, 0, 1); - // 动画淡入淡出设置 + // Animation fade in/out settings animation_fade_in = CLAMP_INT(config.animation_fade_in, 0, 1); animation_fade_out = CLAMP_INT(config.animation_fade_out, 0, 1); zoom_initial_ratio = CLAMP_FLOAT(config.zoom_initial_ratio, 0.1f, 1.0f); @@ -3110,15 +3110,15 @@ void override_config(void) { fadeout_begin_opacity = CLAMP_FLOAT(config.fadeout_begin_opacity, 0.0f, 1.0f); - // 打开关闭动画类型 + // Open/close animation type animation_type_open = config.animation_type_open; animation_type_close = config.animation_type_close; - // layer打开关闭动画类型 + // Layer open/close animation type layer_animation_type_open = config.layer_animation_type_open; layer_animation_type_close = config.layer_animation_type_close; - // 动画时间限制在合理范围(1-50000ms) + // Animation time limited to reasonable range (1-50000ms) animation_duration_move = CLAMP_INT(config.animation_duration_move, 1, 50000); animation_duration_open = @@ -3129,7 +3129,7 @@ void override_config(void) { animation_duration_focus = CLAMP_INT(config.animation_duration_focus, 1, 50000); - // 滚动布局设置 + // Scroll layout settings scroller_default_proportion = CLAMP_FLOAT(config.scroller_default_proportion, 0.1f, 1.0f); scroller_default_proportion_single = @@ -3142,14 +3142,14 @@ void override_config(void) { CLAMP_INT(config.edge_scroller_pointer_focus, 0, 1); scroller_structs = CLAMP_INT(config.scroller_structs, 0, 1000); - // 主从布局设置 + // Master-slave layout settings default_mfact = CLAMP_FLOAT(config.default_mfact, 0.1f, 0.9f); default_nmaster = CLAMP_INT(config.default_nmaster, 1, 1000); center_master_overspread = CLAMP_INT(config.center_master_overspread, 0, 1); center_when_single_stack = CLAMP_INT(config.center_when_single_stack, 0, 1); new_is_master = CLAMP_INT(config.new_is_master, 0, 1); - // 概述模式设置 + // Overview mode settings hotarea_size = CLAMP_INT(config.hotarea_size, 1, 1000); hotarea_corner = CLAMP_INT(config.hotarea_corner, 0, 3); enable_hotarea = CLAMP_INT(config.enable_hotarea, 0, 1); @@ -3157,7 +3157,7 @@ void override_config(void) { overviewgappi = CLAMP_INT(config.overviewgappi, 0, 1000); overviewgappo = CLAMP_INT(config.overviewgappo, 0, 1000); - // 杂项设置 + // Miscellaneous settings xwayland_persistence = CLAMP_INT(config.xwayland_persistence, 0, 1); syncobj_enable = CLAMP_INT(config.syncobj_enable, 0, 1); allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2); @@ -3183,16 +3183,16 @@ void override_config(void) { no_border_when_single = CLAMP_INT(config.no_border_when_single, 0, 1); no_radius_when_single = CLAMP_INT(config.no_radius_when_single, 0, 1); cursor_hide_timeout = - CLAMP_INT(config.cursor_hide_timeout, 0, 36000); // 0-10小时 + CLAMP_INT(config.cursor_hide_timeout, 0, 36000); // 0-10 hours drag_tile_to_tile = CLAMP_INT(config.drag_tile_to_tile, 0, 1); single_scratchpad = CLAMP_INT(config.single_scratchpad, 0, 1); - // 键盘设置 + // Keyboard settings repeat_rate = CLAMP_INT(config.repeat_rate, 1, 1000); repeat_delay = CLAMP_INT(config.repeat_delay, 1, 20000); numlockon = CLAMP_INT(config.numlockon, 0, 1); - // 触控板设置 + // Touchpad settings disable_trackpad = CLAMP_INT(config.disable_trackpad, 0, 1); tap_to_click = CLAMP_INT(config.tap_to_click, 0, 1); tap_and_drag = CLAMP_INT(config.tap_and_drag, 0, 1); @@ -3204,7 +3204,7 @@ void override_config(void) { middle_button_emulation = CLAMP_INT(config.middle_button_emulation, 0, 1); swipe_min_threshold = CLAMP_INT(config.swipe_min_threshold, 1, 1000); - // 鼠标设置 + // Mouse settings mouse_natural_scrolling = CLAMP_INT(config.mouse_natural_scrolling, 0, 1); accel_profile = CLAMP_INT(config.accel_profile, 0, 2); accel_speed = CLAMP_FLOAT(config.accel_speed, -1.0f, 1.0f); @@ -3215,7 +3215,7 @@ void override_config(void) { button_map = CLAMP_INT(config.button_map, 0, 1); axis_scroll_factor = CLAMP_FLOAT(config.axis_scroll_factor, 0.1f, 10.0f); - // 外观设置 + // Appearance settings gappih = CLAMP_INT(config.gappih, 0, 1000); gappiv = CLAMP_INT(config.gappiv, 0, 1000); gappoh = CLAMP_INT(config.gappoh, 0, 1000); @@ -3248,7 +3248,7 @@ void override_config(void) { unfocused_opacity = CLAMP_FLOAT(config.unfocused_opacity, 0.0f, 1.0f); memcpy(shadowscolor, config.shadowscolor, sizeof(shadowscolor)); - // 复制颜色数组 + // Copy color array memcpy(rootcolor, config.rootcolor, sizeof(rootcolor)); memcpy(bordercolor, config.bordercolor, sizeof(bordercolor)); memcpy(focuscolor, config.focuscolor, sizeof(focuscolor)); @@ -3259,7 +3259,7 @@ void override_config(void) { memcpy(globalcolor, config.globalcolor, sizeof(globalcolor)); memcpy(overlaycolor, config.overlaycolor, sizeof(overlaycolor)); - // 复制动画曲线 + // Copy animation curve memcpy(animation_curve_move, config.animation_curve_move, sizeof(animation_curve_move)); memcpy(animation_curve_open, config.animation_curve_open, @@ -3278,13 +3278,13 @@ void override_config(void) { void set_value_default() { /* animaion */ - config.animations = animations; // 是否启用动画 - config.layer_animations = layer_animations; // 是否启用layer动画 + config.animations = animations; // Whether to enable animation + config.layer_animations = layer_animations; // Whether to enable layer animation config.animation_fade_in = animation_fade_in; // Enable animation fade in config.animation_fade_out = animation_fade_out; // Enable animation fade out - config.tag_animation_direction = tag_animation_direction; // 标签动画方向 - config.zoom_initial_ratio = zoom_initial_ratio; // 动画起始窗口比例 - config.zoom_end_ratio = zoom_end_ratio; // 动画结束窗口比例 + config.tag_animation_direction = tag_animation_direction; // Tag animation direction + config.zoom_initial_ratio = zoom_initial_ratio; // Animation initial window ratio + config.zoom_end_ratio = zoom_end_ratio; // Animation end window ratio config.fadein_begin_opacity = fadein_begin_opacity; // Begin opac window ratio for animations config.fadeout_begin_opacity = fadeout_begin_opacity; diff --git a/src/data/static_keymap.h b/src/data/static_keymap.h index 8a0c1f71..644df996 100644 --- a/src/data/static_keymap.h +++ b/src/data/static_keymap.h @@ -1,6 +1,6 @@ typedef struct { const char *full_name; - const char *abbr; // 全部使用小写 + const char *abbr; // all lowercase } LayoutMapping; static const LayoutMapping layout_mappings[] = { @@ -75,5 +75,5 @@ static const LayoutMapping layout_mappings[] = { {"Telugu", "te"}, {"Kannada", "kn"}, {"Malayalam", "ml"}, - {NULL, NULL} // 结束标记 + {NULL, NULL} // end marker }; diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index c54f9a53..245af336 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -798,7 +798,7 @@ int32_t spawn_shell(const Arg *arg) { return 0; if (fork() == 0) { - // 1. 忽略可能导致 coredump 的信号 + // 1. Ignore signals that may cause coredump signal(SIGSEGV, SIG_IGN); signal(SIGABRT, SIG_IGN); signal(SIGILL, SIG_IGN); @@ -826,7 +826,7 @@ int32_t spawn(const Arg *arg) { return 0; if (fork() == 0) { - // 1. 忽略可能导致 coredump 的信号 + // 1. Ignore signals that may cause coredump signal(SIGSEGV, SIG_IGN); signal(SIGABRT, SIG_IGN); signal(SIGILL, SIG_IGN); @@ -834,7 +834,7 @@ int32_t spawn(const Arg *arg) { dup2(STDERR_FILENO, STDOUT_FILENO); setsid(); - // 2. 解析参数 + // 2. Parse parameters char *argv[64]; char *allocated_strings[64]; // Track strdup'd strings for cleanup int32_t argc = 0; @@ -859,10 +859,10 @@ int32_t spawn(const Arg *arg) { } argv[argc] = NULL; - // 3. 执行命令 + // 3. Execute command execvp(argv[0], argv); - // 4. execvp 失败时:清理并退出 + // 4. When execvp fails: cleanup and exit // If execvp succeeds, this code never runs (process replaced) // If it fails, clean up allocated strings before exiting for (int32_t i = 0; i < alloc_count; i++) { @@ -870,7 +870,7 @@ int32_t spawn(const Arg *arg) { } wlr_log(WLR_ERROR, "mango: execvp '%s' failed: %s\n", argv[0], strerror(errno)); - _exit(EXIT_FAILURE); // 使用 _exit 避免缓冲区刷新等操作 + _exit(EXIT_FAILURE); // Use _exit to avoid buffer flush operations } return 0; } @@ -907,7 +907,7 @@ int32_t switch_keyboard_layout(const Arg *arg) { return 0; } - // 1. 获取当前布局和计算下一个布局 + // 1. Get current layout and calculate next layout xkb_layout_index_t current = xkb_state_serialize_layout( keyboard->xkb_state, XKB_STATE_LAYOUT_EFFECTIVE); const int32_t num_layouts = xkb_keymap_num_layouts(keyboard->keymap); @@ -917,14 +917,14 @@ int32_t switch_keyboard_layout(const Arg *arg) { } xkb_layout_index_t next = (current + 1) % num_layouts; - // 6. 应用新 keymap + // 6. Apply new keymap uint32_t depressed = keyboard->modifiers.depressed; uint32_t latched = keyboard->modifiers.latched; uint32_t locked = keyboard->modifiers.locked; wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, next); - // 7. 更新 seat + // 7. Update seat wlr_seat_set_keyboard(seat, keyboard); wlr_seat_keyboard_notify_modifiers(seat, &keyboard->modifiers); @@ -937,7 +937,7 @@ int32_t switch_keyboard_layout(const Arg *arg) { struct wlr_keyboard *tkb = (struct wlr_keyboard *)id->device_data; wlr_keyboard_notify_modifiers(tkb, depressed, latched, locked, next); - // 7. 更新 seat + // 7. Update seat wlr_seat_set_keyboard(seat, tkb); wlr_seat_keyboard_notify_modifiers(seat, &tkb->modifiers); } @@ -1102,8 +1102,8 @@ int32_t tagmon(const Arg *arg) { selmon = c->mon; c->float_geom = setclient_coordinate_center(c, c->mon, c->float_geom, 0, 0); - // 重新计算居中的坐标 - // 重新计算居中的坐标 + // Recalculate centered coordinates + // Recalculate centered coordinates if (c->isfloating) { c->geom = c->float_geom; target = get_tags_first_tag(c->tags); @@ -1586,8 +1586,8 @@ int32_t toggleoverview(const Arg *arg) { return 0; } - // 正常视图到overview,退出所有窗口的浮动和全屏状态参与平铺, - // overview到正常视图,还原之前退出的浮动和全屏窗口状态 + // Normal view to overview, exit all floating and fullscreen states to participate in tiling, + // Overview to normal view, restore previously exited floating and fullscreen window states if (selmon->isoverview) { wl_list_for_each(c, &clients, link) { if (c && c->mon == selmon && !client_is_unmanaged(c) && diff --git a/src/ext-protocol/dwl-ipc.h b/src/ext-protocol/dwl-ipc.h index ab0bdb8d..4953c581 100644 --- a/src/ext-protocol/dwl-ipc.h +++ b/src/ext-protocol/dwl-ipc.h @@ -99,14 +99,14 @@ static void dwl_ipc_output_destroy(struct wl_resource *resource) { free(ipc_output); } -// 修改IPC输出函数,接受掩码参数 +// Modify IPC output function to accept mask parameter void dwl_ipc_output_printstatus(Monitor *monitor) { DwlIpcOutput *ipc_output; wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link) dwl_ipc_output_printstatus_to(ipc_output); } -// 修改主IPC输出函数,根据掩码发送相应事件 +// Modify main IPC output function to send events based on mask void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) { Monitor *monitor = ipc_output->mon; Client *c = NULL, *focused = NULL; diff --git a/src/ext-protocol/foreign-toplevel.h b/src/ext-protocol/foreign-toplevel.h index 89f3839a..8e04f1e1 100644 --- a/src/ext-protocol/foreign-toplevel.h +++ b/src/ext-protocol/foreign-toplevel.h @@ -111,7 +111,7 @@ void add_foreign_toplevel(Client *c) { c->foreign_toplevel = wlr_foreign_toplevel_handle_v1_create(foreign_toplevel_manager); - // 监听来自外部对于窗口的事件请求 + // Listen to external event requests for the window if (c->foreign_toplevel) { LISTEN(&(c->foreign_toplevel->events.request_activate), &c->foreign_activate_request, handle_foreign_activate_request); @@ -126,19 +126,19 @@ void add_foreign_toplevel(Client *c) { &c->foreign_close_request, handle_foreign_close_request); LISTEN(&(c->foreign_toplevel->events.destroy), &c->foreign_destroy, handle_foreign_destroy); - // 设置外部顶层句柄的id为应用的id + // Set the foreign toplevel handle's id to the application's id const char *appid; appid = client_get_appid(c); if (appid) wlr_foreign_toplevel_handle_v1_set_app_id(c->foreign_toplevel, appid); - // 设置外部顶层句柄的title为应用的title + // Set the foreign toplevel handle's title to the application's title const char *title; title = client_get_title(c); if (title) wlr_foreign_toplevel_handle_v1_set_title(c->foreign_toplevel, title); - // 设置外部顶层句柄的显示监视器为当前监视器 + // Set the foreign toplevel handle's display monitor to the current monitor wlr_foreign_toplevel_handle_v1_output_enter(c->foreign_toplevel, c->mon->wlr_output); } diff --git a/src/ext-protocol/tearing.h b/src/ext-protocol/tearing.h index 8e02656a..03e3c21d 100644 --- a/src/ext-protocol/tearing.h +++ b/src/ext-protocol/tearing.h @@ -99,30 +99,30 @@ bool custom_wlr_scene_output_commit(struct wlr_scene_output *scene_output, struct wlr_output *wlr_output = scene_output->output; Monitor *m = wlr_output->data; - // 检查是否需要帧 + // Check if frame is needed if (!wlr_scene_output_needs_frame(scene_output)) { wlr_log(WLR_DEBUG, "No frame needed for output %s", wlr_output->name); return true; } - // 构建输出状态 + // Build output state if (!wlr_scene_output_build_state(scene_output, state, NULL)) { wlr_log(WLR_ERROR, "Failed to build output state for %s", wlr_output->name); return false; } - // 测试撕裂翻页 + // Test tearing page flip if (state->tearing_page_flip) { if (!wlr_output_test_state(wlr_output, state)) { state->tearing_page_flip = false; } } - // 尝试提交 + // Attempt commit bool committed = wlr_output_commit_state(wlr_output, state); - // 如果启用撕裂翻页但提交失败,重试禁用撕裂翻页 + // If tearing page flip is enabled but commit fails, retry without tearing page flip if (!committed && state->tearing_page_flip) { wlr_log(WLR_DEBUG, "Retrying commit without tearing for %s", wlr_output->name); @@ -130,7 +130,7 @@ bool custom_wlr_scene_output_commit(struct wlr_scene_output *scene_output, committed = wlr_output_commit_state(wlr_output, state); } - // 处理状态清理 + // Handle state cleanup if (committed) { wlr_log(WLR_DEBUG, "Successfully committed output %s", wlr_output->name); @@ -140,7 +140,7 @@ bool custom_wlr_scene_output_commit(struct wlr_scene_output *scene_output, } } else { wlr_log(WLR_ERROR, "Failed to commit output %s", wlr_output->name); - // 即使提交失败,也清理状态避免积累 + // Clean up state even if commit fails to avoid accumulation if (state == &m->pending) { wlr_output_state_finish(&m->pending); wlr_output_state_init(&m->pending); diff --git a/src/ext-protocol/text-input.h b/src/ext-protocol/text-input.h index dbd97e11..53d8f4e9 100644 --- a/src/ext-protocol/text-input.h +++ b/src/ext-protocol/text-input.h @@ -52,7 +52,7 @@ struct wlr_input_method_manager_v2 *input_method_manager; struct wlr_text_input_manager_v3 *text_input_manager; struct dwl_input_method_relay *dwl_input_method_relay; -/*-------------------封装给外部调用-------------------------------*/ +/*------------------- Wrapped for external calls -------------------------------*/ bool dwl_im_keyboard_grab_forward_key(KeyboardGroup *keyboard, struct wlr_keyboard_key_event *event); @@ -66,7 +66,7 @@ void dwl_im_relay_set_focus(struct dwl_input_method_relay *relay, struct wlr_surface *surface); /*----------------------------------------------------------*/ -/*------------------协议内部代码------------------------------*/ +/*------------------ Protocol internal code ------------------------------*/ Monitor *output_from_wlr_output(struct wlr_output *wlr_output) { Monitor *m = NULL; wl_list_for_each(m, &mons, link) { @@ -111,7 +111,7 @@ get_keyboard_grab(KeyboardGroup *keyboard) { return NULL; } - // kb_group是一个物理键盘组,它不应该被过滤掉 + // kb_group is a physical keyboard group, it should not be filtered out if (keyboard != kb_group) return NULL; diff --git a/src/fetch/client.h b/src/fetch/client.h index 8fccb261..b2a8401a 100644 --- a/src/fetch/client.h +++ b/src/fetch/client.h @@ -75,7 +75,7 @@ Client *get_client_by_id_or_title(const char *arg_id, const char *arg_title) { } return target_client; } -struct wlr_box // 计算客户端居中坐标 +struct wlr_box // Calculate client center coordinates setclient_coordinate_center(Client *c, Monitor *tm, struct wlr_box geom, int32_t offsetx, int32_t offsety) { struct wlr_box tempbox; @@ -101,7 +101,7 @@ setclient_coordinate_center(Client *c, Monitor *tm, struct wlr_box geom, offset = len * (offsetx / 100.0); tempbox.x += offset; - // 限制窗口在屏幕内 + // Constrain window within screen if (tempbox.x < m->m.x) { tempbox.x = m->m.x - cbw; } @@ -114,7 +114,7 @@ setclient_coordinate_center(Client *c, Monitor *tm, struct wlr_box geom, offset = len * (offsety / 100.0); tempbox.y += offset; - // 限制窗口在屏幕内 + // Constrain window within screen if (tempbox.y < m->m.y) { tempbox.y = m->m.y - cbw; } @@ -158,10 +158,10 @@ Client *center_tiled_select(Monitor *m) { Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, bool ignore_align) { Client *c = NULL; - Client **tempClients = NULL; // 初始化为 NULL + Client **tempClients = NULL; // Initialize to NULL int32_t last = -1; - // 第一次遍历,计算客户端数量 + // First pass: count clients wl_list_for_each(c, &clients, link) { if (c && (findfloating || !c->isfloating) && !c->isunglobal && (focus_cross_monitor || c->mon == tc->mon) && @@ -171,17 +171,17 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, } if (last < 0) { - return NULL; // 没有符合条件的客户端 + return NULL; // No clients matching criteria } - // 动态分配内存 + // Allocate memory dynamically tempClients = malloc((last + 1) * sizeof(Client *)); if (!tempClients) { - // 处理内存分配失败的情况 + // Handle memory allocation failure return NULL; } - // 第二次遍历,填充 tempClients + // Second pass: fill tempClients last = -1; wl_list_for_each(c, &clients, link) { if (c && (findfloating || !c->isfloating) && !c->isunglobal && @@ -209,7 +209,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -225,7 +225,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -244,7 +244,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -267,7 +267,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -283,7 +283,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -302,7 +302,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -325,7 +325,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -341,7 +341,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -360,7 +360,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -383,7 +383,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -399,7 +399,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -418,7 +418,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, int32_t dis_x = tempClients[_i]->geom.x - sel_x; int32_t dis_y = tempClients[_i]->geom.y - sel_y; int64_t tmp_distance = - dis_x * dis_x + dis_y * dis_y; // 计算距离 + dis_x * dis_x + dis_y * dis_y; // Calculate distance if (tmp_distance < distance) { distance = tmp_distance; tempFocusClients = tempClients[_i]; @@ -434,7 +434,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, break; } - free(tempClients); // 释放内存 + free(tempClients); // Release memory if (tempSameMonitorFocusClients) { return tempSameMonitorFocusClients; } else { diff --git a/src/fetch/common.h b/src/fetch/common.h index b04f090d..76e94676 100644 --- a/src/fetch/common.h +++ b/src/fetch/common.h @@ -8,7 +8,7 @@ pid_t getparentprocess(pid_t p) { if (!(f = fopen(buf, "r"))) return 0; - // 检查fscanf返回值,确保成功读取了1个参数 + // Check fscanf return value to ensure 1 parameter was successfully read if (fscanf(f, "%*u %*s %*c %u", &v) != 1) { fclose(f); return 0; @@ -30,10 +30,10 @@ int32_t isdescprocess(pid_t p, pid_t c) { #define LAYOUT_ABBR_SIZE 32 void get_layout_abbr(char *abbr, const char *full_name) { - // 清空输出缓冲区 + // Clear output buffer abbr[0] = '\0'; - // 1. 尝试在映射表中查找 + // 1. Try to find in mapping table for (int32_t i = 0; layout_mappings[i].full_name != NULL; i++) { if (strcmp(full_name, layout_mappings[i].full_name) == 0) { strncpy(abbr, layout_mappings[i].abbr, LAYOUT_ABBR_SIZE - 1); @@ -42,13 +42,13 @@ void get_layout_abbr(char *abbr, const char *full_name) { } } - // 2. 尝试从名称中提取并转换为小写 + // 2. Try to extract and convert to lowercase from name const char *open = strrchr(full_name, '('); const char *close = strrchr(full_name, ')'); if (open && close && close > open) { uint32_t len = close - open - 1; if (len > 0 && len <= 4) { - // 提取并转换为小写 + // Extract and convert to lowercase for (uint32_t j = 0; j < len; j++) { abbr[j] = tolower(open[j + 1]); } @@ -57,7 +57,7 @@ void get_layout_abbr(char *abbr, const char *full_name) { } } - // 3. 提取前2-3个字母并转换为小写 + // 3. Extract first 2-3 letters and convert to lowercase uint32_t j = 0; for (uint32_t i = 0; full_name[i] != '\0' && j < 3; i++) { if (isalpha(full_name[i])) { @@ -66,17 +66,17 @@ void get_layout_abbr(char *abbr, const char *full_name) { } abbr[j] = '\0'; - // 确保至少2个字符 + // Ensure at least 2 characters if (j >= 2) { return; } - // 4. 回退方案:使用首字母小写 + // 4. Fallback: use first letter in lowercase if (j == 1) { abbr[1] = full_name[1] ? tolower(full_name[1]) : '\0'; abbr[2] = '\0'; } else { - // 5. 最终回退:返回 "xx" + // 5. Final fallback: return "xx" abbr[0] = 'x'; abbr[1] = 'x'; abbr[2] = '\0'; @@ -112,8 +112,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, } /* start from the topmost layer, - find a sureface that can be focused by pointer, - impopup neither a client nor a layer surface.*/ + find a surface that can be focused by pointer, + impopup is neither a client nor a layer surface.*/ if (layer == LyrIMPopup) { c = NULL; l = NULL; diff --git a/src/fetch/monitor.h b/src/fetch/monitor.h index 7a1ca4dc..84e06be7 100644 --- a/src/fetch/monitor.h +++ b/src/fetch/monitor.h @@ -70,7 +70,7 @@ uint32_t get_tags_first_tag_num(uint32_t source_tags) { } } -// 获取tags中最前面的tag的tagmask +// Get the first tag's tagmask from tags uint32_t get_tags_first_tag(uint32_t source_tags) { uint32_t i, tag; tag = 0; diff --git a/src/layout/arrange.h b/src/layout/arrange.h index 1ef89c3a..7962b064 100644 --- a/src/layout/arrange.h +++ b/src/layout/arrange.h @@ -82,7 +82,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, bool begin_find_nextnext = false; bool begin_find_prevprev = false; - // 从当前节点的下一个开始遍历 + // Start traversal from next node of current node for (node = grabc->link.next; node != &clients; node = node->next) { tc = wl_container_of(node, tc, link); if (begin_find_nextnext && VISIBLEON(tc, grabc->mon) && ISTILED(tc)) { @@ -91,14 +91,14 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, } if (!begin_find_nextnext && VISIBLEON(tc, grabc->mon) && - ISTILED(tc)) { // 根据你的实际字段名调整 + ISTILED(tc)) { // Adjust according to your actual field names next = tc; begin_find_nextnext = true; continue; } } - // 从当前节点的上一个开始遍历 + // Start traversal from previous node of current node for (node = grabc->link.prev; node != &clients; node = node->prev) { tc = wl_container_of(node, tc, link); @@ -108,7 +108,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, } if (!begin_find_prevprev && VISIBLEON(tc, grabc->mon) && - ISTILED(tc)) { // 根据你的实际字段名调整 + ISTILED(tc)) { // Adjust according to your actual field names prev = tc; begin_find_prevprev = true; continue; @@ -119,7 +119,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, drag_begin_cursorx = cursor->x; drag_begin_cursory = cursor->y; start_drag_window = true; - // 记录初始状态 + // Record initial state grabc->old_master_mfact_per = grabc->master_mfact_per; grabc->old_master_inner_per = grabc->master_inner_per; grabc->old_stack_inner_per = grabc->stack_inner_per; @@ -127,10 +127,10 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, cursor->y < grabc->geom.y + grabc->geom.height / 2; grabc->cursor_in_left_half = cursor->x < grabc->geom.x + grabc->geom.width / 2; - // 记录初始几何信息 + // Record initial geometric information grabc->drag_begin_geom = grabc->geom; } else { - // 计算相对于屏幕尺寸的比例变化 + // Calculate proportional change relative to screen size if (isdrag) { offsetx = cursor->x - drag_begin_cursorx; @@ -205,11 +205,11 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, } } else if ((grabc->cursor_in_upper_half && moving_up) || (!grabc->cursor_in_upper_half && moving_down)) { - // 光标在窗口上方且向上移动,或在窗口下方且向下移动 → 增加高度 + // Cursor above window and moving up, or below window and moving down → increase height delta_y = fabsf(delta_y); delta_y = delta_y * 2; } else { - // 其他情况 → 减小高度 + // Other cases → decrease height delta_y = -fabsf(delta_y); delta_y = delta_y * 2; } @@ -231,17 +231,17 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx, delta_x = delta_x * -1.0f; } - // 直接设置新的比例,基于初始值 + 变化量 + // Directly set new proportion, based on initial value + change amount float new_master_mfact_per = grabc->old_master_mfact_per + delta_x; float new_master_inner_per = grabc->old_master_inner_per + delta_y; float new_stack_inner_per = grabc->old_stack_inner_per + delta_y; - // 应用限制,确保比例在合理范围内 + // Apply limits to ensure proportion is within reasonable range new_master_mfact_per = fmaxf(0.1f, fminf(0.9f, new_master_mfact_per)); new_master_inner_per = fmaxf(0.1f, fminf(0.9f, new_master_inner_per)); new_stack_inner_per = fmaxf(0.1f, fminf(0.9f, new_stack_inner_per)); - // 应用到所有平铺窗口 + // Apply to all tiling windows wl_list_for_each(tc, &clients, link) { if (VISIBLEON(tc, grabc->mon) && ISTILED(tc)) { tc->master_mfact_per = new_master_mfact_per; @@ -272,23 +272,23 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx, Client *prev = NULL; struct wl_list *node; - // 从当前节点的下一个开始遍历 + // Start traversal from next node of current node for (node = grabc->link.next; node != &clients; node = node->next) { tc = wl_container_of(node, tc, link); if (VISIBLEON(tc, grabc->mon) && - ISTILED(tc)) { // 根据你的实际字段名调整 + ISTILED(tc)) { // Adjust according to your actual field names next = tc; break; } } - // 从当前节点的上一个开始遍历 + // Start traversal from previous node of current node for (node = grabc->link.prev; node != &clients; node = node->prev) { tc = wl_container_of(node, tc, link); if (VISIBLEON(tc, grabc->mon) && - ISTILED(tc)) { // 根据你的实际字段名调整 + ISTILED(tc)) { // Adjust according to your actual field names prev = tc; break; } @@ -299,7 +299,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx, drag_begin_cursory = cursor->y; start_drag_window = true; - // 记录初始状态 + // Record initial state grabc->old_master_mfact_per = grabc->master_mfact_per; grabc->old_master_inner_per = grabc->master_inner_per; grabc->old_stack_inner_per = grabc->stack_inner_per; @@ -307,11 +307,11 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx, cursor->y < grabc->geom.y + grabc->geom.height / 2; grabc->cursor_in_left_half = cursor->x < grabc->geom.x + grabc->geom.width / 2; - // 记录初始几何信息 + // Record initial geometric information grabc->drag_begin_geom = grabc->geom; } else { - // 计算相对于屏幕尺寸的比例变化 - // 计算相对于屏幕尺寸的比例变化 + // Calculate proportional change relative to screen size + // Calculate proportional change relative to screen size if (isdrag) { offsetx = cursor->x - drag_begin_cursorx; @@ -326,7 +326,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx, } if (grabc->ismaster) { - // 垂直版本:左右移动调整高度比例,上下移动调整宽度比例 + // Vertical version: left-right movement adjusts height proportion, up-down movement adjusts width proportion delta_x = (float)(offsetx) * (grabc->old_master_inner_per) / grabc->drag_begin_geom.width; delta_y = (float)(offsety) * (grabc->old_master_mfact_per) / @@ -349,56 +349,56 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx, moving_right = cursor->x > drag_begin_cursorx; } - // 调整主区域和栈区域的高度比例(垂直分割) + // Adjust height proportion of master and stack areas (vertical split) if (grabc->ismaster && !prev) { if (moving_left) { - delta_x = -fabsf(delta_x); // 向上移动减少主区域高度 + delta_x = -fabsf(delta_x); // Move up to decrease master area height } else { - delta_x = fabsf(delta_x); // 向下移动增加主区域高度 + delta_x = fabsf(delta_x); // Move down to increase master area height } } else if (grabc->ismaster && next && !next->ismaster) { if (moving_left) { - delta_x = fabsf(delta_x); // 向上移动增加主区域高度 + delta_x = fabsf(delta_x); // Move up to increase master area height } else { - delta_x = -fabsf(delta_x); // 向下移动减少主区域高度 + delta_x = -fabsf(delta_x); // Move down to decrease master area height } } else if (!grabc->ismaster && prev && prev->ismaster) { if (moving_left) { - delta_x = -fabsf(delta_x); // 向上移动减少栈区域高度 + delta_x = -fabsf(delta_x); // Move up to decrease stack area height } else { - delta_x = fabsf(delta_x); // 向下移动增加栈区域高度 + delta_x = fabsf(delta_x); // Move down to increase stack area height } } else if (!grabc->ismaster && !next) { if (moving_left) { - delta_x = fabsf(delta_x); // 向上移动增加栈区域高度 + delta_x = fabsf(delta_x); // Move up to increase stack area height } else { - delta_x = -fabsf(delta_x); // 向下移动减少栈区域高度 + delta_x = -fabsf(delta_x); // Move down to decrease stack area height } } else if ((grabc->cursor_in_left_half && moving_left) || (!grabc->cursor_in_left_half && moving_right)) { - // 光标在窗口左侧且向左移动,或在窗口右侧且向右移动 → 增加宽度 + // Cursor on left side of window and moving left, or on right side and moving right → increase width delta_x = fabsf(delta_x); delta_x = delta_x * 2; } else { - // 其他情况 → 减小宽度 + // Other cases → decrease width delta_x = -fabsf(delta_x); delta_x = delta_x * 2; } - // 直接设置新的比例,基于初始值 + 变化量 + // Directly set new proportion, based on initial value + change amount float new_master_mfact_per = grabc->old_master_mfact_per + - delta_y; // 垂直:delta_y调整主区域高度 + delta_y; // Vertical: delta_y adjusts master area height float new_master_inner_per = grabc->old_master_inner_per + - delta_x; // 垂直:delta_x调整主区域内部宽度 + delta_x; // Vertical: delta_x adjusts master area internal width float new_stack_inner_per = grabc->old_stack_inner_per + - delta_x; // 垂直:delta_x调整栈区域内部宽度 + delta_x; // Vertical: delta_x adjusts stack area internal width - // 应用限制,确保比例在合理范围内 + // Apply limits to ensure proportion is within reasonable range new_master_mfact_per = fmaxf(0.1f, fminf(0.9f, new_master_mfact_per)); new_master_inner_per = fmaxf(0.1f, fminf(0.9f, new_master_inner_per)); new_stack_inner_per = fmaxf(0.1f, fminf(0.9f, new_stack_inner_per)); - // 应用到所有平铺窗口 + // Apply to all tiling windows wl_list_for_each(tc, &clients, link) { if (VISIBLEON(tc, grabc->mon) && ISTILED(tc)) { tc->master_mfact_per = new_master_mfact_per; @@ -437,7 +437,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx, drag_begin_cursory = cursor->y; start_drag_window = true; - // 记录初始状态 + // Record initial state stack_head->old_scroller_pproportion = stack_head->scroller_proportion; grabc->old_stack_proportion = grabc->stack_proportion; @@ -445,11 +445,11 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx, cursor->x < grabc->geom.x + grabc->geom.width / 2; grabc->cursor_in_upper_half = cursor->y < grabc->geom.y + grabc->geom.height / 2; - // 记录初始几何信息 + // Record initial geometric information grabc->drag_begin_geom = grabc->geom; } else { - // 计算相对于屏幕尺寸的比例变化 - // 计算相对于屏幕尺寸的比例变化 + // Calculate proportional change relative to screen size + // Calculate proportional change relative to screen size if (isdrag) { offsetx = cursor->x - drag_begin_cursorx; @@ -499,10 +499,10 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx, if ((grabc->cursor_in_upper_half && moving_up) || (!grabc->cursor_in_upper_half && moving_down)) { - // 光标在窗口上方且向上移动,或在窗口下方且向下移动 → 增加高度 + // Cursor above window and moving up, or below window and moving down → increase height delta_y = fabsf(delta_y); } else { - // 其他情况 → 减小高度 + // Other cases → decrease height delta_y = -fabsf(delta_y); } @@ -568,7 +568,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx, } } - // 直接设置新的比例,基于初始值 + 变化量 + // Directly set new proportion, based on initial value + change amount if (isvertical) { new_scroller_proportion = stack_head->old_scroller_pproportion + delta_y; @@ -580,7 +580,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx, new_stack_proportion = grabc->old_stack_proportion + delta_y; } - // 应用限制,确保比例在合理范围内 + // Apply limits to ensure proportion is within reasonable range new_scroller_proportion = fmaxf(0.1f, fminf(1.0f, new_scroller_proportion)); new_stack_proportion = fmaxf(0.1f, fminf(1.0f, new_stack_proportion)); @@ -705,7 +705,7 @@ void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num, } } -void // 17 +void // Main arrange function arrange(Monitor *m, bool want_animation, bool from_view) { Client *c = NULL; double total_stack_inner_percent = 0; diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index e1a335d1..67ae1cdd 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -1,4 +1,4 @@ -// 网格布局窗口大小和位置计算 +// Grid layout window size and position calculation void grid(Monitor *m) { int32_t i, n; int32_t cx, cy, cw, ch; @@ -16,7 +16,7 @@ void grid(Monitor *m) { n = m->isoverview ? m->visible_clients : m->visible_tiling_clients; if (n == 0) { - return; // 没有需要处理的客户端,直接返回 + return; // No clients to process, return directly } if (n == 1) { @@ -68,7 +68,7 @@ void grid(Monitor *m) { return; } - // 计算列数和行数 + // Calculate columns and rows for (cols = 0; cols <= n / 2; cols++) { if (cols * cols >= n) { break; @@ -76,18 +76,18 @@ void grid(Monitor *m) { } rows = (cols && (cols - 1) * cols >= n) ? cols - 1 : cols; - // 计算每个客户端的高度和宽度 + // Calculate height and width for each client ch = (m->w.height - 2 * target_gappo - (rows - 1) * target_gappi) / rows; cw = (m->w.width - 2 * target_gappo - (cols - 1) * target_gappi) / cols; - // 处理多余的列 + // Handle extra columns overcols = n % cols; if (overcols) { dx = (m->w.width - overcols * cw - (overcols - 1) * target_gappi) / 2 - target_gappo; } - // 调整每个客户端的位置和大小 + // Adjust position and size for each client i = 0; wl_list_for_each(c, &clients, link) { @@ -273,13 +273,13 @@ void horizontal_check_scroller_root_inside_mon(Client *c, } } -// 滚动布局 +// Scroll layout void scroller(Monitor *m) { int32_t i, n, j; float single_proportion = 1.0; Client *c = NULL, *root_client = NULL; - Client **tempClients = NULL; // 初始化为 NULL + Client **tempClients = NULL; // Initialize to NULL struct wlr_box target_geom; int32_t focus_client_index = 0; bool need_scroller = false; @@ -300,17 +300,17 @@ void scroller(Monitor *m) { n = m->visible_scroll_tiling_clients; if (n == 0) { - return; // 没有需要处理的客户端,直接返回 + return; // No clients to process, return directly } - // 动态分配内存 + // Allocate memory dynamically tempClients = malloc(n * sizeof(Client *)); if (!tempClients) { - // 处理内存分配失败的情况 + // Handle memory allocation failure return; } - // 第二次遍历,填充 tempClients + // Second pass: fill tempClients j = 0; wl_list_for_each(c, &clients, link) { if (VISIBLEON(c, m) && ISSCROLLTILED(c) && !c->prev_in_stack) { @@ -333,7 +333,7 @@ void scroller(Monitor *m) { target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; horizontal_check_scroller_root_inside_mon(c, &target_geom); arrange_stack(c, target_geom, cur_gappiv); - free(tempClients); // 释放内存 + free(tempClients); // Release memory return; } @@ -352,7 +352,7 @@ void scroller(Monitor *m) { } if (!root_client) { - free(tempClients); // 释放内存 + free(tempClients); // Release memory return; } @@ -440,7 +440,7 @@ void scroller(Monitor *m) { arrange_stack(c, target_geom, cur_gappiv); } - free(tempClients); // 最后释放内存 + free(tempClients); // Finally release memory } void center_tile(Monitor *m) { @@ -460,19 +460,19 @@ void center_tile(Monitor *m) { if (n == 0) return; - // 获取第一个可见的平铺客户端用于主区域宽度百分比 + // Get the first visible tiling client for master area width percentage wl_list_for_each(fc, &clients, link) { if (VISIBLEON(fc, m) && ISTILED(fc)) break; } - // 间隙参数处理 - int32_t cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙 - int32_t cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙 - int32_t cur_gappov = enablegaps ? m->gappov : 0; // 外部垂直间隙 - int32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙 + // Gap parameter handling + int32_t cur_gappiv = enablegaps ? m->gappiv : 0; // Internal vertical gap + int32_t cur_gappih = enablegaps ? m->gappih : 0; // Internal horizontal gap + int32_t cur_gappov = enablegaps ? m->gappov : 0; // Outer vertical gap + int32_t cur_gappoh = enablegaps ? m->gappoh : 0; // Outer horizontal gap - // 智能间隙处理 + // Smart gap handling cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; @@ -482,13 +482,13 @@ void center_tile(Monitor *m) { mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per : m->pertag->mfacts[m->pertag->curtag]; - // 初始化区域 + // Initialize areas mw = m->w.width; mx = cur_gappoh; my = cur_gappov; tw = mw; - // 判断是否需要主区域铺满 + // Determine if master area should overspread int32_t should_overspread = center_master_overspread && (n <= nmasters); int32_t master_surplus_height = @@ -505,35 +505,35 @@ void center_tile(Monitor *m) { float slave_right_surplus_ratio = 1.0; if (n > nmasters || !should_overspread) { - // 计算主区域宽度(居中模式) + // Calculate master area width (centered mode) mw = nmasters ? (m->w.width - 2 * cur_gappoh - cur_gappih * ie) * mfact : 0; if (n - nmasters > 1) { - // 多个堆叠窗口:主区域居中,左右两侧各有一个堆叠区域 + // Multiple stack windows: master centered, one stack area on each side tw = (m->w.width - mw) / 2 - cur_gappoh - cur_gappih * ie; mx = cur_gappoh + tw + cur_gappih * ie; } else if (n - nmasters == 1) { - // 单个堆叠窗口的处理 + // Single stack window handling if (center_when_single_stack) { - // stack在右边,master居中,左边空着 + // stack on the right, master centered, left side empty tw = (m->w.width - mw) / 2 - cur_gappoh - cur_gappih * ie; - mx = cur_gappoh + tw + cur_gappih * ie; // master居中 + mx = cur_gappoh + tw + cur_gappih * ie; // master centered } else { - // stack在右边,master在左边 + // stack on the right, master on the left tw = m->w.width - mw - 2 * cur_gappoh - cur_gappih * ie; - mx = cur_gappoh; // master在左边 + mx = cur_gappoh; // master on the left } } else { - // 只有主区域窗口:居中显示 + // Only master area windows: center display tw = (m->w.width - mw) / 2 - cur_gappoh - cur_gappih * ie; mx = cur_gappoh + tw + cur_gappih * ie; } } else { - // 主区域铺满模式(只有主区域窗口时) + // Master area overspread mode (when only master area windows exist) mw = m->w.width - 2 * cur_gappoh; mx = cur_gappoh; - tw = 0; // 堆叠区域宽度为0 + tw = 0; // Stack area width is 0 } oty = cur_gappov; @@ -545,7 +545,7 @@ void center_tile(Monitor *m) { continue; if (i < nmasters) { - // 主区域窗口 + // Master area windows r = MIN(n, nmasters) - i; if (c->master_inner_per > 0.0f) { h = master_surplus_height * c->master_inner_per / @@ -571,11 +571,11 @@ void center_tile(Monitor *m) { 0); my += c->geom.height + cur_gappiv * ie; } else { - // 堆叠区域窗口 + // Stack area windows int32_t stack_index = i - nmasters; if (n - nmasters == 1) { - // 单个堆叠窗口 + // Single stack window r = n - i; if (c->stack_inner_per > 0.0f) { h = (m->w.height - 2 * cur_gappov - @@ -593,10 +593,10 @@ void center_tile(Monitor *m) { int32_t stack_x; if (center_when_single_stack) { - // 放在右侧(master居中时,stack在右边) + // Place on the right (when master is centered, stack is on the right) stack_x = m->w.x + mx + mw + cur_gappih * ie; } else { - // 放在右侧(master在左边时,stack在右边) + // Place on the right (when master is on the left, stack is on the right) stack_x = m->w.x + mx + mw + cur_gappih * ie; } @@ -608,11 +608,11 @@ void center_tile(Monitor *m) { 0); ety += c->geom.height + cur_gappiv * ie; } else { - // 多个堆叠窗口:交替放在左右两侧 + // Multiple stack windows: alternate on left and right sides r = (n - i + 1) / 2; if ((stack_index % 2) ^ (n % 2 == 0)) { - // 右侧堆叠窗口 + // Right stack window if (c->stack_inner_per > 0.0f) { h = slave_right_surplus_height * c->stack_inner_per / slave_right_surplus_ratio; @@ -641,7 +641,7 @@ void center_tile(Monitor *m) { 0); ety += c->geom.height + cur_gappiv * ie; } else { - // 左侧堆叠窗口 + // Left stack window if (c->stack_inner_per > 0.0f) { h = slave_left_surplus_height * c->stack_inner_per / slave_left_surplus_ratio; diff --git a/src/layout/layout.h b/src/layout/layout.h index f896ac27..d3890c6c 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -32,19 +32,19 @@ enum { }; Layout layouts[] = { - // 最少两个,不能删除少于两个 + // At least two required, cannot delete to less than two /* symbol arrange function name */ - {"T", tile, "tile", TILE}, // 平铺布局 - {"S", scroller, "scroller", SCROLLER}, // 滚动布局 - {"G", grid, "grid", GRID}, // 格子布局 - {"M", monocle, "monocle", MONOCLE}, // 单屏布局 - {"K", deck, "deck", DECK}, // 卡片布局 - {"CT", center_tile, "center_tile", CENTER_TILE}, // 居中布局 - {"RT", right_tile, "right_tile", RIGHT_TILE}, // 右布局 + {"T", tile, "tile", TILE}, // Tile layout + {"S", scroller, "scroller", SCROLLER}, // Scroll layout + {"G", grid, "grid", GRID}, // Grid layout + {"M", monocle, "monocle", MONOCLE}, // Monocle layout + {"K", deck, "deck", DECK}, // Deck layout + {"CT", center_tile, "center_tile", CENTER_TILE}, // Center tile layout + {"RT", right_tile, "right_tile", RIGHT_TILE}, // Right tile layout {"VS", vertical_scroller, "vertical_scroller", - VERTICAL_SCROLLER}, // 垂直滚动布局 - {"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局 - {"VG", vertical_grid, "vertical_grid", VERTICAL_GRID}, // 垂直格子布局 - {"VK", vertical_deck, "vertical_deck", VERTICAL_DECK}, // 垂直卡片布局 - {"TG", tgmix, "tgmix", TGMIX}, // 混合布局 + VERTICAL_SCROLLER}, // Vertical scroll layout + {"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // Vertical tile layout + {"VG", vertical_grid, "vertical_grid", VERTICAL_GRID}, // Vertical grid layout + {"VK", vertical_deck, "vertical_deck", VERTICAL_DECK}, // Vertical deck layout + {"TG", tgmix, "tgmix", TGMIX}, // Mix layout }; \ No newline at end of file diff --git a/src/layout/vertical.h b/src/layout/vertical.h index f7bd442c..a3179d25 100644 --- a/src/layout/vertical.h +++ b/src/layout/vertical.h @@ -260,7 +260,7 @@ void vertical_check_scroller_root_inside_mon(Client *c, } } -// 竖屏滚动布局 +// Vertical scroll layout void vertical_scroller(Monitor *m) { int32_t i, n, j; float single_proportion = 1.0; diff --git a/src/mango.c b/src/mango.c index ae163a75..1a4bcaac 100644 --- a/src/mango.c +++ b/src/mango.c @@ -166,7 +166,7 @@ enum { VERTICAL, HORIZONTAL }; enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT }; enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ enum { XDGShell, LayerShell, X11 }; /* client types */ -enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // 滚轮滚动的方向 +enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // Mouse wheel scroll directions enum { LyrBg, LyrBlur, @@ -205,7 +205,7 @@ enum seat_config_shortcuts_inhibit { SHORTCUTS_INHIBIT_ENABLE, }; -// 事件掩码枚举 +// Event mask enum enum print_event_type { PRINT_ACTIVE = 1 << 0, PRINT_TAG = 1 << 1, @@ -224,7 +224,7 @@ enum print_event_type { PRINT_KEYMODE = 1 << 14, PRINT_SCALEFACTOR = 1 << 15, PRINT_FRAME = 1 << 16, - PRINT_ALL = (1 << 17) - 1 // 所有位都设为1 + PRINT_ALL = (1 << 17) - 1 // All bits set to 1 }; typedef struct Pertag Pertag; @@ -256,7 +256,7 @@ typedef struct { uint32_t button; int32_t (*func)(const Arg *); const Arg arg; -} Button; // 鼠标按键 +} Button; // Mouse buttons typedef struct { char mode[28]; @@ -564,18 +564,18 @@ typedef struct { /* function declarations */ static void applybounds( Client *c, - struct wlr_box *bbox); // 设置边界规则,能让一些窗口拥有比较适合的大小 -static void applyrules(Client *c); // 窗口规则应用,应用config.h中定义的窗口规则 + struct wlr_box *bbox); // Set boundary rules to allow some windows to have appropriate sizes +static void applyrules(Client *c); // Apply window rules defined in config.h static void arrange(Monitor *m, bool want_animation, - bool from_view); // 布局函数,让窗口俺平铺规则移动和重置大小 + bool from_view); // Layout function to move and resize windows according to tiling rules static void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int32_t exclusive); static void arrangelayers(Monitor *m); static void handle_print_status(struct wl_listener *listener, void *data); static void axisnotify(struct wl_listener *listener, - void *data); // 滚轮事件处理 + void *data); // Mouse wheel event handling static void buttonpress(struct wl_listener *listener, - void *data); // 鼠标按键事件处理 + void *data); // Mouse button event handling static int32_t ongesture(struct wlr_pointer_swipe_end_event *event); static void swipe_begin(struct wl_listener *listener, void *data); static void swipe_update(struct wl_listener *listener, void *data); @@ -591,7 +591,7 @@ static void cleanupmon(struct wl_listener *listener, void *data); // Monitor cleanup static void closemon(Monitor *m); static void cleanuplisteners(void); -static void toggle_hotarea(int32_t x_root, int32_t y_root); // 触发热区 +static void toggle_hotarea(int32_t x_root, int32_t y_root); // Trigger hot area static void maplayersurfacenotify(struct wl_listener *listener, void *data); static void commitlayersurfacenotify(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data); @@ -1029,7 +1029,7 @@ void clear_fullscreen_and_maximized_state(Monitor *m) { } } -/*清除全屏标志,还原全屏时清0的border*/ +/*Clear fullscreen flag and restore border that was set to 0 during fullscreen*/ void clear_fullscreen_flag(Client *c) { if ((c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id == @@ -1052,7 +1052,7 @@ void clear_fullscreen_flag(Client *c) { void show_scratchpad(Client *c) { c->is_scratchpad_show = 1; if (c->isfullscreen || c->ismaximizescreen) { - c->isfullscreen = 0; // 清除窗口全屏标志 + c->isfullscreen = 0; // Clear window fullscreen flag c->ismaximizescreen = 0; c->bw = c->isnoborder ? 0 : borderpx; } @@ -1066,7 +1066,7 @@ void show_scratchpad(Client *c) { c->geom.height = c->iscustomsize ? c->float_geom.height : c->mon->w.height * scratchpad_height_ratio; - // 重新计算居中的坐标 + // Recalculate centered coordinates c->float_geom = c->geom = c->animainit_geom = c->animation.current = setclient_coordinate_center(c, c->mon, c->geom, 0, 0); c->iscustomsize = 1; @@ -1074,8 +1074,8 @@ void show_scratchpad(Client *c) { } c->oldtags = c->mon->tagset[c->mon->seltags]; - wl_list_remove(&c->link); // 从原来位置移除 - wl_list_insert(clients.prev->next, &c->link); // 插入开头 + wl_list_remove(&c->link); // Remove from original position + wl_list_insert(clients.prev->next, &c->link); // Insert at head show_hide_client(c); setborder_color(c); } @@ -1135,14 +1135,14 @@ bool switch_scratchpad_client_state(Client *c) { if (scratchpad_cross_monitor && selmon && c->mon != selmon && c->is_in_scratchpad) { - // 保存原始monitor用于尺寸计算 + // Save original monitor for size calculation Monitor *oldmon = c->mon; c->scratchpad_switching_mon = true; c->mon = selmon; reset_foreign_tolevel(c); client_update_oldmonname_record(c, selmon); - // 根据新monitor调整窗口尺寸 + // Adjust window size based on new monitor c->float_geom.width = (int32_t)(c->float_geom.width * c->mon->w.width / oldmon->w.width); c->float_geom.height = (int32_t)(c->float_geom.height * @@ -1151,7 +1151,7 @@ bool switch_scratchpad_client_state(Client *c) { c->float_geom = setclient_coordinate_center(c, c->mon, c->float_geom, 0, 0); - // 只有显示状态的scratchpad才需要聚焦和返回true + // Only scratchpad in displayed state needs focus and returns true if (c->is_scratchpad_show) { c->tags = get_tags_first_tag(selmon->tagset[selmon->seltags]); resize(c, c->float_geom, 0); @@ -1239,59 +1239,59 @@ void handlesig(int32_t signo) { } void toggle_hotarea(int32_t x_root, int32_t y_root) { - // 左下角热区坐标计算,兼容多显示屏 + // Bottom-left hot area coordinate calculation, compatible with multiple displays Arg arg = {0}; - // 在刚启动的时候,selmon为NULL,但鼠标可能已经处于热区, - // 必须判断避免奔溃 + // At startup, selmon is NULL, but mouse may already be in hot area, + // Must check to avoid crash if (!selmon) return; if (grabc) return; - // 根据热角位置计算不同的热区坐标 + // Calculate different hot area coordinates based on hot corner position unsigned hx, hy; switch (hotarea_corner) { - case BOTTOM_RIGHT: // 右下角 + case BOTTOM_RIGHT: // Bottom-right corner hx = selmon->m.x + selmon->m.width - hotarea_size; hy = selmon->m.y + selmon->m.height - hotarea_size; break; - case TOP_LEFT: // 左上角 + case TOP_LEFT: // Top-left corner hx = selmon->m.x + hotarea_size; hy = selmon->m.y + hotarea_size; break; - case TOP_RIGHT: // 右上角 + case TOP_RIGHT: // Top-right corner hx = selmon->m.x + selmon->m.width - hotarea_size; hy = selmon->m.y + hotarea_size; break; - case BOTTOM_LEFT: // 左下角(默认) + case BOTTOM_LEFT: // Bottom-left corner (default) default: hx = selmon->m.x + hotarea_size; hy = selmon->m.y + selmon->m.height - hotarea_size; break; } - // 判断鼠标是否在热区内 + // Check if mouse is in hot area int in_hotarea = 0; switch (hotarea_corner) { - case BOTTOM_RIGHT: // 右下角 + case BOTTOM_RIGHT: // Bottom-right corner in_hotarea = (y_root > hy && x_root > hx && x_root <= (selmon->m.x + selmon->m.width) && y_root <= (selmon->m.y + selmon->m.height)); break; - case TOP_LEFT: // 左上角 + case TOP_LEFT: // Top-left corner in_hotarea = (y_root < hy && x_root < hx && x_root >= selmon->m.x && y_root >= selmon->m.y); break; - case TOP_RIGHT: // 右上角 + case TOP_RIGHT: // Top-right corner in_hotarea = (y_root < hy && x_root > hx && x_root <= (selmon->m.x + selmon->m.width) && y_root >= selmon->m.y); break; - case BOTTOM_LEFT: // 左下角(默认) + case BOTTOM_LEFT: // Bottom-left corner (default) default: in_hotarea = (y_root > hy && x_root < hx && x_root >= selmon->m.x && y_root <= (selmon->m.y + selmon->m.height)); @@ -1748,7 +1748,7 @@ void arrangelayers(Monitor *m) { reset_exclusive_layer(m); } -void // 鼠标滚轮事件 +void // Mouse wheel event axisnotify(struct wl_listener *listener, void *data) { /* This event is forwarded by the cursor when a pointer emits an axis event, @@ -1784,14 +1784,14 @@ axisnotify(struct wl_listener *listener, void *data) { if (config.axis_bindings_count < 1) break; a = &config.axis_bindings[ji]; - if (CLEANMASK(mods) == CLEANMASK(a->mod) && // 按键一致 - adir == a->dir && a->func) { // 滚轮方向判断一致且处理函数存在 + if (CLEANMASK(mods) == CLEANMASK(a->mod) && // Keys match + adir == a->dir && a->func) { // Scroll direction matches and handler function exists if (event->time_msec - axis_apply_time > axis_bind_apply_timeout || axis_apply_dir * event->delta < 0) { a->func(&a->arg); axis_apply_time = event->time_msec; axis_apply_dir = event->delta > 0 ? 1 : -1; - return; // 如果成功匹配就不把这个滚轮事件传送给客户端了 + return; // If successfully matched, do not send this wheel event to client } else { axis_apply_dir = event->delta > 0 ? 1 : -1; axis_apply_time = event->time_msec; @@ -1805,7 +1805,7 @@ axisnotify(struct wl_listener *listener, void *data) { */ /* Notify the client with pointer focus of the axis event. */ wlr_seat_pointer_notify_axis( - seat, // 滚轮事件发送给客户端也就是窗口 + seat, // Send wheel event to client (window) event->time_msec, event->orientation, event->delta * axis_scroll_factor, roundf(event->delta_discrete * axis_scroll_factor), event->source, event->relative_direction); @@ -1969,16 +1969,16 @@ bool check_trackpad_disabled(struct wlr_pointer *pointer) { if (wlr_input_device_is_libinput(&pointer->base) && (device = wlr_libinput_get_device_handle(&pointer->base))) { - // 如果是触摸板且被禁用,忽略事件 + // If it is touchpad and disabled, ignore event if (libinput_device_config_tap_get_finger_count(device) > 0) { - return true; // 不处理事件 + return true; // Do not handle event } } return false; } -void // 鼠标按键事件 +void // Mouse button event buttonpress(struct wl_listener *listener, void *data) { struct wlr_pointer_button_event *event = data; struct wlr_keyboard *hard_keyboard, *keyboard; @@ -2017,7 +2017,7 @@ buttonpress(struct wl_listener *listener, void *data) { motionnotify(0, NULL, 0, 0, 0, 0); } - // 聚焦按需要交互焦点的layer,但注意不能抢占独占焦点的layer + // Focus layer that needs interactive focus, but note cannot preempt exclusive focus layer if (l && !exclusive_focus && l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { @@ -2025,8 +2025,8 @@ buttonpress(struct wl_listener *listener, void *data) { } } - // 当鼠标焦点在layer上的时候,不检测虚拟键盘的mod状态, - // 避免layer虚拟键盘锁死mod按键状态 + // When mouse focus is on layer, do not detect virtual keyboard mod state, + // Avoid layer virtual keyboard locking mod key state hard_keyboard = &kb_group->wlr_group->keyboard; hard_mods = hard_keyboard ? wlr_keyboard_get_modifiers(hard_keyboard) : 0; @@ -2314,7 +2314,7 @@ void layer_flush_blur_background(LayerSurface *l) { if (!blur) return; - // 如果背景层发生变化,标记优化的模糊背景缓存需要更新 + // If background layer changes, mark optimized blur background cache needs update if (l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { if (l->mon) { @@ -2334,11 +2334,11 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { if (!l->mon) return; strncpy(l->mon->last_surface_ws_name, layer_surface->namespace, - sizeof(l->mon->last_surface_ws_name) - 1); // 最多拷贝255个字符 + sizeof(l->mon->last_surface_ws_name) - 1); // Copy at most 255 characters l->mon->last_surface_ws_name[sizeof(l->mon->last_surface_ws_name) - 1] = - '\0'; // 确保字符串以null结尾 + '\0'; // Ensure string ends with null - // 初始化几何位置 + // Initialize geometric position get_layer_target_geometry(l, &l->geom); l->noanim = 0; @@ -2347,7 +2347,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { l->shadow = NULL; l->need_output_flush = true; - // 应用layer规则 + // Apply layer rules for (ji = 0; ji < config.layer_rules_count; ji++) { if (config.layer_rules_count < 1) break; @@ -2363,7 +2363,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { } } - // 初始化阴影 + // Initialize shadow if (layer_surface->current.exclusive_zone == 0 && layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM && layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { @@ -2373,16 +2373,16 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { wlr_scene_node_set_enabled(&l->shadow->node, true); } - // 初始化动画 + // Initialize animation if (animations && layer_animations && !l->noanim) { l->animation.duration = animation_duration_open; l->animation.action = OPEN; layer_set_pending_state(l); } - // 刷新布局,让窗口能感应到exclude_zone变化以及设置独占表面 + // Refresh layout so windows can sense exclude_zone changes and set exclusive surface arrangelayers(l->mon); - // 按需交互layer需要像正常窗口一样抢占非独占layer的焦点 + // On-demand interactive layer needs to preempt non-exclusive layer focus like normal window if (!exclusive_focus && l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { @@ -2411,8 +2411,8 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) { return; } - // 检查surface是否有buffer - // 空buffer,只是隐藏,不改变mapped状态 + // Check if surface has buffer + // Empty buffer, just hide, do not change mapped state if (l->mapped && !layer_surface->surface->buffer) { wlr_scene_node_set_enabled(&l->scene->node, false); return; @@ -2438,7 +2438,7 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) { } if (blur && blur_layer) { - // 设置非背景layer模糊 + // Set non-background layer blur if (!l->noblur && layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM && @@ -2834,10 +2834,10 @@ void createmon(struct wl_listener *listener, void *data) { r = &config.monitor_rules[ji]; - // 检查是否匹配的变量 + // Check if variable matches match_rule = true; - // 检查四个标识字段的匹配 + // Check matching of four identifier fields if (r->name != NULL) { if (!regex_match(r->name, m->wlr_output->name)) { match_rule = false; @@ -3007,30 +3007,30 @@ void destroyinputdevice(struct wl_listener *listener, void *data) { InputDevice *input_dev = wl_container_of(listener, input_dev, destroy_listener); - // 清理设备特定数据 + // Clean up device-specific data if (input_dev->device_data) { - // 根据设备类型进行特定清理 + // Perform specific cleanup based on device type switch (input_dev->wlr_device->type) { case WLR_INPUT_DEVICE_SWITCH: { Switch *sw = (Switch *)input_dev->device_data; - // 移除 toggle 监听器 + // Remove toggle listener wl_list_remove(&sw->toggle.link); - // 释放 Switch 内存 + // Release Switch memory free(sw); break; } - // 可以添加其他设备类型的清理代码 + // Can add cleanup code for other device types default: break; } input_dev->device_data = NULL; } - // 从设备列表中移除 + // Remove from device list wl_list_remove(&input_dev->link); - // 移除 destroy 监听器 + // Remove destroy listener wl_list_remove(&input_dev->destroy_listener.link); - // 释放内存 + // Release memory free(input_dev); } @@ -3105,10 +3105,10 @@ void createpointer(struct wlr_pointer *pointer) { } void switch_toggle(struct wl_listener *listener, void *data) { - // 获取包含监听器的结构体 + // Get structure containing listener Switch *sw = wl_container_of(listener, sw, toggle); - // 处理切换事件 + // Handle switch event struct wlr_switch_toggle_event *event = data; SwitchBinding *s; int32_t ji; @@ -3134,25 +3134,25 @@ void createswitch(struct wlr_switch *switch_device) { InputDevice *input_dev = calloc(1, sizeof(InputDevice)); input_dev->wlr_device = &switch_device->base; input_dev->libinput_device = device; - input_dev->device_data = NULL; // 初始化为 NULL + input_dev->device_data = NULL; // Initialize to NULL input_dev->destroy_listener.notify = destroyinputdevice; wl_signal_add(&switch_device->base.events.destroy, &input_dev->destroy_listener); - // 创建 Switch 特定数据 + // Create Switch-specific data Switch *sw = calloc(1, sizeof(Switch)); sw->wlr_switch = switch_device; sw->toggle.notify = switch_toggle; sw->input_dev = input_dev; - // 将 Switch 指针保存到 input_device 中 + // Save Switch pointer to input_device input_dev->device_data = sw; - // 添加 toggle 监听器 + // Add toggle listener wl_signal_add(&switch_device->events.toggle, &sw->toggle); - // 添加到全局列表 + // Add to global list wl_list_insert(&inputdevices, &input_dev->link); } } @@ -3364,7 +3364,7 @@ void focusclient(Client *c, int32_t lift) { /* Raise client in stacking order if requested */ if (c && lift) - wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 + wlr_scene_node_raise_to_top(&c->scene->node); // Raise view to top if (c && client_surface(c) == old_keyboard_focus_surface && selmon && selmon->sel) @@ -4020,7 +4020,7 @@ mapnotify(struct wl_listener *listener, void *data) { if (new_is_master && selmon && !is_scroller_layout(selmon)) // tile at the top - wl_list_insert(&clients, &c->link); // 新窗口是master,头部入栈 + wl_list_insert(&clients, &c->link); // New window is master, insert at head else if (selmon && is_scroller_layout(selmon) && selmon->visible_scroll_tiling_clients > 0) { @@ -4037,10 +4037,10 @@ mapnotify(struct wl_listener *listener, void *data) { c->link.next = at_client->link.next; at_client->link.next = &c->link; } else { - wl_list_insert(clients.prev, &c->link); // 尾部入栈 + wl_list_insert(clients.prev, &c->link); // Insert at tail } } else - wl_list_insert(clients.prev, &c->link); // 尾部入栈 + wl_list_insert(clients.prev, &c->link); // Insert at tail wl_list_insert(&fstack, &c->flink); applyrules(c); @@ -4118,8 +4118,8 @@ void set_minimized(Client *c) { arrange(c->mon, false, false); wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, false); wlr_foreign_toplevel_handle_v1_set_minimized(c->foreign_toplevel, true); - wl_list_remove(&c->link); // 从原来位置移除 - wl_list_insert(clients.prev, &c->link); // 插入尾部 + wl_list_remove(&c->link); // Remove from original position + wl_list_insert(clients.prev, &c->link); // Insert at tail } void minimizenotify(struct wl_listener *listener, void *data) { @@ -4423,7 +4423,7 @@ void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, wlr_seat_pointer_notify_motion(seat, time, sx, sy); } -// 修改printstatus函数,接受掩码参数 +// Modify printstatus function to accept mask parameter void printstatus(void) { wl_signal_emit(&mango_print_status, NULL); } void powermgrsetmode(struct wl_listener *listener, void *data) { @@ -4502,7 +4502,7 @@ void rendermon(struct wl_listener *listener, void *data) { frame_allow_tearing = check_tearing_frame_allow(m); - // 绘制层和淡出效果 + // Draw layers and fade effects for (i = 0; i < LENGTH(m->layers); i++) { layer_list = &m->layers[i]; wl_list_for_each_safe(l, tmpl, layer_list, link) { @@ -4518,7 +4518,7 @@ void rendermon(struct wl_listener *listener, void *data) { need_more_frames = layer_draw_fadeout_frame(l) || need_more_frames; } - // 绘制客户端 + // Draw clients wl_list_for_each(c, &clients, link) { need_more_frames = client_draw_frame(c) || need_more_frames; if (!animations && !(allow_tearing && frame_allow_tearing) && @@ -4533,7 +4533,7 @@ void rendermon(struct wl_listener *listener, void *data) { monitor_stop_skip_timer(m); } - // 只有在需要帧时才构建和提交状态 + // Only build and commit state when frame is needed if (allow_tearing && frame_allow_tearing) { apply_tear_state(m); } else { @@ -4541,7 +4541,7 @@ void rendermon(struct wl_listener *listener, void *data) { } skip: - // 发送帧完成通知 + // Send frame done notification clock_gettime(CLOCK_MONOTONIC, &now); if (allow_tearing && frame_allow_tearing) { wlr_scene_output_send_frame_done(m->scene_output, &now); @@ -4550,7 +4550,7 @@ skip: wlr_output_state_finish(&pending); } - // 如果需要更多帧,确保安排下一帧 + // If more frames needed, ensure next frame is scheduled if (need_more_frames && allow_frame_scheduling) { request_fresh_all_monitors(); } @@ -4561,11 +4561,11 @@ void requestdecorationmode(struct wl_listener *listener, void *data) { struct wlr_xdg_toplevel_decoration_v1 *deco = data; if (c->surface.xdg->initialized) { - // 获取客户端请求的模式 + // Get mode requested by client enum wlr_xdg_toplevel_decoration_v1_mode requested_mode = deco->requested_mode; - // 如果客户端没有指定,使用默认模式 + // If client did not specify, use default mode if (!c->allow_csd) { requested_mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; } @@ -4626,7 +4626,7 @@ void exchange_two_client(Client *c1, Client *c2) { Client *c1head = get_scroll_stack_head(c1); Client *c2head = get_scroll_stack_head(c2); - // 交换布局参数 + // Swap layout parameters if (c1head == c2head) { scroller_proportion = c1->scroller_proportion; stack_proportion = c1->stack_proportion; @@ -4649,13 +4649,13 @@ void exchange_two_client(Client *c1, Client *c2) { c2->master_mfact_per = master_mfact_per; c2->stack_inner_per = stack_inner_per; - // 交换栈链表连接 + // Swap stack list connections Client *tmp1_next_in_stack = c1->next_in_stack; Client *tmp1_prev_in_stack = c1->prev_in_stack; Client *tmp2_next_in_stack = c2->next_in_stack; Client *tmp2_prev_in_stack = c2->prev_in_stack; - // 处理相邻节点的情况 + // Handle adjacent node case if (c1->next_in_stack == c2) { c1->next_in_stack = tmp2_next_in_stack; c2->next_in_stack = c1; @@ -4683,13 +4683,13 @@ void exchange_two_client(Client *c1, Client *c2) { return; } - // 交换全局链表连接 + // Swap global list connections struct wl_list *tmp1_prev = c1->link.prev; struct wl_list *tmp2_prev = c2->link.prev; struct wl_list *tmp1_next = c1->link.next; struct wl_list *tmp2_next = c2->link.next; - // 处理相邻节点的情况 + // Handle adjacent node case if (c1->link.next == &c2->link) { c1->link.next = c2->link.next; c1->link.prev = &c2->link; @@ -4704,7 +4704,7 @@ void exchange_two_client(Client *c1, Client *c2) { c1->link.prev = tmp2_prev; tmp2_prev->next = &c1->link; tmp1_next->prev = &c2->link; - } else { // 不为相邻节点 + } else { // Not adjacent nodes c2->link.next = tmp1_next; c2->link.prev = tmp1_prev; c1->link.next = tmp2_next; @@ -4716,7 +4716,7 @@ void exchange_two_client(Client *c1, Client *c2) { tmp2_next->prev = &c1->link; } - // 处理跨监视器交换 + // Handle cross-monitor swap if (exchange_cross_monitor) { tmp_mon = c2->mon; tmp_tags = c2->tags; @@ -4842,14 +4842,14 @@ setfloating(Client *c, int32_t floating) { if (floating == 1 && c != grabc) { if (c->isfullscreen || c->ismaximizescreen) { - c->isfullscreen = 0; // 清除窗口全屏标志 + c->isfullscreen = 0; // Clear window fullscreen flag c->ismaximizescreen = 0; c->bw = c->isnoborder ? 0 : borderpx; } exit_scroller_stack(c); - // 重新计算居中的坐标 + // Recalculate centered coordinates if (!client_is_x11(c) && !c->iscustompos) target_box = setclient_coordinate_center(c, c->mon, target_box, 0, 0); @@ -4883,7 +4883,7 @@ setfloating(Client *c, int32_t floating) { c->is_scratchpad_show = 0; c->is_in_scratchpad = 0; c->isnamedscratchpad = 0; - // 让当前tag中的全屏窗口退出全屏参与平铺 + // Make fullscreen windows in current tag exit fullscreen to participate in tiling wl_list_for_each(fc, &clients, link) if (fc && fc != c && VISIBLEON(fc, c->mon) && c->tags & fc->tags && ISFULLSCREEN(fc)) { @@ -4973,7 +4973,7 @@ void setmaximizescreen(Client *c, int32_t maximizescreen) { maximizescreen_box.y = c->mon->w.y + gappov; maximizescreen_box.width = c->mon->w.width - 2 * gappoh; maximizescreen_box.height = c->mon->w.height - 2 * gappov; - wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 + wlr_scene_node_raise_to_top(&c->scene->node); // Raise view to top if (!is_scroller_layout(c->mon) || c->isfloating) resize(c, maximizescreen_box, 0); c->ismaximizescreen = 1; @@ -5010,7 +5010,7 @@ void setfakefullscreen(Client *c, int32_t fakefullscreen) { client_set_fullscreen(c, fakefullscreen); } -void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自带全屏 +void setfullscreen(Client *c, int32_t fullscreen) // Use custom fullscreen as proxy for built-in fullscreen { if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling) @@ -5036,7 +5036,7 @@ void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自 c->isfakefullscreen = 0; c->bw = 0; - wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 + wlr_scene_node_raise_to_top(&c->scene->node); // Raise view to top if (!is_scroller_layout(c->mon) || c->isfloating) resize(c, c->mon->m, 1); c->isfullscreen = 1; @@ -5100,17 +5100,17 @@ void reset_keyboard_layout(void) { return; } - // 现在安全地创建真正的keymap + // Now safely create the real keymap struct xkb_keymap *new_keymap = xkb_keymap_new_from_names( context, &xkb_rules, XKB_KEYMAP_COMPILE_NO_FLAGS); if (!new_keymap) { - // 理论上这里不应该失败,因为前面已经验证过了 + // Theoretically should not fail here since already validated wlr_log(WLR_ERROR, "Unexpected failure to create keymap after validation"); goto cleanup_context; } - // 验证新keymap是否有布局 + // Verify new keymap has layouts const int32_t new_num_layouts = xkb_keymap_num_layouts(new_keymap); if (new_num_layouts < 1) { wlr_log(WLR_ERROR, "New keymap has no layouts"); @@ -5118,7 +5118,7 @@ void reset_keyboard_layout(void) { goto cleanup_context; } - // 确保当前布局索引在新keymap中有效 + // Ensure current layout index is valid in new keymap if (current >= new_num_layouts) { wlr_log(WLR_INFO, "Current layout index %u out of range for new keymap, " @@ -5153,7 +5153,7 @@ void reset_keyboard_layout(void) { wlr_keyboard_notify_modifiers(tkb, depressed, latched, locked, 0); tkb->modifiers.group = 0; - // 7. 更新 seat + // 7. Update seat wlr_seat_set_keyboard(seat, tkb); wlr_seat_keyboard_notify_modifiers(seat, &tkb->modifiers); } @@ -5265,7 +5265,7 @@ void create_output(struct wlr_backend *backend, void *data) { #endif } -// 修改信号处理函数,接收掩码参数 +// Modify signal handler function to accept mask parameter void handle_print_status(struct wl_listener *listener, void *data) { Monitor *m = NULL; @@ -5374,7 +5374,7 @@ void setup(void) { wlr_alpha_modifier_v1_create(dpy); wlr_ext_data_control_manager_v1_create(dpy, 1); - // 在 setup 函数中 + // In setup function wl_signal_init(&mango_print_status); wl_signal_add(&mango_print_status, &print_status_listener); @@ -5482,7 +5482,7 @@ void setup(void) { wl_signal_add(&cursor->events.axis, &cursor_axis); wl_signal_add(&cursor->events.frame, &cursor_frame); - // 这两句代码会造成obs窗口里的鼠标光标消失,不知道注释有什么影响 + // These two lines will cause mouse cursor to disappear in obs window, unknown impact of commenting cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1); wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape); @@ -5555,14 +5555,14 @@ void setup(void) { wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, dwl_ipc_manager_bind); - // 创建顶层管理句柄 + // Create toplevel management handle foreign_toplevel_manager = wlr_foreign_toplevel_manager_v1_create(dpy); struct wlr_xdg_foreign_registry *foreign_registry = wlr_xdg_foreign_registry_create(dpy); wlr_xdg_foreign_v1_create(dpy, foreign_registry); wlr_xdg_foreign_v2_create(dpy, foreign_registry); - // ext-workspace协议 + // ext-workspace protocol workspaces_init(); #ifdef XWAYLAND /* @@ -5619,7 +5619,7 @@ void tag_client(const Arg *arg, Client *target_client) { void overview(Monitor *m) { grid(m); } -// 目标窗口有其他窗口和它同个tag就返回0 +// Return 0 if target window has other windows with same tag uint32_t want_restore_fullscreen(Client *target_client) { Client *c = NULL; wl_list_for_each(c, &clients, link) { @@ -5636,7 +5636,7 @@ uint32_t want_restore_fullscreen(Client *target_client) { return 1; } -// 普通视图切换到overview时保存窗口的旧状态 +// Save window old state when switching from normal view to overview void overview_backup(Client *c) { c->overview_isfloatingbak = c->isfloating; c->overview_isfullscreenbak = c->isfullscreen; @@ -5651,7 +5651,7 @@ void overview_backup(Client *c) { c->isfloating = 0; } if (c->isfullscreen || c->ismaximizescreen) { - c->isfullscreen = 0; // 清除窗口全屏标志 + c->isfullscreen = 0; // Clear window fullscreen flag c->ismaximizescreen = 0; } c->bw = c->isnoborder ? 0 : borderpx; @@ -5660,7 +5660,7 @@ void overview_backup(Client *c) { WLR_EDGE_RIGHT); } -// overview切回到普通视图还原窗口的状态 +// Restore window state when switching back from overview to normal view void overview_restore(Client *c, const Arg *arg) { c->isfloating = c->overview_isfloatingbak; c->isfullscreen = c->overview_isfullscreenbak; @@ -5674,7 +5674,7 @@ void overview_restore(Client *c, const Arg *arg) { c->is_restoring_from_ov = (arg->ui & c->tags & TAGMASK) == 0 ? true : false; if (c->isfloating) { - // XRaiseWindow(dpy, c->win); // 提升悬浮窗口到顶层 + // XRaiseWindow(dpy, c->win); // Raise floating window to top resize(c, c->overview_backup_geom, 0); } else if (c->isfullscreen || c->ismaximizescreen) { if (want_restore_fullscreen(c) && c->ismaximizescreen) { @@ -5694,7 +5694,7 @@ void overview_restore(Client *c, const Arg *arg) { } if (c->bw == 0 && - !c->isfullscreen) { // 如果是在ov模式中创建的窗口,没有bw记录 + !c->isfullscreen) { // If window was created in ov mode, no bw record c->bw = c->isnoborder ? 0 : borderpx; } @@ -6191,7 +6191,7 @@ void fix_xwayland_unmanaged_coordinate(Client *c) { if (!selmon) return; - // 1. 如果窗口已经在当前活动显示器内,直接返回 + // 1. If window is already in current active monitor, return directly if (c->geom.x >= selmon->m.x && c->geom.x < selmon->m.x + selmon->m.width && c->geom.y >= selmon->m.y && c->geom.y < selmon->m.y + selmon->m.height) return;