mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
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:
parent
d53f0aea75
commit
c797222930
3 changed files with 30 additions and 6 deletions
11
notify.c
11
notify.c
|
|
@ -181,7 +181,7 @@ notif_done(struct reaper *reaper, pid_t pid, int status, void *data)
|
||||||
if (notif->activated && notif->report_activated) {
|
if (notif->activated && notif->report_activated) {
|
||||||
xassert(notif->id != NULL);
|
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];
|
char reply[7 + strlen(notif->id) + 1 + 2 + 1];
|
||||||
int n = xsnprintf(
|
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);
|
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);
|
notify_free(term, notif);
|
||||||
tll_remove(term->active_notifications, it);
|
tll_remove(term->active_notifications, it);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
1
notify.h
1
notify.h
|
|
@ -40,6 +40,7 @@ struct notification {
|
||||||
enum notify_urgency urgency;
|
enum notify_urgency urgency;
|
||||||
bool focus;
|
bool focus;
|
||||||
bool report_activated;
|
bool report_activated;
|
||||||
|
bool report_closed;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used internally by notify
|
* Used internally by notify
|
||||||
|
|
|
||||||
24
osc.c
24
osc.c
|
|
@ -581,7 +581,8 @@ kitty_notification(struct terminal *term, char *string)
|
||||||
char *payload = NULL;
|
char *payload = NULL;
|
||||||
|
|
||||||
bool focus = true; /* The 'a' parameter */
|
bool focus = true; /* The 'a' parameter */
|
||||||
bool report = false; /* The 'a' parameter */
|
bool report_activated = false; /* The 'a' parameter */
|
||||||
|
bool report_closed = false; /* The 'c' parameter */
|
||||||
bool done = true; /* The 'd' parameter */
|
bool done = true; /* The 'd' parameter */
|
||||||
bool base64 = false; /* The 'e' parameter */
|
bool base64 = false; /* The 'e' parameter */
|
||||||
|
|
||||||
|
|
@ -596,6 +597,7 @@ kitty_notification(struct terminal *term, char *string)
|
||||||
enum notify_urgency urgency = NOTIFY_URGENCY_NORMAL;
|
enum notify_urgency urgency = NOTIFY_URGENCY_NORMAL;
|
||||||
|
|
||||||
bool have_a = false;
|
bool have_a = false;
|
||||||
|
bool have_c = false;
|
||||||
bool have_o = false;
|
bool have_o = false;
|
||||||
bool have_u = false;
|
bool have_u = false;
|
||||||
|
|
||||||
|
|
@ -628,12 +630,20 @@ kitty_notification(struct terminal *term, char *string)
|
||||||
if (streq(v, "focus"))
|
if (streq(v, "focus"))
|
||||||
focus = !reverse;
|
focus = !reverse;
|
||||||
else if (streq(v, "report"))
|
else if (streq(v, "report"))
|
||||||
report = !reverse;
|
report_activated = !reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
if (value[0] == '1' && value[1] == '\0')
|
||||||
|
report_closed = true;
|
||||||
|
else if (value[0] == '0' && value[1] == '\0')
|
||||||
|
report_closed = false;
|
||||||
|
have_c = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
/* done: 0|1 */
|
/* done: 0|1 */
|
||||||
if (value[0] == '0' && value[1] == '\0')
|
if (value[0] == '0' && value[1] == '\0')
|
||||||
|
|
@ -677,7 +687,7 @@ kitty_notification(struct terminal *term, char *string)
|
||||||
char reply[128];
|
char reply[128];
|
||||||
int n = xsnprintf(
|
int n = xsnprintf(
|
||||||
reply, sizeof(reply),
|
reply, sizeof(reply),
|
||||||
"\033]99;i=%s:p=?;p=title,body,icon:a=focus,report:o=%s:u=0,1,2%s",
|
"\033]99;i=%s:p=?;p=title,body,icon:a=focus,report:o=%s:u=0,1,2:c=1%s",
|
||||||
id, when_str, terminator);
|
id, when_str, terminator);
|
||||||
|
|
||||||
term_to_slave(term, reply, n);
|
term_to_slave(term, reply, n);
|
||||||
|
|
@ -746,7 +756,8 @@ kitty_notification(struct terminal *term, char *string)
|
||||||
.when = when,
|
.when = when,
|
||||||
.urgency = urgency,
|
.urgency = urgency,
|
||||||
.focus = focus,
|
.focus = focus,
|
||||||
.report_activated = report,
|
.report_activated = report_activated,
|
||||||
|
.report_closed = report_closed,
|
||||||
.stdout_fd = -1,
|
.stdout_fd = -1,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -762,9 +773,12 @@ kitty_notification(struct terminal *term, char *string)
|
||||||
/* Update notification metadata */
|
/* Update notification metadata */
|
||||||
if (have_a) {
|
if (have_a) {
|
||||||
notif->focus = focus;
|
notif->focus = focus;
|
||||||
notif->report_activated = report;
|
notif->report_activated = report_activated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (have_c)
|
||||||
|
notif->report_closed = report_closed;
|
||||||
|
|
||||||
if (have_o)
|
if (have_o)
|
||||||
notif->when = when;
|
notif->when = when;
|
||||||
if (have_u)
|
if (have_u)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue