mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
parent
1c8d347a61
commit
daa0308932
1 changed files with 19 additions and 0 deletions
|
|
@ -124,6 +124,25 @@ keybind_create(const char *keybind)
|
|||
gchar **symnames = g_strsplit(keybind, "-", -1);
|
||||
for (size_t i = 0; symnames[i]; i++) {
|
||||
char *symname = symnames[i];
|
||||
/*
|
||||
* Since "-" is used as a separator, a keybind string like "W--"
|
||||
* becomes "W", "", "". This means that it is impossible to bind
|
||||
* an action to the "-" key in this way.
|
||||
* We detect empty ""s outputted by g_strsplit and treat them as
|
||||
* literal "-"s.
|
||||
*/
|
||||
if (!symname[0]) {
|
||||
/*
|
||||
* You might have noticed that in the "W--" example, the
|
||||
* output is "W", "", ""; which turns into "W", "-",
|
||||
* "-". In order to avoid such duplications, we perform
|
||||
* a lookahead on the tokens to treat that edge-case.
|
||||
*/
|
||||
if (symnames[i+1] && !symnames[i+1][0]) {
|
||||
continue;
|
||||
}
|
||||
symname = "-";
|
||||
}
|
||||
uint32_t modifier = parse_modifier(symname);
|
||||
if (modifier != 0) {
|
||||
k->modifiers |= modifier;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue