From 45bad74f92e488daec9479bddb126a583ef532f9 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 14 Sep 2023 08:37:20 +1000 Subject: [PATCH] Allow Notify:Close to work for docs being closed. When a doc is closed we need to allow some notifications. Remove the Close:Notify hack and use Notify:Close with the target commands defined with DEF_CMD_CLOSED(). Signed-off-by: NeilBrown --- core-doc.c | 9 +++------ core-pane.c | 5 ----- core-pane.h | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/core-doc.c b/core-doc.c index 1e154290..31b45492 100644 --- a/core-doc.c +++ b/core-doc.c @@ -732,10 +732,7 @@ DEF_CMD(doc_addview) if (d->views /* FIXME always true */) { points_attach(d, ret); d->views[ret].owner = ci->focus; - /* Use Close:Notify because we need this even - * when the pane is closing - */ - pane_add_notify(ci->home, ci->focus, "Close:Notify"); + pane_add_notify(ci->home, ci->focus, "Notify:Close"); } return 1 + ret; } @@ -747,7 +744,7 @@ DEF_CMD(doc_close_doc) return 1; } -DEF_CMD(doc_view_close) +DEF_CMD_CLOSED(doc_view_close) { /* A pane which once held a view is closing. We must discard * that view if it still exists. @@ -1334,7 +1331,7 @@ static void init_doc_cmds(void) key_add(doc_default_cmd, "doc:add-view", &doc_addview); key_add(doc_default_cmd, "doc:del-view", &doc_delview); - key_add(doc_default_cmd, "Close:Notify", &doc_view_close); + key_add(doc_default_cmd, "Notify:Close", &doc_view_close); key_add(doc_default_cmd, "doc:vmark-get", &doc_vmarkget); key_add(doc_default_cmd, "doc:vmark-prev", &doc_vmarkprev); key_add(doc_default_cmd, "doc:vmark-new", &doc_vmarknew); diff --git a/core-pane.c b/core-pane.c index f8ff319a..4e2932cd 100644 --- a/core-pane.c +++ b/core-pane.c @@ -489,11 +489,6 @@ static void pane_notify_close(struct pane *p safe) list_del_init(&n->notifier_link); if (strcmp(n->notification, "Notify:Close") == 0) pane_call(n->notifiee, n->notification, p); - /* Close:Notify can be delivered even to DAMAGED_CLOSED - * panes - */ - if (strcmp(n->notification, "Close:Notify") == 0) - pane_call(n->notifiee, n->notification, p); free(n->notification); free(n); } diff --git a/core-pane.h b/core-pane.h index ebc27fa0..65a43ff3 100644 --- a/core-pane.h +++ b/core-pane.h @@ -138,7 +138,7 @@ static inline int do_call_val(enum target_type type, struct pane *home, */ strncmp(ci.key, "Close", 5) != 0) /* This pane cannot accept anything but - * "Close" or "Close:mark" or "Close:Notify" + * "Close" or "Close:mark". */ return Efallthrough; ci.comm = home->handle; -- 2.39.5