mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
rcxml: refactor load_default_key_bindings()
This commit is contained in:
parent
b5acf387b8
commit
39b9133cec
1 changed files with 25 additions and 27 deletions
|
|
@ -342,37 +342,35 @@ rcxml_init()
|
|||
rc.doubleclick_time = 500;
|
||||
}
|
||||
|
||||
static void
|
||||
bind(const char *binding, const char *action, const char *command)
|
||||
{
|
||||
if (!binding || !action) {
|
||||
return;
|
||||
}
|
||||
struct keybind *k = keybind_create(binding);
|
||||
if (!k) {
|
||||
return;
|
||||
}
|
||||
if (action) {
|
||||
k->action = strdup(action);
|
||||
}
|
||||
if (command) {
|
||||
k->command = strdup(command);
|
||||
}
|
||||
}
|
||||
static struct {
|
||||
const char *binding, *action, *command;
|
||||
} key_combos[] = {
|
||||
{ "A-Tab", "NextWindow", NULL },
|
||||
{ "A-Escape", "Exit", NULL },
|
||||
{ "W-Return", "Execute", "alacritty" },
|
||||
{ "A-F3", "Execute", "bemenu-run" },
|
||||
{ "A-F4", "Close", NULL },
|
||||
{ "W-a", "ToggleMaximize", NULL },
|
||||
{ "A-Left", "MoveToEdge", "left" },
|
||||
{ "A-Right", "MoveToEdge", "right" },
|
||||
{ "A-Up", "MoveToEdge", "up" },
|
||||
{ "A-Down", "MoveToEdge", "down" },
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
static void
|
||||
load_default_key_bindings(void)
|
||||
{
|
||||
bind("A-Tab", "NextWindow", NULL);
|
||||
bind("A-Escape", "Exit", NULL);
|
||||
bind("W-Return", "Execute", "alacritty");
|
||||
bind("A-F3", "Execute", "bemenu-run");
|
||||
bind("A-F4", "Close", NULL);
|
||||
bind("W-a", "ToggleMaximize", NULL);
|
||||
bind("A-Left", "MoveToEdge", "left");
|
||||
bind("A-Right", "MoveToEdge", "right");
|
||||
bind("A-Up", "MoveToEdge", "up");
|
||||
bind("A-Down", "MoveToEdge", "down");
|
||||
for (int i = 0; key_combos[i].binding; i++) {
|
||||
struct keybind *k = keybind_create(key_combos[i].binding);
|
||||
if (!k) {
|
||||
continue;
|
||||
}
|
||||
k->action = strdup(key_combos[i].action);
|
||||
if (key_combos[i].command) {
|
||||
k->command = strdup(key_combos[i].command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue