Use a command string rather than an action enum
This commit is contained in:
parent
97d0fe8976
commit
238ded1578
|
@ -18,14 +18,10 @@ struct device_config {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum binding_config_action {
|
|
||||||
BINDING_CONFIG_ACTION_QUIT,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct binding_config {
|
struct binding_config {
|
||||||
xkb_keysym_t *keysyms;
|
xkb_keysym_t *keysyms;
|
||||||
size_t keysyms_len;
|
size_t keysyms_len;
|
||||||
enum binding_config_action action;
|
char *command;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -175,14 +175,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
||||||
struct binding_config *bc = calloc(1, sizeof(struct binding_config));
|
struct binding_config *bc = calloc(1, sizeof(struct binding_config));
|
||||||
wl_list_insert(&config->bindings, &bc->link);
|
wl_list_insert(&config->bindings, &bc->link);
|
||||||
|
|
||||||
if (strcmp(value, "quit") == 0) {
|
bc->command = strdup(value);
|
||||||
bc->action = BINDING_CONFIG_ACTION_QUIT;
|
|
||||||
} else {
|
|
||||||
wlr_log(L_ERROR, "got unknown key binding action: %s", value);
|
|
||||||
wl_list_remove(&bc->link);
|
|
||||||
free(bc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bc->keysyms_len = 1;
|
bc->keysyms_len = 1;
|
||||||
char *symnames = strdup(name);
|
char *symnames = strdup(name);
|
||||||
|
@ -226,7 +219,7 @@ struct roots_config *parse_args(int argc, char *argv[]) {
|
||||||
// TEMPORARY, probably
|
// TEMPORARY, probably
|
||||||
struct binding_config *bc = calloc(1, sizeof(struct binding_config));
|
struct binding_config *bc = calloc(1, sizeof(struct binding_config));
|
||||||
wl_list_insert(&config->bindings, &bc->link);
|
wl_list_insert(&config->bindings, &bc->link);
|
||||||
bc->action = BINDING_CONFIG_ACTION_QUIT;
|
bc->command = strdup("exit");
|
||||||
bc->keysyms_len = 1;
|
bc->keysyms_len = 1;
|
||||||
bc->keysyms = calloc(1, sizeof(xkb_keysym_t));
|
bc->keysyms = calloc(1, sizeof(xkb_keysym_t));
|
||||||
bc->keysyms[0] = XKB_KEY_Escape;
|
bc->keysyms[0] = XKB_KEY_Escape;
|
||||||
|
|
|
@ -21,12 +21,10 @@ static ssize_t keyboard_pressed_keysym_index(struct roots_keyboard *keyboard,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
||||||
struct binding_config *bc) {
|
char *command) {
|
||||||
struct roots_server *server = keyboard->input->server;
|
struct roots_server *server = keyboard->input->server;
|
||||||
switch (bc->action) {
|
if (strcmp(command, "exit") == 0) {
|
||||||
case BINDING_CONFIG_ACTION_QUIT:
|
|
||||||
wl_display_terminate(server->wl_display);
|
wl_display_terminate(server->wl_display);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ static void keyboard_keysym_press(struct roots_keyboard *keyboard,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
keyboard_binding_execute(keyboard, bc);
|
keyboard_binding_execute(keyboard, bc->command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue