From f26bfbb810db61ec82b823452c3eeebe6fe1f1f2 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Sun, 26 Apr 2026 13:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AA=97=E5=8F=A3uid?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E4=BF=AE=E5=A4=8D=E5=A4=9A=E7=AA=97=E5=8F=A3?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cleonos/c/apps/taskmgr_main.c | 46 +++++++- cleonos/c/apps/uwm/uwm.h | 5 + cleonos/c/apps/uwm/uwm_events.c | 80 +++++++++---- cleonos/c/apps/uwm/uwm_util.c | 51 +++++++++ cleonos/c/apps/uwm/uwm_window.c | 20 +++- cleonos/c/include/cleonos_syscall.h | 51 ++++++--- cleonos/c/src/syscall.c | 26 +++-- clks | 2 +- configs/menuconfig/.config.cleonos.json | 10 ++ configs/menuconfig/clks_features.json | 144 ++++++++++++++++++++---- configs/menuconfig/config.cleonos.cmake | 10 ++ docs/syscall.md | 49 +++++++- kit | 2 +- scripts/menuconfig.py | 8 ++ wine | 2 +- 15 files changed, 423 insertions(+), 83 deletions(-) diff --git a/cleonos/c/apps/taskmgr_main.c b/cleonos/c/apps/taskmgr_main.c index 51eaf6e..493dffd 100644 --- a/cleonos/c/apps/taskmgr_main.c +++ b/cleonos/c/apps/taskmgr_main.c @@ -66,6 +66,7 @@ typedef struct tm_app { u64 selected_pid; u64 total_mem; u64 proc_count_raw; + u64 window_count_raw; u64 last_refresh_tick; cleonos_proc_snapshot rows[TM_MAX_ROWS]; u64 row_count; @@ -440,7 +441,9 @@ static void tm_build_summary_status(tm_app *app) { tm_append_u64_dec(app->status, (u64)sizeof(app->status), app->proc_count_raw); tm_append(app->status, (u64)sizeof(app->status), " | ACTIVE MEM "); tm_append_u64_dec(app->status, (u64)sizeof(app->status), app->total_mem / 1024ULL); - tm_append(app->status, (u64)sizeof(app->status), " KB | R REFRESH A ALL DEL END TASK"); + tm_append(app->status, (u64)sizeof(app->status), " KB | WINDOWS "); + tm_append_u64_dec(app->status, (u64)sizeof(app->status), app->window_count_raw); + tm_append(app->status, (u64)sizeof(app->status), " | R REFRESH A ALL DEL END TASK"); } static void tm_clamp_selection(tm_app *app) { @@ -494,6 +497,7 @@ static void tm_reload(tm_app *app) { app->total_mem = 0ULL; proc_count = cleonos_sys_proc_count(); app->proc_count_raw = proc_count; + app->window_count_raw = cleonos_sys_wm_count(); for (i = 0ULL; i < proc_count && app->row_count < (u64)TM_MAX_ROWS; i++) { u64 pid = 0ULL; @@ -593,8 +597,37 @@ static void tm_draw_header(const tm_app *app) { tm_draw_text(app->w, app->h, 18, y + 9, "PID", 1, TM_COLOR_MUTED); tm_draw_text(app->w, app->h, 82, y + 9, "STATE", 1, TM_COLOR_MUTED); tm_draw_text(app->w, app->h, 172, y + 9, "MEM KB", 1, TM_COLOR_MUTED); - tm_draw_text(app->w, app->h, 260, y + 9, "TICKS", 1, TM_COLOR_MUTED); - tm_draw_text(app->w, app->h, 350, y + 9, "IMAGE", 1, TM_COLOR_MUTED); + tm_draw_text(app->w, app->h, 248, y + 9, "TICKS", 1, TM_COLOR_MUTED); + tm_draw_text(app->w, app->h, 330, y + 9, "WIN", 1, TM_COLOR_MUTED); + tm_draw_text(app->w, app->h, 382, y + 9, "IMAGE", 1, TM_COLOR_MUTED); +} + +static u64 tm_window_count_for_pid(u64 pid) { + u64 count = cleonos_sys_wm_count(); + u64 i; + u64 owned = 0ULL; + + if (pid == 0ULL) { + return 0ULL; + } + + for (i = 0ULL; i < count; i++) { + u64 window_id = 0ULL; + cleonos_wm_snapshot snap; + + tm_zero(&snap, (u64)sizeof(snap)); + if (cleonos_sys_wm_id_at(i, &window_id) == 0ULL || window_id == 0ULL) { + continue; + } + if (cleonos_sys_wm_snapshot(window_id, &snap, (u64)sizeof(snap)) == 0ULL) { + continue; + } + if (snap.owner_pid == pid) { + owned++; + } + } + + return owned; } static void tm_draw_row(const tm_app *app, int row_y, int row_index) { @@ -635,9 +668,12 @@ static void tm_draw_row(const tm_app *app, int row_y, int row_index) { tm_draw_text_limit(app->w, app->h, 172, row_y + 8, value, 1, TM_COLOR_TEXT, 250); tm_u64_to_dec(value, (u64)sizeof(value), snap->runtime_ticks); - tm_draw_text_limit(app->w, app->h, 260, row_y + 8, value, 1, TM_COLOR_TEXT, 342); + tm_draw_text_limit(app->w, app->h, 248, row_y + 8, value, 1, TM_COLOR_TEXT, 324); - tm_draw_text_limit(app->w, app->h, 350, row_y + 8, snap->path, 1, TM_COLOR_TEXT, app->w - 16); + tm_u64_to_dec(value, (u64)sizeof(value), tm_window_count_for_pid(snap->pid)); + tm_draw_text_limit(app->w, app->h, 330, row_y + 8, value, 1, TM_COLOR_TEXT, 374); + + tm_draw_text_limit(app->w, app->h, 382, row_y + 8, snap->path, 1, TM_COLOR_TEXT, app->w - 16); } static void tm_draw_rows(const tm_app *app) { diff --git a/cleonos/c/apps/uwm/uwm.h b/cleonos/c/apps/uwm/uwm.h index f6b4b44..ac4c6ba 100644 --- a/cleonos/c/apps/uwm/uwm.h +++ b/cleonos/c/apps/uwm/uwm.h @@ -89,9 +89,12 @@ typedef struct ush_uwm_session { int resize_pending_h; int start_open; u64 mouse_packet_seen; + u64 app_registry_last_tick; u64 tty_before; int tty_switched; char last_error[96]; + u64 app_pids[USH_UWM_APP_COUNT]; + u64 app_states[USH_UWM_APP_COUNT]; ush_uwm_window windows[USH_UWM_WINDOW_COUNT]; } ush_uwm_session; @@ -100,6 +103,8 @@ int ush_uwm_app_index_valid(int index); int ush_uwm_clampi(int value, int min_value, int max_value); int ush_uwm_u64_as_i32(u64 raw); void ush_uwm_drain_startup_keys(void); +int ush_uwm_app_registry_running(ush_uwm_session *sess, int index); +int ush_uwm_refresh_app_registry(ush_uwm_session *sess); int ush_uwm_alloc_pixels(ush_uwm_window *win); int ush_uwm_replace_pixels(ush_uwm_window *win, int width, int height); diff --git a/cleonos/c/apps/uwm/uwm_events.c b/cleonos/c/apps/uwm/uwm_events.c index d30294b..68f5e31 100644 --- a/cleonos/c/apps/uwm/uwm_events.c +++ b/cleonos/c/apps/uwm/uwm_events.c @@ -4,45 +4,76 @@ #define USH_UWM_TASKMGR_PATH "/shell/uwm/taskmgr.elf" #define USH_UWM_TERMINAL_PATH "/shell/uwm/terminal.elf" -static int ush_uwm_launch_file_explorer(void) { - u64 pid = cleonos_sys_spawn_pathv(USH_UWM_FILE_EXPLORER_PATH, "", "LAUNCHED_BY=uwm"); +static const char *ush_uwm_app_path(int index) { + if (index == 0) { + return USH_UWM_FILE_EXPLORER_PATH; + } + if (index == USH_UWM_TERMINAL_INDEX) { + return USH_UWM_TERMINAL_PATH; + } + if (index == USH_UWM_TASKMGR_INDEX) { + return USH_UWM_TASKMGR_PATH; + } - return (pid != 0ULL && pid != (u64)-1) ? 1 : 0; + return (const char *)0; } -static int ush_uwm_launch_terminal(void) { - u64 pid = cleonos_sys_spawn_pathv(USH_UWM_TERMINAL_PATH, "", "LAUNCHED_BY=uwm"); +static int ush_uwm_focus_first_window_for_pid(u64 pid) { + u64 count; + u64 i; - return (pid != 0ULL && pid != (u64)-1) ? 1 : 0; -} + if (pid == 0ULL || pid == (u64)-1) { + return 0; + } -static int ush_uwm_launch_taskmgr(void) { - u64 pid = cleonos_sys_spawn_pathv(USH_UWM_TASKMGR_PATH, "", "LAUNCHED_BY=uwm"); + count = cleonos_sys_wm_count(); + while (count > 0ULL) { + u64 window_id = 0ULL; + cleonos_wm_snapshot snap; - return (pid != 0ULL && pid != (u64)-1) ? 1 : 0; + count--; + i = count; + ush_zero(&snap, (u64)sizeof(snap)); + if (cleonos_sys_wm_id_at(i, &window_id) == 0ULL || window_id == 0ULL) { + continue; + } + if (cleonos_sys_wm_snapshot(window_id, &snap, (u64)sizeof(snap)) == 0ULL) { + continue; + } + if (snap.owner_pid == pid) { + return (cleonos_sys_wm_set_focus(window_id) != 0ULL) ? 1 : 0; + } + } + + return 0; } static void ush_uwm_launch_or_restore_app(ush_uwm_session *sess, int index) { + const char *path; + u64 pid; + if (sess == (ush_uwm_session *)0 || ush_uwm_app_index_valid(index) == 0) { return; } - if (index == 0) { - (void)ush_uwm_launch_file_explorer(); + if (ush_uwm_app_registry_running(sess, index) != 0) { + (void)ush_uwm_focus_first_window_for_pid(sess->app_pids[index]); + ush_uwm_refresh_taskbar(sess); return; } - if (index == USH_UWM_TERMINAL_INDEX) { - (void)ush_uwm_launch_terminal(); + path = ush_uwm_app_path(index); + if (path == (const char *)0) { + ush_uwm_restore_window(sess, index); return; } - if (index == USH_UWM_TASKMGR_INDEX) { - (void)ush_uwm_launch_taskmgr(); - return; + pid = cleonos_sys_spawn_pathv(path, "", "LAUNCHED_BY=uwm"); + if (pid != 0ULL && pid != (u64)-1) { + sess->app_pids[index] = pid; + sess->app_states[index] = CLEONOS_PROC_STATE_PENDING; } - - ush_uwm_restore_window(sess, index); + ush_uwm_refresh_taskbar(sess); } static int ush_uwm_hit_close(const ush_uwm_window *win, int x, int y) { @@ -567,6 +598,17 @@ int ush_uwm_loop(ush_uwm_session *sess) { int i; int handled_events = 0; int preferred_window = -1; + u64 now_tick = cleonos_sys_timer_ticks(); + + if (now_tick - sess->app_registry_last_tick >= 20ULL) { + sess->app_registry_last_tick = now_tick; + if (ush_uwm_refresh_app_registry(sess) != 0) { + ush_uwm_refresh_taskbar(sess); + if (sess->start_open != 0) { + ush_uwm_refresh_window(sess, USH_UWM_START_INDEX); + } + } + } if (sess->dragging != 0 && ush_uwm_window_index_valid(sess->drag_window) != 0) { preferred_window = sess->drag_window; diff --git a/cleonos/c/apps/uwm/uwm_util.c b/cleonos/c/apps/uwm/uwm_util.c index fc4fd15..d7cda61 100644 --- a/cleonos/c/apps/uwm/uwm_util.c +++ b/cleonos/c/apps/uwm/uwm_util.c @@ -48,3 +48,54 @@ void ush_uwm_drain_startup_keys(void) { drained++; } } + +int ush_uwm_app_registry_running(ush_uwm_session *sess, int index) { + cleonos_proc_snapshot snap; + u64 pid; + + if (sess == (ush_uwm_session *)0 || ush_uwm_app_index_valid(index) == 0) { + return 0; + } + + pid = sess->app_pids[index]; + if (pid == 0ULL || pid == (u64)-1) { + sess->app_pids[index] = 0ULL; + sess->app_states[index] = CLEONOS_PROC_STATE_UNUSED; + return 0; + } + + ush_zero(&snap, (u64)sizeof(snap)); + if (cleonos_sys_proc_snapshot(pid, &snap, (u64)sizeof(snap)) == 0ULL) { + sess->app_pids[index] = 0ULL; + sess->app_states[index] = CLEONOS_PROC_STATE_UNUSED; + return 0; + } + + sess->app_states[index] = snap.state; + if (snap.state == CLEONOS_PROC_STATE_EXITED || snap.state == CLEONOS_PROC_STATE_UNUSED) { + sess->app_pids[index] = 0ULL; + return 0; + } + + return 1; +} + +int ush_uwm_refresh_app_registry(ush_uwm_session *sess) { + int i; + int changed = 0; + + if (sess == (ush_uwm_session *)0) { + return 0; + } + + for (i = 0; i < (int)USH_UWM_APP_COUNT; i++) { + u64 old_pid = sess->app_pids[i]; + u64 old_state = sess->app_states[i]; + (void)ush_uwm_app_registry_running(sess, i); + if (old_pid != sess->app_pids[i] || old_state != sess->app_states[i]) { + changed = 1; + } + } + + return changed; +} diff --git a/cleonos/c/apps/uwm/uwm_window.c b/cleonos/c/apps/uwm/uwm_window.c index fd61758..fc175ac 100644 --- a/cleonos/c/apps/uwm/uwm_window.c +++ b/cleonos/c/apps/uwm/uwm_window.c @@ -527,14 +527,21 @@ static void ush_uwm_render_taskbar(ush_uwm_session *sess) { ush_uwm_u32 bg = 0x00282828U; ush_uwm_u32 fg = 0x00EAEAEAU; int active = 0; + int running = (sess->app_pids[i] != 0ULL && sess->app_states[i] != CLEONOS_PROC_STATE_EXITED && + sess->app_states[i] != CLEONOS_PROC_STATE_UNUSED) + ? 1 + : 0; if (app_x + USH_UWM_TASKBAR_BUTTON_W > taskbar->w - 98) { break; } - if (app->closed != 0) { + if (running == 0 && app->closed != 0) { bg = 0x001F1F1FU; fg = 0x008F8F8FU; + } else if (running != 0) { + bg = 0x00383838U; + active = 1; } else if (app->minimized != 0) { bg = 0x002F2F2FU; } else if (sess->active_window == i) { @@ -570,15 +577,20 @@ static void ush_uwm_render_start(ush_uwm_session *sess) { for (i = 0; i < (int)USH_UWM_APP_COUNT; i++) { int y = 78 + (i * 44); - ush_uwm_u32 bg = (sess->active_window == i && sess->windows[i].closed == 0 && sess->windows[i].minimized == 0) - ? 0x003B3B3BU - : 0x00272727U; + int running = (sess->app_pids[i] != 0ULL && sess->app_states[i] != CLEONOS_PROC_STATE_EXITED && + sess->app_states[i] != CLEONOS_PROC_STATE_UNUSED) + ? 1 + : 0; + ush_uwm_u32 bg = (running != 0) ? 0x003B3B3BU : 0x00272727U; if (y + 34 > start->h - 76) { break; } ush_uwm_fill_rect(start, 66, y, start->w - 82, 34, bg); ush_uwm_fill_rect(start, 66, y, 4, 34, sess->windows[i].accent); ush_uwm_draw_text_limit(start, 82, y + 10, labels[i], 1, UWM_COLOR_WHITE, start->w - 12); + if (running != 0) { + ush_uwm_draw_text_limit(start, start->w - 64, y + 10, "RUN", 1, 0x00A6F0A6U, start->w - 12); + } } if (start->w > 248 && start->h > 260) { diff --git a/cleonos/c/include/cleonos_syscall.h b/cleonos/c/include/cleonos_syscall.h index c465bda..ded3de7 100644 --- a/cleonos/c/include/cleonos_syscall.h +++ b/cleonos/c/include/cleonos_syscall.h @@ -66,15 +66,28 @@ typedef struct cleonos_mouse_state { #define CLEONOS_WM_FLAG_TOPMOST 0x1ULL -typedef struct cleonos_wm_event { - u64 type; - u64 arg0; - u64 arg1; - u64 arg2; - u64 arg3; -} cleonos_wm_event; - -typedef struct cleonos_wm_create_req { +typedef struct cleonos_wm_event { + u64 type; + u64 arg0; + u64 arg1; + u64 arg2; + u64 arg3; +} cleonos_wm_event; + +typedef struct cleonos_wm_snapshot { + u64 window_id; + u64 owner_pid; + u64 flags; + u64 x; + u64 y; + u64 width; + u64 height; + u64 focused; + u64 presented; + u64 event_count; +} cleonos_wm_snapshot; + +typedef struct cleonos_wm_create_req { u64 x; u64 y; u64 width; @@ -261,9 +274,12 @@ typedef struct cleonos_net_tcp_recv_req { #define CLEONOS_SYSCALL_WM_POLL_EVENT 111ULL #define CLEONOS_SYSCALL_WM_MOVE 112ULL #define CLEONOS_SYSCALL_WM_SET_FOCUS 113ULL -#define CLEONOS_SYSCALL_WM_SET_FLAGS 114ULL -#define CLEONOS_SYSCALL_WM_RESIZE 115ULL -#define CLEONOS_SYSCALL_PTY_OPEN 116ULL +#define CLEONOS_SYSCALL_WM_SET_FLAGS 114ULL +#define CLEONOS_SYSCALL_WM_RESIZE 115ULL +#define CLEONOS_SYSCALL_PTY_OPEN 116ULL +#define CLEONOS_SYSCALL_WM_COUNT 117ULL +#define CLEONOS_SYSCALL_WM_ID_AT 118ULL +#define CLEONOS_SYSCALL_WM_SNAPSHOT 119ULL u64 cleonos_syscall(u64 id, u64 arg0, u64 arg1, u64 arg2); u64 cleonos_sys_log_write(const char *message, u64 length); @@ -379,9 +395,12 @@ u64 cleonos_sys_wm_destroy(u64 window_id); u64 cleonos_sys_wm_present(const cleonos_wm_present_req *req); u64 cleonos_sys_wm_poll_event(u64 window_id, cleonos_wm_event *out_event); u64 cleonos_sys_wm_move(const cleonos_wm_move_req *req); -u64 cleonos_sys_wm_set_focus(u64 window_id); -u64 cleonos_sys_wm_set_flags(u64 window_id, u64 flags); -u64 cleonos_sys_wm_resize(const cleonos_wm_resize_req *req); -u64 cleonos_sys_pty_open(void); +u64 cleonos_sys_wm_set_focus(u64 window_id); +u64 cleonos_sys_wm_set_flags(u64 window_id, u64 flags); +u64 cleonos_sys_wm_resize(const cleonos_wm_resize_req *req); +u64 cleonos_sys_wm_count(void); +u64 cleonos_sys_wm_id_at(u64 index, u64 *out_window_id); +u64 cleonos_sys_wm_snapshot(u64 window_id, cleonos_wm_snapshot *out_snapshot, u64 out_size); +u64 cleonos_sys_pty_open(void); #endif diff --git a/cleonos/c/src/syscall.c b/cleonos/c/src/syscall.c index be40f93..4318009 100644 --- a/cleonos/c/src/syscall.c +++ b/cleonos/c/src/syscall.c @@ -492,10 +492,22 @@ u64 cleonos_sys_wm_set_flags(u64 window_id, u64 flags) { return cleonos_syscall(CLEONOS_SYSCALL_WM_SET_FLAGS, window_id, flags, 0ULL); } -u64 cleonos_sys_wm_resize(const cleonos_wm_resize_req *req) { - return cleonos_syscall(CLEONOS_SYSCALL_WM_RESIZE, (u64)req, 0ULL, 0ULL); -} - -u64 cleonos_sys_pty_open(void) { - return cleonos_syscall(CLEONOS_SYSCALL_PTY_OPEN, 0ULL, 0ULL, 0ULL); -} +u64 cleonos_sys_wm_resize(const cleonos_wm_resize_req *req) { + return cleonos_syscall(CLEONOS_SYSCALL_WM_RESIZE, (u64)req, 0ULL, 0ULL); +} + +u64 cleonos_sys_wm_count(void) { + return cleonos_syscall(CLEONOS_SYSCALL_WM_COUNT, 0ULL, 0ULL, 0ULL); +} + +u64 cleonos_sys_wm_id_at(u64 index, u64 *out_window_id) { + return cleonos_syscall(CLEONOS_SYSCALL_WM_ID_AT, index, (u64)out_window_id, 0ULL); +} + +u64 cleonos_sys_wm_snapshot(u64 window_id, cleonos_wm_snapshot *out_snapshot, u64 out_size) { + return cleonos_syscall(CLEONOS_SYSCALL_WM_SNAPSHOT, window_id, (u64)out_snapshot, out_size); +} + +u64 cleonos_sys_pty_open(void) { + return cleonos_syscall(CLEONOS_SYSCALL_PTY_OPEN, 0ULL, 0ULL, 0ULL); +} diff --git a/clks b/clks index 1632db2..e382e0f 160000 --- a/clks +++ b/clks @@ -1 +1 @@ -Subproject commit 1632db237257d55a85ad0b4347ead7f8f12f7ef2 +Subproject commit e382e0fb8ae05720e8a9f29e1595d37c2ea895f3 diff --git a/configs/menuconfig/.config.cleonos.json b/configs/menuconfig/.config.cleonos.json index 90f5586..c30c745 100644 --- a/configs/menuconfig/.config.cleonos.json +++ b/configs/menuconfig/.config.cleonos.json @@ -5,6 +5,7 @@ "CLEONOS_USER_APP_ARGS": true, "CLEONOS_USER_APP_BG": true, "CLEONOS_USER_APP_BMPVIEW": true, + "CLEONOS_USER_APP_BROWSER": true, "CLEONOS_USER_APP_CAT": true, "CLEONOS_USER_APP_CD": true, "CLEONOS_USER_APP_CLEAR": true, @@ -20,11 +21,14 @@ "CLEONOS_USER_APP_FASTFETCH": true, "CLEONOS_USER_APP_FDTEST": true, "CLEONOS_USER_APP_FG": true, + "CLEONOS_USER_APP_FILE_EXPLORER": true, "CLEONOS_USER_APP_FSSTAT": true, "CLEONOS_USER_APP_GREP": true, "CLEONOS_USER_APP_HEAD": true, "CLEONOS_USER_APP_HELLO": true, "CLEONOS_USER_APP_HELP": true, + "CLEONOS_USER_APP_HTTPGET": true, + "CLEONOS_USER_APP_IFCONFIG": true, "CLEONOS_USER_APP_JOBS": true, "CLEONOS_USER_APP_KBDSTAT": true, "CLEONOS_USER_APP_KDBG": true, @@ -38,8 +42,10 @@ "CLEONOS_USER_APP_MKFSFAT32": true, "CLEONOS_USER_APP_MOUNT": true, "CLEONOS_USER_APP_MV": true, + "CLEONOS_USER_APP_NSLOOKUP": true, "CLEONOS_USER_APP_PARTCTL": true, "CLEONOS_USER_APP_PID": true, + "CLEONOS_USER_APP_PING": true, "CLEONOS_USER_APP_PROCSTAT": true, "CLEONOS_USER_APP_PS": true, "CLEONOS_USER_APP_PWD": true, @@ -56,13 +62,17 @@ "CLEONOS_USER_APP_STATS": true, "CLEONOS_USER_APP_SYSSTAT": true, "CLEONOS_USER_APP_TAIL": true, + "CLEONOS_USER_APP_TASKMGR": true, "CLEONOS_USER_APP_TASKSTAT": true, + "CLEONOS_USER_APP_TERMINAL": true, "CLEONOS_USER_APP_TOP": true, "CLEONOS_USER_APP_TOUCH": true, "CLEONOS_USER_APP_TTY": true, "CLEONOS_USER_APP_TTYDRV": true, "CLEONOS_USER_APP_UNIQ": true, "CLEONOS_USER_APP_USERSTAT": true, + "CLEONOS_USER_APP_UWM": true, + "CLEONOS_USER_APP_VIM": true, "CLEONOS_USER_APP_WAIT": true, "CLEONOS_USER_APP_WAVPLAY": true, "CLEONOS_USER_APP_WC": true, diff --git a/configs/menuconfig/clks_features.json b/configs/menuconfig/clks_features.json index 7ddb5fe..4a1ddb2 100644 --- a/configs/menuconfig/clks_features.json +++ b/configs/menuconfig/clks_features.json @@ -18,19 +18,91 @@ "type": "bool", "default": true }, - { - "key": "CLEONOS_CLKS_ENABLE_DESKTOP", - "title": "TTY2 Desktop", - "title_zh": "TTY2 桌面", - "description": "Enable desktop compositor tick/update path on TTY2.", - "description_zh": "在 TTY2 启用桌面合成器 tick/更新路径。", - "type": "bool", - "default": true, - "depends_on": "CLEONOS_CLKS_ENABLE_MOUSE" - }, - { - "key": "CLEONOS_CLKS_ENABLE_DRIVER_MANAGER", - "title": "Driver Manager", + { + "key": "CLEONOS_CLKS_ENABLE_DESKTOP", + "title": "TTY2 Desktop", + "title_zh": "TTY2 桌面", + "description": "Enable desktop compositor tick/update path on TTY2.", + "description_zh": "在 TTY2 启用桌面合成器 tick/更新路径。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_MOUSE" + }, + { + "key": "CLEONOS_CLKS_ENABLE_WM_MULTI_RECT_DAMAGE", + "title": "WM Multi-Rect Damage", + "title_zh": "WM 多脏矩形", + "description": "Track several dirty rectangles instead of collapsing every frame into one large region.", + "description_zh": "跟踪多个脏矩形,避免每帧都合并成一个大区域。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_DESKTOP", + "group": "Window Manager", + "group_zh": "窗口管理器" + }, + { + "key": "CLEONOS_CLKS_ENABLE_WM_LAYER_CACHE", + "title": "WM Scene Layer Cache", + "title_zh": "WM 场景层缓存", + "description": "Keep a cached scene layer so unchanged background/window pixels do not need full redraw.", + "description_zh": "保留场景层缓存,避免未变化的背景/窗口像素重复重绘。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_DESKTOP", + "group": "Window Manager", + "group_zh": "窗口管理器" + }, + { + "key": "CLEONOS_CLKS_ENABLE_WM_FRAME_PACING", + "title": "WM Frame Pacing", + "title_zh": "WM 帧率限制", + "description": "Limit compositor flush rate using timer/TSC pacing to reduce tearing and jitter.", + "description_zh": "使用 timer/TSC 控制合成器刷新率,减少撕裂和抖动。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_DESKTOP", + "group": "Window Manager", + "group_zh": "窗口管理器" + }, + { + "key": "CLEONOS_CLKS_ENABLE_WM_STATS_OVERLAY", + "title": "WM FPS/MS Overlay", + "title_zh": "WM FPS/MS 叠加层", + "description": "Draw the compositor FPS/MS box in the bottom-right corner.", + "description_zh": "在右下角绘制合成器 FPS/MS 统计框。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_DESKTOP", + "group": "Window Manager", + "group_zh": "窗口管理器" + }, + { + "key": "CLEONOS_CLKS_ENABLE_WM_INPUT_DISPATCH", + "title": "WM Input Dispatch", + "title_zh": "WM 输入事件分发", + "description": "Dispatch mouse and keyboard events to focused kernel windows.", + "description_zh": "将鼠标和键盘事件分发给获得焦点的内核窗口。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_DESKTOP && CLEONOS_CLKS_ENABLE_MOUSE && CLEONOS_CLKS_ENABLE_KEYBOARD", + "group": "Window Manager", + "group_zh": "窗口管理器" + }, + { + "key": "CLEONOS_CLKS_ENABLE_WM_REAP_DEAD_OWNERS", + "title": "WM Dead Owner Cleanup", + "title_zh": "WM 死进程窗口回收", + "description": "Automatically destroy windows owned by exited processes.", + "description_zh": "自动销毁已退出进程拥有的窗口。", + "type": "bool", + "default": true, + "depends_on": "CLEONOS_CLKS_ENABLE_DESKTOP", + "group": "Window Manager", + "group_zh": "窗口管理器" + }, + { + "key": "CLEONOS_CLKS_ENABLE_DRIVER_MANAGER", + "title": "Driver Manager", "title_zh": "驱动管理器", "description": "Initialize kernel ELF driver manager.", "description_zh": "初始化内核 ELF 驱动管理器。", @@ -229,18 +301,40 @@ "type": "bool", "default": true }, - { - "key": "CLEONOS_CLKS_ENABLE_EXEC_SERIAL_LOG", - "title": "EXEC Serial Logs", - "title_zh": "EXEC 串口日志", - "description": "Print EXEC run/return/path logs to serial output.", - "description_zh": "将 EXEC run/return/path 日志输出到串口。", - "type": "tristate", - "default": "y" - }, - { - "key": "CLEONOS_CLKS_ENABLE_SYSCALL_SERIAL_LOG", - "title": "SYSCALL Serial Logs", + { + "key": "CLEONOS_CLKS_ENABLE_EXEC_SERIAL_LOG", + "title": "EXEC Serial Logs", + "title_zh": "EXEC 串口日志", + "description": "Print EXEC run/return/path logs to serial output.", + "description_zh": "将 EXEC run/return/path 日志输出到串口。", + "type": "tristate", + "default": "y" + }, + { + "key": "CLEONOS_CLKS_ENABLE_EXEC_CONTEXT_SWITCH_LOG", + "title": "EXEC Context Switch Logs", + "title_zh": "EXEC 上下文切换日志", + "description": "Print cooperative EXEC suspend/resume logs such as EXEC RUN RESUME and RUN SUSPENDED.", + "description_zh": "输出协作式 EXEC 挂起/恢复日志,例如 EXEC RUN RESUME 和 RUN SUSPENDED。", + "type": "bool", + "default": false, + "group": "Logging Controls", + "group_zh": "日志控制" + }, + { + "key": "CLEONOS_CLKS_ENABLE_NET_DHCP_CLIENT", + "title": "Network DHCP Client", + "title_zh": "网络 DHCP 客户端", + "description": "Use DHCP to auto-configure IPv4/netmask/gateway/DNS; disable to use fallback QEMU-style static config.", + "description_zh": "使用 DHCP 自动配置 IPv4/掩码/网关/DNS;关闭后使用 QEMU 风格 fallback 静态配置。", + "type": "bool", + "default": true, + "group": "Networking", + "group_zh": "网络" + }, + { + "key": "CLEONOS_CLKS_ENABLE_SYSCALL_SERIAL_LOG", + "title": "SYSCALL Serial Logs", "title_zh": "SYSCALL 串口日志", "description": "Print user syscall CALL/RET trace logs to serial output.", "description_zh": "将用户态 syscall 的 CALL/RET 跟踪日志输出到串口。", diff --git a/configs/menuconfig/config.cleonos.cmake b/configs/menuconfig/config.cleonos.cmake index 12f6408..cc7e51e 100644 --- a/configs/menuconfig/config.cleonos.cmake +++ b/configs/menuconfig/config.cleonos.cmake @@ -9,6 +9,7 @@ set(CLEONOS_USER_APP_APPEND ON CACHE BOOL "append.elf [shell]" FORCE) set(CLEONOS_USER_APP_ARGS ON CACHE BOOL "args.elf [shell]" FORCE) set(CLEONOS_USER_APP_BG ON CACHE BOOL "bg.elf [shell]" FORCE) set(CLEONOS_USER_APP_BMPVIEW ON CACHE BOOL "bmpview.elf [shell]" FORCE) +set(CLEONOS_USER_APP_BROWSER ON CACHE BOOL "browser.elf [shell]" FORCE) set(CLEONOS_USER_APP_CAT ON CACHE BOOL "cat.elf [shell]" FORCE) set(CLEONOS_USER_APP_CD ON CACHE BOOL "cd.elf [shell]" FORCE) set(CLEONOS_USER_APP_CLEAR ON CACHE BOOL "clear.elf [shell]" FORCE) @@ -23,10 +24,13 @@ set(CLEONOS_USER_APP_EXIT ON CACHE BOOL "exit.elf [shell]" FORCE) set(CLEONOS_USER_APP_FASTFETCH ON CACHE BOOL "fastfetch.elf [shell]" FORCE) set(CLEONOS_USER_APP_FDTEST ON CACHE BOOL "fdtest.elf [shell]" FORCE) set(CLEONOS_USER_APP_FG ON CACHE BOOL "fg.elf [shell]" FORCE) +set(CLEONOS_USER_APP_FILE_EXPLORER ON CACHE BOOL "file_explorer.elf [shell]" FORCE) set(CLEONOS_USER_APP_FSSTAT ON CACHE BOOL "fsstat.elf [shell]" FORCE) set(CLEONOS_USER_APP_GREP ON CACHE BOOL "grep.elf [shell]" FORCE) set(CLEONOS_USER_APP_HEAD ON CACHE BOOL "head.elf [shell]" FORCE) set(CLEONOS_USER_APP_HELP ON CACHE BOOL "help.elf [shell]" FORCE) +set(CLEONOS_USER_APP_HTTPGET ON CACHE BOOL "httpget.elf [shell]" FORCE) +set(CLEONOS_USER_APP_IFCONFIG ON CACHE BOOL "ifconfig.elf [shell]" FORCE) set(CLEONOS_USER_APP_JOBS ON CACHE BOOL "jobs.elf [shell]" FORCE) set(CLEONOS_USER_APP_KBDSTAT ON CACHE BOOL "kbdstat.elf [shell]" FORCE) set(CLEONOS_USER_APP_KDBG ON CACHE BOOL "kdbg.elf [shell]" FORCE) @@ -39,8 +43,10 @@ set(CLEONOS_USER_APP_MKDIR ON CACHE BOOL "mkdir.elf [shell]" FORCE) set(CLEONOS_USER_APP_MKFSFAT32 ON CACHE BOOL "mkfsfat32.elf [shell]" FORCE) set(CLEONOS_USER_APP_MOUNT ON CACHE BOOL "mount.elf [shell]" FORCE) set(CLEONOS_USER_APP_MV ON CACHE BOOL "mv.elf [shell]" FORCE) +set(CLEONOS_USER_APP_NSLOOKUP ON CACHE BOOL "nslookup.elf [shell]" FORCE) set(CLEONOS_USER_APP_PARTCTL ON CACHE BOOL "partctl.elf [shell]" FORCE) set(CLEONOS_USER_APP_PID ON CACHE BOOL "pid.elf [shell]" FORCE) +set(CLEONOS_USER_APP_PING ON CACHE BOOL "ping.elf [shell]" FORCE) set(CLEONOS_USER_APP_PROCSTAT ON CACHE BOOL "procstat.elf [shell]" FORCE) set(CLEONOS_USER_APP_PS ON CACHE BOOL "ps.elf [shell]" FORCE) set(CLEONOS_USER_APP_PWD ON CACHE BOOL "pwd.elf [shell]" FORCE) @@ -57,12 +63,16 @@ set(CLEONOS_USER_APP_SPIN ON CACHE BOOL "spin.elf [shell]" FORCE) set(CLEONOS_USER_APP_STATS ON CACHE BOOL "stats.elf [shell]" FORCE) set(CLEONOS_USER_APP_SYSSTAT ON CACHE BOOL "sysstat.elf [shell]" FORCE) set(CLEONOS_USER_APP_TAIL ON CACHE BOOL "tail.elf [shell]" FORCE) +set(CLEONOS_USER_APP_TASKMGR ON CACHE BOOL "taskmgr.elf [shell]" FORCE) set(CLEONOS_USER_APP_TASKSTAT ON CACHE BOOL "taskstat.elf [shell]" FORCE) +set(CLEONOS_USER_APP_TERMINAL ON CACHE BOOL "terminal.elf [shell]" FORCE) set(CLEONOS_USER_APP_TOP ON CACHE BOOL "top.elf [shell]" FORCE) set(CLEONOS_USER_APP_TOUCH ON CACHE BOOL "touch.elf [shell]" FORCE) set(CLEONOS_USER_APP_TTY ON CACHE BOOL "tty.elf [shell]" FORCE) set(CLEONOS_USER_APP_UNIQ ON CACHE BOOL "uniq.elf [shell]" FORCE) set(CLEONOS_USER_APP_USERSTAT ON CACHE BOOL "userstat.elf [shell]" FORCE) +set(CLEONOS_USER_APP_UWM ON CACHE BOOL "uwm.elf [shell]" FORCE) +set(CLEONOS_USER_APP_VIM ON CACHE BOOL "vim.elf [shell]" FORCE) set(CLEONOS_USER_APP_WAIT ON CACHE BOOL "wait.elf [shell]" FORCE) set(CLEONOS_USER_APP_WAVPLAY ON CACHE BOOL "wavplay.elf [shell]" FORCE) set(CLEONOS_USER_APP_WC ON CACHE BOOL "wc.elf [shell]" FORCE) diff --git a/docs/syscall.md b/docs/syscall.md index d8f9f90..0920dfa 100644 --- a/docs/syscall.md +++ b/docs/syscall.md @@ -875,7 +875,7 @@ UserSafeController(USC)危险 syscall 确认: - 参数: - `arg0`: `u64 window_id` - 返回:成功 `1`,失败 `0` -- 说明:将目标窗口置为焦点并提升到顶层 z-order。 +- 说明:将目标窗口置为焦点并提升到顶层 z-order。该操作允许 UWM/任务栏聚焦其他进程创建的窗口;窗口内容提交、移动、销毁仍由窗口拥有者限制。 ### 114 `CLEONOS_SYSCALL_WM_SET_FLAGS` @@ -901,8 +901,48 @@ UserSafeController(USC)危险 syscall 确认: - 说明: - 创建桌面伪 tty 输出端。用户态可把该 FD 传给 `EXEC_PATHV_IO` 的 stdout/stderr,然后通过 `FD_READ` 从同一 FD 读取子进程输出。 - 当前 PTY 是“命令输出捕获型”最小实现,不提供完整主从终端会话语义;阻塞式交互 shell 仍应继续使用普通 TTY。 - -## 5. 用户态封装函数 + +### 117 `CLEONOS_SYSCALL_WM_COUNT` + +- 参数:无 +- 返回:当前内核 WM 窗口数量。 +- 说明:窗口列表按当前 z-order 枚举,主要给 UWM、Task Manager 这类桌面组件做窗口/进程关联。 + +### 118 `CLEONOS_SYSCALL_WM_ID_AT` + +- 参数: +- `arg0`: `u64 index` +- `arg1`: `u64 *out_window_id` +- 返回:成功返回 `1`,失败返回 `0`。 +- 说明:按 z-order 索引读取窗口 ID;`index` 范围为 `[0, WM_COUNT)`。 + +### 119 `CLEONOS_SYSCALL_WM_SNAPSHOT` + +- 参数: +- `arg0`: `u64 window_id` +- `arg1`: `struct cleonos_wm_snapshot *out_snapshot` +- `arg2`: `u64 out_size` +- 返回:成功返回 `1`,失败返回 `0`。 +- 快照结构: + +```c +typedef struct cleonos_wm_snapshot { + u64 window_id; + u64 owner_pid; + u64 flags; + u64 x; + u64 y; + u64 width; + u64 height; + u64 focused; + u64 presented; + u64 event_count; +} cleonos_wm_snapshot; +``` + +- 说明:`owner_pid` 是创建窗口的用户进程 PID;内核仍会限制窗口修改/销毁等操作只能由窗口拥有者执行。 + +## 5. 用户态封装函数 用户态封装位于: @@ -916,8 +956,9 @@ UserSafeController(USC)危险 syscall 确认: - `cleonos_sys_exec_path()` - `cleonos_sys_exec_pathv()` - `cleonos_sys_tty_write()` -- `cleonos_sys_kbd_get_char()` / `cleonos_sys_kbd_buffered()` +- `cleonos_sys_kbd_get_char()` / `cleonos_sys_kbd_buffered()` - `cleonos_sys_getpid()` / `cleonos_sys_spawn_path()` / `cleonos_sys_wait_pid()` +- `cleonos_sys_wm_count()` / `cleonos_sys_wm_id_at()` / `cleonos_sys_wm_snapshot()` - `cleonos_sys_spawn_pathv()` - `cleonos_sys_exit()` / `cleonos_sys_sleep_ticks()` / `cleonos_sys_yield()` / `cleonos_sys_shutdown()` / `cleonos_sys_restart()` - `cleonos_sys_audio_available()` / `cleonos_sys_audio_play_tone()` / `cleonos_sys_audio_stop()` diff --git a/kit b/kit index 3f29819..ebd6793 160000 --- a/kit +++ b/kit @@ -1 +1 @@ -Subproject commit 3f298195989388ce9207745c51fbadd3d6343d56 +Subproject commit ebd6793b42ecc08883e534d098e6c28caa13cd1d diff --git a/scripts/menuconfig.py b/scripts/menuconfig.py index 1b4a925..3283ae7 100644 --- a/scripts/menuconfig.py +++ b/scripts/menuconfig.py @@ -528,6 +528,7 @@ def apply_preset(preset: str, clks_options: List[OptionItem], user_options: List _set_all_options(values, user_options, TRI_Y) _set_option_if_exists(values, option_index, "CLEONOS_CLKS_ENABLE_USERLAND_AUTO_EXEC", TRI_N) _set_option_if_exists(values, option_index, "CLEONOS_CLKS_ENABLE_EXEC_SERIAL_LOG", TRI_Y) + _set_option_if_exists(values, option_index, "CLEONOS_CLKS_ENABLE_EXEC_CONTEXT_SWITCH_LOG", TRI_N) _set_option_if_exists(values, option_index, "CLEONOS_CLKS_ENABLE_PROCFS", TRI_Y) _set_option_if_exists(values, option_index, "CLEONOS_CLKS_ENABLE_IDLE_DEBUG_LOG", TRI_Y) return @@ -540,6 +541,12 @@ def apply_preset(preset: str, clks_options: List[OptionItem], user_options: List "CLEONOS_CLKS_ENABLE_AUDIO", "CLEONOS_CLKS_ENABLE_MOUSE", "CLEONOS_CLKS_ENABLE_DESKTOP", + "CLEONOS_CLKS_ENABLE_WM_MULTI_RECT_DAMAGE", + "CLEONOS_CLKS_ENABLE_WM_LAYER_CACHE", + "CLEONOS_CLKS_ENABLE_WM_FRAME_PACING", + "CLEONOS_CLKS_ENABLE_WM_STATS_OVERLAY", + "CLEONOS_CLKS_ENABLE_WM_INPUT_DISPATCH", + "CLEONOS_CLKS_ENABLE_WM_REAP_DEAD_OWNERS", "CLEONOS_CLKS_ENABLE_DRIVER_MANAGER", "CLEONOS_CLKS_ENABLE_KELF", "CLEONOS_CLKS_ENABLE_EXTERNAL_PSF", @@ -554,6 +561,7 @@ def apply_preset(preset: str, clks_options: List[OptionItem], user_options: List "CLEONOS_CLKS_ENABLE_SYSCALL_TICK_QUERY", "CLEONOS_CLKS_ENABLE_TTY_READY_LOG", "CLEONOS_CLKS_ENABLE_IDLE_DEBUG_LOG", + "CLEONOS_CLKS_ENABLE_EXEC_CONTEXT_SWITCH_LOG", "CLEONOS_CLKS_ENABLE_USER_SYSTEM_APP_PROBE", "CLEONOS_CLKS_ENABLE_SCHED_TASK_COUNT_LOG", ] diff --git a/wine b/wine index fe46a15..86d4c8d 160000 --- a/wine +++ b/wine @@ -1 +1 @@ -Subproject commit fe46a157c22b4c5b9c6219838c94d32cbd9806d0 +Subproject commit 86d4c8d793231569bd5391c761a462ad5133b063