Commit graph

33 commits

Author SHA1 Message Date
John Lindgren
b00873a988 src: remove unused #includes (via include-what-you-use) 2025-09-07 19:34:30 +09:00
John Lindgren
6574c82aed keybind: refactor update_keycodes_iter() to reduce nesting
update_keycodes_iter() currently has 4(!) levels of nested loops, which
makes the logic (especially the break/continue statements) difficult to
understand. The logic also appears to continue looping uselessly after
a given keycode has already been added to a keybind.

Refactor by adding some small utility functions:

- keybind_contains_keycode()
- keybind_contains_keysym()
- keybind_contains_any_keysym()

No functional change intended.
2025-08-18 19:54:18 +01:00
John Lindgren
e1475a1e47 include: reduce global includes in labwc.h 2025-07-30 21:04:31 +01:00
John Lindgren
31d42b50e2 src: include primary header first
This is a common practice in C projects, which simply enforces that
each header must compile cleanly without implicit dependencies on
other headers (see also the previous commit).
2025-07-29 21:51:56 +01:00
John Lindgren
cd8a8c2bf6 keybind: pointer to string literal should be const
Assigning to (char*) creates a mutable string literal, which was
likely not intended here and wasn't necessary.
2025-07-21 16:51:10 +02:00
Consolatis
6754801052 rcxml.c: fix mem leak when deduplicating keybinds
Before this patch `keybind->keysyms` wasn't free'd when
- deduplicating keybinds
- removing keybinds due to empty action list

This patch creates a shared `keybind_destroy()` helper
which gets used in all cases where a keybind is destroyed.
2024-11-16 22:13:17 +00:00
Chloé Vulquin
daa0308932 keybind: allow keybinding "-"
Updates #1811
2024-05-14 16:30:49 +02:00
Consolatis
65bd32d625 keybinds: add support for Meta and Hyper modifiers
The modifiers can be used in keybinds via M-key and H-key

Additionally adds support for:
- Mod1 (same as A)
- Mod3 (same as H)
- Mod4 (same as W)
- Mod5 (same as M)

This is compatible with the format used by Openbox.
(http://openbox.org/wiki/Help:Bindings#Syntax)

Mod2 (NumLock) and Caps are still not supported due to
their locking behavior but could theoretically be added.

Fixes: #1061
2023-10-08 21:11:32 +02:00
Consolatis
c1c624daf0 keybinds: add optional layoutDependent argument
This allows to define keybinds as layout dependent. E.g. keybinds
only trigger if the configured key exists in the currently active
keyboard layout. The keybind will also only trigger on the physical
key that is mapped to the configured key in the active layout.

By default the new argument is false which means all keybinds by
default are layout agnostic. This optional argument can be used
to restore the earlier default behavior of having keys layout
dependent.
2023-09-11 15:41:19 +02:00
Consolatis
6b80751010 keybinds: prefer keycodes over keysyms
This allows keyboard layout agnostic keybinds
in a multi layout configuration.

Fixes: #1069
2023-09-11 15:39:34 +02:00
Consolatis
272222e3c9 keybinds: allow non-english based keybinds 2023-09-07 23:24:36 +01:00
Consolatis
4a8b50603e src/config/rcxml.c: allow clearing key/mouse bindings
Fixes #567
2023-02-03 03:30:10 +01:00
Consolatis
89ad0b808f s/wl_list_insert(list.prev...)/wl_list_append(list...)/ 2022-10-05 19:50:36 +01:00
John Lindgren
a54d378e6c common: Add znew/znew_n() macros 2022-09-18 15:25:19 -04:00
John Lindgren
cb40cdc36c common: Add additional memory utilities (xzalloc() etc.) 2022-09-17 10:57:30 -04:00
Consolatis
39cdba36a8 src/config/keybind.c: fix keybind insertion order
This restores the intended behavior of keybinds set by `<default />`
to be overwritten by manually configured keybinds which come later in
the config.

In `src/keyboard.c`, `handle_keybinding()` is going backwards through
the list of keybindings and breaks after the first match.

`wl_list_insert(&list_node, item)` will insert the new item *after* the
list_node so if its called multiple times with the same list_node as
fist argument the result will be a reversed list. Using `list_node.prev`
instead will result in a non-reversed list.
2022-06-03 22:54:32 +01:00
Johan Malm
5b34c81768 Fix trivial coding style breaches 2022-04-04 20:53:36 +01:00
Consolatis
0b45cce648 Rewrite action handling to allow multiple actions at once 2022-01-05 16:22:41 +00:00
Consolatis
f28319be54 config/keybind.c: Don't overwrite the stack 2022-01-03 08:27:22 +00:00
bi4k8
c34a2fc976 make parse_modifiers public 2021-12-01 15:11:21 -05:00
Joshua Ashton
95ce9e0264 keybind: Fix shift modifiers
Need to lower the syms for these to match!

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-21 18:15:42 +01:00
Johan Malm
ebb632419b *.c: add SPDX-License-Identifier 2021-09-24 21:45:48 +01:00
Johan Malm
82e47ac1f5 Remove src/common/log.c
Use wlr_log() instead
2021-07-23 21:15:55 +01:00
Johan Malm
cd9fe2900e keybind: use XKB_KEYSYM_CASE_INSENSITIVE 2020-12-29 19:02:04 +00:00
Johan Malm
96e05057a3 Update .clang-format
Align with wlroots style
2020-09-28 20:41:41 +01:00
Johan Malm
b2504bdf9a keybind: s/add/create/ 2020-09-02 21:05:28 +01:00
Johan Malm
2a17df0f8b Add log.c with info() and warn() 2020-08-12 19:37:44 +01:00
Johan Malm
4d1363dcae include/: refactor header files more 2020-08-03 20:56:38 +01:00
Johan Malm
158f42d1e8 src/rcxml.c: parse <keybind> 2020-06-19 22:00:22 +01:00
Johan Malm
f6578248c0 src/keybind.c: move keybind_print() to dbg.c 2020-06-18 20:39:55 +01:00
Johan Malm
7440919452 Add action.c 2020-06-18 20:18:01 +01:00
Johan Malm
1e342f8976 src/keyboard.c: handle list of keybinds 2020-06-17 21:21:28 +01:00
Johan Malm
40f01ed3c9 Add keybind.c 2020-06-16 07:21:53 +01:00