From c1cb196365aacdff8c4a2d375be92d1fca097750 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Nov 2021 14:14:50 +0530 Subject: [PATCH] Set the media role when playing the bell sound to "event" Fixes #4256 --- kitty/data-types.h | 2 +- kitty/desktop.c | 5 +++-- kitty/glfw.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kitty/data-types.h b/kitty/data-types.h index 06f05b714..bb74c4ee0 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -363,7 +363,7 @@ void scroll_event(double, double, int, int); void on_key_input(GLFWkeyevent *ev); void request_window_attention(id_type, bool); #ifndef __APPLE__ -void play_canberra_sound(const char *which_sound, const char *event_id, bool is_path); +void play_canberra_sound(const char *which_sound, const char *event_id, bool is_path, const char *role); #endif SPRITE_MAP_HANDLE alloc_sprite_map(unsigned int, unsigned int); SPRITE_MAP_HANDLE free_sprite_map(SPRITE_MAP_HANDLE); diff --git a/kitty/desktop.c b/kitty/desktop.c index 3013e918a..97618f4a2 100644 --- a/kitty/desktop.c +++ b/kitty/desktop.c @@ -145,7 +145,7 @@ load_libcanberra(void) { } void -play_canberra_sound(const char *which_sound, const char *event_id, bool is_path) { +play_canberra_sound(const char *which_sound, const char *event_id, bool is_path, const char *media_role) { load_libcanberra(); if (libcanberra_handle == NULL || canberra_ctx == NULL) return; const char *which_type = is_path ? "media.filename" : "event.id"; @@ -153,6 +153,7 @@ play_canberra_sound(const char *which_sound, const char *event_id, bool is_path) canberra_ctx, 0, which_type, which_sound, "event.description", event_id, + "media.role", media_role, NULL ); } @@ -162,7 +163,7 @@ play_desktop_sound(PyObject *self UNUSED, PyObject *args) { const char *which, *event_id = "test sound"; int is_path = 0; if (!PyArg_ParseTuple(args, "s|sp", &which, &event_id, &is_path)) return NULL; - play_canberra_sound(which, event_id, is_path); + play_canberra_sound(which, event_id, is_path, "event"); Py_RETURN_NONE; } diff --git a/kitty/glfw.c b/kitty/glfw.c index 50eb9ada2..84b545d5a 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -1193,8 +1193,8 @@ ring_audio_bell(void) { #ifdef __APPLE__ cocoa_system_beep(OPT(bell_path)); #else - if (OPT(bell_path)) play_canberra_sound(OPT(bell_path), "kitty bell", true); - else play_canberra_sound("bell", "kitty bell", false); + if (OPT(bell_path)) play_canberra_sound(OPT(bell_path), "kitty bell", true, "event"); + else play_canberra_sound("bell", "kitty bell", false, "event"); #endif }