Implement support for buttons on notifications in Linux

This commit is contained in:
Kovid Goyal
2024-07-31 12:11:21 +05:30
parent ad36c481af
commit aa16918dd4
8 changed files with 60 additions and 25 deletions

2
glfw/glfw3.h vendored
View File

@@ -1316,7 +1316,7 @@ typedef struct GLFWLayerShellConfig {
} GLFWLayerShellConfig;
typedef struct GLFWDBUSNotificationData {
const char *app_name, *icon, *summary, *body, *action_name;
const char *app_name, *icon, *summary, *body, **actions; size_t num_actions;
int32_t timeout; uint8_t urgency; uint32_t replaces;
} GLFWDBUSNotificationData;

8
glfw/linux_notify.c vendored
View File

@@ -124,10 +124,10 @@ glfw_dbus_send_user_notification(const GLFWDBUSNotificationData *n, GLFWDBusnoti
APPEND(args, DBUS_TYPE_STRING, n->summary)
APPEND(args, DBUS_TYPE_STRING, n->body)
check_call(dbus_message_iter_open_container, &args, DBUS_TYPE_ARRAY, "s", &array);
if (n->action_name) {
static const char* default_action = "default";
APPEND(array, DBUS_TYPE_STRING, default_action);
APPEND(array, DBUS_TYPE_STRING, n->action_name);
if (n->actions) {
for (size_t i = 0; i < n->num_actions; i++) {
APPEND(array, DBUS_TYPE_STRING, n->actions[i]);
}
}
check_call(dbus_message_iter_close_container, &args, &array);
check_call(dbus_message_iter_open_container, &args, DBUS_TYPE_ARRAY, "{sv}", &array);