mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-03 06:46:38 -04:00
Merge branch 'merge-mangowc-STUDY' into merge-mango
This commit is contained in:
commit
5d2f052886
37 changed files with 4571 additions and 911 deletions
|
|
@ -834,7 +834,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);
|
||||
|
|
@ -862,7 +862,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);
|
||||
|
|
@ -870,28 +870,38 @@ 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;
|
||||
int32_t alloc_count = 0;
|
||||
|
||||
char *token = strtok((char *)arg->v, " ");
|
||||
while (token != NULL && argc < 63) {
|
||||
wordexp_t p;
|
||||
if (wordexp(token, &p, 0) == 0) {
|
||||
argv[argc++] = p.we_wordv[0];
|
||||
if (wordexp(token, &p, WRDE_NOCMD) == 0 && p.we_wordc > 0) {
|
||||
// Duplicate the string since we'll free the wordexp result
|
||||
argv[argc] = strdup(p.we_wordv[0]);
|
||||
wordfree(&p); // Free immediately after copying
|
||||
if (argv[argc] != NULL) {
|
||||
allocated_strings[alloc_count++] = argv[argc];
|
||||
argc++;
|
||||
}
|
||||
} else {
|
||||
argv[argc++] = token;
|
||||
argv[argc] = token;
|
||||
argc++;
|
||||
}
|
||||
token = strtok(NULL, " ");
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
// 3. 执行命令
|
||||
// 3. Execute command
|
||||
execvp(argv[0], argv);
|
||||
|
||||
// 4. execvp 失败时:打印错误并直接退出(避免 coredump)
|
||||
wlr_log(WLR_DEBUG, "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;
|
||||
}
|
||||
|
|
@ -928,7 +938,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);
|
||||
|
|
@ -944,14 +954,14 @@ int32_t switch_keyboard_layout(const Arg *arg) {
|
|||
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);
|
||||
|
||||
|
|
@ -964,7 +974,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);
|
||||
}
|
||||
|
|
@ -1138,8 +1148,7 @@ 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
|
||||
if (c->isfloating) {
|
||||
c->geom = c->float_geom;
|
||||
target = get_tags_first_tag(c->tags);
|
||||
|
|
@ -1674,8 +1683,9 @@ 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) &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue