osc: kitty notification: implement 'close' events

Application can now request to receive a 'close' event when the
notification is closed (but not necessarily activated), by adding
'c=1' to the notification request.
This commit is contained in:
Daniel Eklöf 2024-07-25 18:47:23 +02:00
parent d53f0aea75
commit c797222930
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 30 additions and 6 deletions

View file

@ -181,7 +181,7 @@ notif_done(struct reaper *reaper, pid_t pid, int status, void *data)
if (notif->activated && notif->report_activated) {
xassert(notif->id != NULL);
LOG_DBG("sending notification report to client");
LOG_DBG("sending notification activation event to client");
char reply[7 + strlen(notif->id) + 1 + 2 + 1];
int n = xsnprintf(
@ -189,6 +189,15 @@ notif_done(struct reaper *reaper, pid_t pid, int status, void *data)
term_to_slave(term, reply, n);
}
if (notif->report_closed) {
LOG_DBG("sending notification close event to client");
char reply[7 + strlen(notif->id) + 1 + 7 + 1 + 2 + 1];
int n = xsnprintf(
reply, sizeof(reply), "\033]99;i=%s:p=close;\033\\", notif->id);
term_to_slave(term, reply, n);
}
notify_free(term, notif);
tll_remove(term->active_notifications, it);
return;