feat(runtime): 启动时扫描并接管已有窗口

从 handle_map_request 中提取 populate_window_event 供复用,
新增 backend_scan_windows 扫描 X11 根窗口子树,
runtime_scan 将扫描到的窗口走完整 policy 流程纳入管理。
route_map_request 增加 override_redirect 过滤。
This commit is contained in:
2026-05-07 06:36:58 +08:00
parent c1a4795a85
commit 9275d14c5f
7 changed files with 141 additions and 23 deletions

View File

@@ -91,18 +91,13 @@ static bool urgent_from_states(
return false;
}
static bool handle_map_request(
bool populate_window_event(
backend_t *backend,
event_t *event,
const xcb_map_request_event_t *xcb_event
xcb_window_t window,
window_map_request_event_t *ev
) {
xcb_window_t window = xcb_event->window;
event->type = ZDWM_EVENT_WINDOW_MAP_REQUEST;
window_map_request_event_t *ev = &event->as.window_map_request;
ev->window = (window_id_t)window;
ev->transient_for = window_get_transient_for(backend, window);
ev->window = (window_id_t)window;
ev->transient_for = window_get_transient_for(backend, window);
xcb_get_window_attributes_reply_t *wa =
window_get_attributes(backend, window);
@@ -167,6 +162,19 @@ static bool handle_map_request(
return true;
}
static bool handle_map_request(
backend_t *backend,
event_t *event,
const xcb_map_request_event_t *xcb_event
) {
event->type = ZDWM_EVENT_WINDOW_MAP_REQUEST;
return populate_window_event(
backend,
xcb_event->window,
&event->as.window_map_request
);
}
static bool handle_unmap_notify(
backend_t *backend,
event_t *event,