程序结束时清理 xcb 模块环境

This commit is contained in:
2025-08-07 19:44:25 +08:00
parent 645d6594b8
commit d82081ca71
3 changed files with 21 additions and 0 deletions

View File

@@ -22,3 +22,4 @@ typedef struct window_list_t {
} window_list_t; } window_list_t;
window_list_t *scan_window_list(void); window_list_t *scan_window_list(void);
void free_window_list(window_list_t *window_list); void free_window_list(window_list_t *window_list);
void clean_xcb(void);

View File

@@ -31,6 +31,7 @@ int main(int argc, char *argv[]) {
} }
free_window_list(window_list); free_window_list(window_list);
clean_xcb();
return 0; return 0;
} }

View File

@@ -225,3 +225,22 @@ void free_window_list(window_list_t *window_list) {
free(window_list->list); free(window_list->list);
free(window_list); free(window_list);
} }
void clean_xcb(void) {
if (wm_check_window != XCB_NONE) {
xcb_destroy_window(conn, wm_check_window);
wm_check_window = XCB_NONE;
}
if (ewmh) {
if (!ewmh_init_failed) {
xcb_ewmh_connection_wipe(ewmh);
}
ewmh_init_failed = false;
ewmh = NULL;
}
xcb_disconnect(conn);
conn = NULL;
screen = NULL;
}