From ef1f71e92f59b526e1efafeccb771f0299384b69 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Tue, 9 Dec 2025 09:37:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=AA=97=E5=8F=A3=E6=97=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86=E5=AF=B9=E5=BA=94=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client.c | 17 +++++++++++++++++ src/event.c | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/client.c b/src/client.c index c327cd2..21f96b7 100644 --- a/src/client.c +++ b/src/client.c @@ -204,6 +204,23 @@ void client_resize(client_t *client, uint16_t width, uint16_t height) { width, height); } +void client_unmanage(client_t *client) { + monitor_t *m = client->monitor; + + client_detach_list(client); + client_detach_stack(client); + + for (tag_t *tag = m->tag_list; tag; tag = tag->next) { + if (tag->mask & client->tags) client_remove_from_tag(client, tag); + } + + client_wipe(client); + + monitor_arrange(m); + monitor_draw_bar(m); + xcb_flush(wm.xcb_conn); +} + bool client_is_visible(client_t *client) { return client->tags & client->monitor->selected_tag->mask; } diff --git a/src/event.c b/src/event.c index 67647b8..4f5d9a3 100644 --- a/src/event.c +++ b/src/event.c @@ -139,6 +139,16 @@ static void property_notify(xcb_property_notify_event_t *ev) { } } +static void destroy_notify(xcb_destroy_notify_event_t *ev) { + client_t *client = client_get_by_window(ev->window); + if (client) client_unmanage(client); +} + +static void unmap_notify(xcb_unmap_notify_event_t *ev) { + client_t *client = client_get_by_window(ev->window); + if (client) client_unmanage(client); +} + static void handle_xcb_event(xcb_generic_event_t *event) { uint8_t event_type = XCB_EVENT_RESPONSE_TYPE(event); const char *label = xcb_event_get_label(event_type); @@ -157,6 +167,8 @@ static void handle_xcb_event(xcb_generic_event_t *event) { EVENT(XCB_CONFIGURE_REQUEST, configure_request); EVENT(XCB_MAP_REQUEST, map_request); EVENT(XCB_PROPERTY_NOTIFY, property_notify); + EVENT(XCB_UNMAP_NOTIFY, unmap_notify); + EVENT(XCB_DESTROY_NOTIFY, destroy_notify); #undef EVENT }