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

This commit is contained in:
zedhugh committed 2025-08-07 19:44:25 +08:00
1 parent 645d6594b8
commit d82081ca71
3 files changed
+21

No files matched your search

+1
View File
@@ -22,3 +22,4 @@ typedef struct window_list_t {
} window_list_t;
window_list_t *scan_window_list(void);
void free_window_list(window_list_t *window_list);
void clean_xcb(void);
+1
View File
@@ -31,6 +31,7 @@ int main(int argc, char *argv[]) {
}
free_window_list(window_list);
clean_xcb();
return 0;
}
+19
View File
@@ -225,3 +225,22 @@ void free_window_list(window_list_t *window_list) {
free(window_list->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;
}