From d82081ca71e736f80c1aea5fe9a2abc7310b5027 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Thu, 7 Aug 2025 19:44:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=BB=93=E6=9D=9F=E6=97=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86=20xcb=20=E6=A8=A1=E5=9D=97=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/xcb.h | 1 + src/main.c | 1 + src/xcb/xcb.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/include/xcb.h b/src/include/xcb.h index 899ff79..89dd3b8 100644 --- a/src/include/xcb.h +++ b/src/include/xcb.h @@ -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); diff --git a/src/main.c b/src/main.c index aaae239..2292183 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,7 @@ int main(int argc, char *argv[]) { } free_window_list(window_list); + clean_xcb(); return 0; } diff --git a/src/xcb/xcb.c b/src/xcb/xcb.c index 5cb01ee..7bdf2b8 100644 --- a/src/xcb/xcb.c +++ b/src/xcb/xcb.c @@ -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; +}