From 23d261e26b77ac80a972fd841de2fba6b586b5c9 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Thu, 6 Feb 2025 12:07:25 +0800 Subject: [PATCH] fix: foreign toplevel release miss fix:cerash about last change --- main.c | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 1e54f9c..9f37552 100644 --- a/main.c +++ b/main.c @@ -2903,29 +2903,30 @@ void pending_kill_client(Client *c) { c->pending = c->geom; c->pending.y = c->geom.y + c->mon->m.height; - if (c == selmon->sel) - selmon->sel = NULL; - if (c == grabc) { cursor_mode = CurNormal; grabc = NULL; } + if (c == selmon->sel) { + selmon->sel = NULL; + Client *nextfocus = focustop(selmon); + + if(nextfocus) { + focusclient(nextfocus,0); + } + + if(!nextfocus && selmon->isoverview){ + Arg arg = {0}; + toggleoverview(&arg); + } + } + if(c->foreign_toplevel){ wlr_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel); c->foreign_toplevel = NULL; } - Client *nextfocus = focustop(selmon); - - if(nextfocus) { - focusclient(nextfocus,0); - } - - if(!nextfocus && selmon->isoverview){ - Arg arg = {0}; - toggleoverview(&arg); - } resize(c,c->geom,0); printstatus(); motionnotify(0, NULL, 0, 0, 0, 0); @@ -4903,6 +4904,25 @@ unmapnotify(struct wl_listener *listener, void *data) /* Called when the surface is unmapped, and should no longer be shown. */ Client *c = wl_container_of(listener, c, unmap); + if (c == grabc) { + cursor_mode = CurNormal; + grabc = NULL; + } + + if (c == selmon->sel) { + selmon->sel = NULL; + Client *nextfocus = focustop(selmon); + + if(nextfocus) { + focusclient(nextfocus,0); + } + + if(!nextfocus && selmon->isoverview){ + Arg arg = {0}; + toggleoverview(&arg); + } + } + if (client_is_unmanaged(c)) { if (c == exclusive_focus) exclusive_focus = NULL; @@ -4914,8 +4934,14 @@ unmapnotify(struct wl_listener *listener, void *data) wl_list_remove(&c->flink); } + if(c->foreign_toplevel){ + wlr_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel); + c->foreign_toplevel = NULL; + } + wlr_scene_node_destroy(&c->scene->node); printstatus(); + motionnotify(0, NULL, 0, 0, 0, 0); } void //0.5