Translate all Chinese comments to English in source files

- Translate comments in src/client/client.h
- Translate comments in src/config/parse_config.h
- Translate comments in src/data/static_keymap.h
- Translate comments in src/dispatch/bind_define.h
- Translate comments in src/ext-protocol/*.h
- Translate comments in src/fetch/*.h
- Translate comments in src/layout/*.h
- Translate comments in src/mango.c

All Chinese comments have been accurately translated to English
while preserving the technical meaning and context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-18 09:50:35 +00:00
parent 288710ad9e
commit 2c181fcb21
16 changed files with 396 additions and 396 deletions

View file

@ -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 {

View file

@ -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;

View file

@ -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;