2021-11-13 21:56:53 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2023-05-13 16:10:33 +03:00
|
|
|
#ifndef LABWC_KEYBIND_H
|
|
|
|
|
#define LABWC_KEYBIND_H
|
2020-08-03 20:56:38 +01:00
|
|
|
|
2025-09-06 20:06:32 -04:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <wayland-util.h>
|
2020-08-03 20:56:38 +01:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
|
2022-01-03 05:38:48 +01:00
|
|
|
#define MAX_KEYSYMS 32
|
2023-09-05 15:18:41 +02:00
|
|
|
#define MAX_KEYCODES 16
|
|
|
|
|
|
|
|
|
|
struct server;
|
2022-01-03 05:38:48 +01:00
|
|
|
|
2020-08-03 20:56:38 +01:00
|
|
|
struct keybind {
|
|
|
|
|
uint32_t modifiers;
|
|
|
|
|
xkb_keysym_t *keysyms;
|
|
|
|
|
size_t keysyms_len;
|
2023-09-11 15:15:37 +02:00
|
|
|
bool use_syms_only;
|
2023-09-05 15:18:41 +02:00
|
|
|
xkb_keycode_t keycodes[MAX_KEYCODES];
|
|
|
|
|
size_t keycodes_len;
|
|
|
|
|
int keycodes_layout;
|
2024-08-02 14:08:19 +02:00
|
|
|
bool allow_when_locked;
|
2022-06-10 19:42:34 +02:00
|
|
|
struct wl_list actions; /* struct action.link */
|
|
|
|
|
struct wl_list link; /* struct rcxml.keybinds */
|
2024-04-26 11:05:12 +01:00
|
|
|
bool on_release;
|
2020-08-03 20:56:38 +01:00
|
|
|
};
|
|
|
|
|
|
2020-08-07 20:21:14 +01:00
|
|
|
/**
|
2020-09-02 21:05:28 +01:00
|
|
|
* keybind_create - parse keybind and add to linked list
|
2020-08-07 20:21:14 +01:00
|
|
|
* @keybind: key combination
|
|
|
|
|
*/
|
2020-09-02 21:05:28 +01:00
|
|
|
struct keybind *keybind_create(const char *keybind);
|
2020-08-03 20:56:38 +01:00
|
|
|
|
2024-11-15 22:58:44 +01:00
|
|
|
void keybind_destroy(struct keybind *keybind);
|
|
|
|
|
|
2021-12-01 02:28:41 +00:00
|
|
|
/**
|
|
|
|
|
* parse_modifier - parse a string containing a single modifier name (e.g. "S")
|
|
|
|
|
* into the represented modifier value. returns 0 for invalid modifier names.
|
|
|
|
|
* @symname: modifier name
|
|
|
|
|
*/
|
|
|
|
|
uint32_t parse_modifier(const char *symname);
|
|
|
|
|
|
2023-01-29 04:06:46 +01:00
|
|
|
bool keybind_the_same(struct keybind *a, struct keybind *b);
|
|
|
|
|
|
2025-08-16 13:17:36 -04:00
|
|
|
bool keybind_contains_keycode(struct keybind *keybind, xkb_keycode_t keycode);
|
|
|
|
|
bool keybind_contains_keysym(struct keybind *keybind, xkb_keysym_t keysym);
|
|
|
|
|
|
tree-wide: auto-replace of (struct server *)
#!/bin/bash
read -r -d '' EXPRS << EOF
s/xwayland->server/xwayland->svr/g;
s/\t*struct server \*server;\n//g;
s/\t*struct server \*server =.*?;\n//gs;
s/\t*.* = ([a-z_]*->)*server[;,]\n//g;
s/\{\n\n/\{\n/g;
s/\n\n+/\n\n/g;
s/\(\s*struct server \*server\)/(void)/g;
s/\(\s*struct server \*server,\s*/(/g;
s/,\s*struct server \*server\)/)/g;
s/,\s*struct server \*server,\s*/, /g;
s/\(\s*([a-z_]*->)*server\)/()/g;
s/\(\s*([a-z_]*->)*server,\s*/(/g;
s/,\s*([a-z_]*->)*server\)/)/g;
s/,\s*([a-z_]*->)*server,\s*/, /g;
s/([a-z_]*->)*server->/g_server./g;
s/xwayland->svr/xwayland->server/g;
EOF
find src include \( -name \*.c -o -name \*.h \) -exec \
perl -0777 -i -pe "$EXPRS" \{\} \;
2026-02-23 11:56:39 -05:00
|
|
|
void keybind_update_keycodes(void);
|
2023-05-13 16:10:33 +03:00
|
|
|
#endif /* LABWC_KEYBIND_H */
|