diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-07-19 21:25:57 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-07-19 21:25:57 +0200 |
commit | ff2c33e3a1659560a3e6d4c5e2c099b240d788ef (patch) | |
tree | 7154d0c9cb64000c09006ee99150c0039e999319 /src/global_shortcuts.h | |
parent | 2209d5e461f1a727171e9ce0be92eb107e05e27b (diff) |
Add support for wayland global hotkeys (global shortcuts desktop portal), only kde really supports this. Refactor x11 hotkeys (use list...), add separate key for start/stop recording/pause
Diffstat (limited to 'src/global_shortcuts.h')
-rw-r--r-- | src/global_shortcuts.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/global_shortcuts.h b/src/global_shortcuts.h new file mode 100644 index 0000000..f27a4de --- /dev/null +++ b/src/global_shortcuts.h @@ -0,0 +1,41 @@ +#ifndef GLOBAL_SHORTCUTS_H +#define GLOBAL_SHORTCUTS_H + +/* Global shortcuts via desktop portal */ + +#include <stdbool.h> +#include <gio/gio.h> + +#define DBUS_RANDOM_STR_SIZE 16 + +typedef struct { + const char *id; + const char *trigger_description; +} gsr_shortcut; + +typedef struct { + const char *description; + gsr_shortcut shortcut; +} gsr_bind_shortcut; + +typedef void (*gsr_init_callback)(void *userdata); +typedef void (*gsr_shortcut_callback)(gsr_shortcut shortcut, void *userdata); +typedef void (*gsr_deactivated_callback)(const char *id, void *userdata); + +typedef struct { + GDBusConnection *gdbus_con; + char *session_handle; + bool session_created; + char random_str[DBUS_RANDOM_STR_SIZE + 1]; + unsigned int handle_counter; +} gsr_global_shortcuts; + +bool gsr_global_shortcuts_init(gsr_global_shortcuts *self, gsr_init_callback callback, void *userdata); +void gsr_global_shortcuts_deinit(gsr_global_shortcuts *self); + +bool gsr_global_shortcuts_list_shortcuts(gsr_global_shortcuts *self, gsr_shortcut_callback callback, void *userdata); +bool gsr_global_shortcuts_bind_shortcuts(gsr_global_shortcuts *self, const gsr_bind_shortcut *shortcuts, int num_shortcuts, gsr_shortcut_callback callback, void *userdata); + +bool gsr_global_shortcuts_subscribe_activated_signal(gsr_global_shortcuts *self, gsr_deactivated_callback deactivated_callback, gsr_shortcut_callback shortcut_changed_callback, void *userdata); + +#endif /* GLOBAL_SHORTCUTS_H */ |