notifications: BEL and OSC-777 now focuses the window on notification activation

Or put more propertly; if the notification daemon, and the
notification helper used by foot has been configured
properly (i.e. they both support XDG activation tokens), notifications
generated by BEL and OSC-777 will now raise/focus the window when the
default action of the notification is activated - typically by
clicking the notification.

Closes #1822
This commit is contained in:
Daniel Eklöf 2024-09-05 07:13:53 +02:00
parent c15ebbfa2e
commit c5bb1fb2ed
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 14 additions and 4 deletions

View file

@ -69,6 +69,14 @@
* `cursor.unfocused-style` is now effective even when `cursor.style` * `cursor.unfocused-style` is now effective even when `cursor.style`
is not `block`. is not `block`.
* Activating a notification triggered with OSC-777, or BEL, now
focuses the foot window, if XDG activation tokens are supported by
the compositor, the notification daemon, and the notification helper
used by foot (i.e. `desktop-notifications.command`). This has been
supported for OSC-99 since 1.18.0, and now we also support it for
BEL and OSC-777 ([#1822][1822]).
[1822]: https://codeberg.org/dnkl/foot/issues/1822
### Deprecated ### Deprecated

5
osc.c
View file

@ -558,9 +558,10 @@ osc_notify(struct terminal *term, char *string)
} }
notify_notify(term, &(struct notification){ notify_notify(term, &(struct notification){
.title = (char *)title, .title = xstrdup(title),
.body = (char *)msg, .body = xstrdup(msg),
.expire_time = -1, .expire_time = -1,
.focus = true,
}); });
} }

View file

@ -3597,9 +3597,10 @@ term_bell(struct terminal *term)
if (term->conf->bell.notify) { if (term->conf->bell.notify) {
notify_notify(term, &(struct notification){ notify_notify(term, &(struct notification){
.title = (char *)"Bell", .title = xstrdup("Bell"),
.body = (char *)"Bell in terminal", .body = xstrdup("Bell in terminal"),
.expire_time = -1, .expire_time = -1,
.focus = true,
}); });
} }