diff options
| author | Trung Lê <8@tle.id.au> | 2026-02-21 23:40:05 +1100 |
|---|---|---|
| committer | Trung Lê <8@tle.id.au> | 2026-02-21 23:47:49 +1100 |
| commit | 3eed1b64af72dcb4bcb8ae28d45856767d4acff1 (patch) | |
| tree | 0aeef768169d69c4ed24c3cc03398c63aef3ff59 /src/global_shortcuts.h | |
Initial commit
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..087c177 --- /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)(bool success, 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 */ |
