mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
This fixes an issue where it wasn't possible to trigger multiple notifications with the same kitty notification ID. This is something that works in kitty, and there's no reason why it shouldn't work. The issue was that we track stdout, and the notification helper's PID in the notification struct. Thus, when a notification is being displayed, we can't re-use the same notification struct instance for another notification. This patch fixes this by adding a new notification list, 'active_notifications'. Whenever we detect that we need to track the helper (notification want's to either focus the window on activation, or send an event to the application), we add a copy of the notification to the 'active' list. The notification can then be removed from the 'kitty' list, allowing kitty notifications to re-use the same ID over and over again, even if old notifications are still being displayed.
70 lines
1.6 KiB
C
70 lines
1.6 KiB
C
#pragma once
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <unistd.h>
|
|
|
|
struct terminal;
|
|
|
|
enum notify_when {
|
|
/* First, so that it can be left out of initializer and still be
|
|
the default */
|
|
NOTIFY_ALWAYS,
|
|
|
|
NOTIFY_UNFOCUSED,
|
|
NOTIFY_INVISIBLE
|
|
};
|
|
|
|
enum notify_urgency {
|
|
/* First, so that it can be left out of initializer and still be
|
|
the default */
|
|
NOTIFY_URGENCY_NORMAL,
|
|
|
|
NOTIFY_URGENCY_LOW,
|
|
NOTIFY_URGENCY_CRITICAL,
|
|
};
|
|
|
|
struct notification {
|
|
/*
|
|
* Set by caller of notify_notify()
|
|
*/
|
|
char *id;
|
|
char *title;
|
|
char *body;
|
|
|
|
char *icon_id;
|
|
char *icon_symbolic_name;
|
|
uint8_t *icon_data;
|
|
size_t icon_data_sz;
|
|
|
|
enum notify_when when;
|
|
enum notify_urgency urgency;
|
|
bool focus;
|
|
bool report;
|
|
|
|
/*
|
|
* Used internally by notify
|
|
*/
|
|
|
|
char *xdg_token; /* XDG activation token, from daemon */
|
|
|
|
pid_t pid; /* Notifier command PID */
|
|
int stdout_fd; /* Notifier command's stdout */
|
|
|
|
char *stdout_data; /* Data we've reado from command's stdout */
|
|
size_t stdout_sz;
|
|
};
|
|
|
|
struct notification_icon {
|
|
char *id;
|
|
char *symbolic_name;
|
|
char *tmp_file_on_disk;
|
|
};
|
|
|
|
bool notify_notify(struct terminal *term, struct notification *notif);
|
|
void notify_free(struct terminal *term, struct notification *notif);
|
|
|
|
void notify_icon_add(struct terminal *term, const char *id,
|
|
const char *symbolic_name, const uint8_t *data,
|
|
size_t data_sz);
|
|
void notify_icon_del(struct terminal *term, const char *id);
|
|
void notify_icon_free(struct notification_icon *icon);
|