diff options
author | emersion <contact@emersion.fr> | 2017-10-03 22:14:25 +0200 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-10-03 22:14:25 +0200 |
commit | f9dbc1841d0a2b4a93cfb9a1783a34ebed426c59 (patch) | |
tree | f6e0976e71ee18d051b026366a078a0b1def3b42 /rootston | |
parent | 9b88f2520862f8707e5e7b91ac0871adbe2edac9 (diff) |
rootston: add meta-key to config file
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/config.c | 50 | ||||
-rw-r--r-- | rootston/cursor.c | 11 | ||||
-rw-r--r-- | rootston/rootston.ini.example | 5 |
3 files changed, 46 insertions, 20 deletions
diff --git a/rootston/config.c b/rootston/config.c index 3a21aff3..d454c2d9 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -86,6 +86,28 @@ invalid_input: return NULL; } +static uint32_t parse_modifier(const char *symname) { + if (strcmp(symname, "Shift") == 0) { + return WLR_MODIFIER_SHIFT; + } else if (strcmp(symname, "Caps") == 0) { + return WLR_MODIFIER_CAPS; + } else if (strcmp(symname, "Ctrl") == 0) { + return WLR_MODIFIER_CTRL; + } else if (strcmp(symname, "Alt") == 0) { + return WLR_MODIFIER_ALT; + } else if (strcmp(symname, "Mod2") == 0) { + return WLR_MODIFIER_MOD2; + } else if (strcmp(symname, "Mod3") == 0) { + return WLR_MODIFIER_MOD3; + } else if (strcmp(symname, "Logo") == 0) { + return WLR_MODIFIER_LOGO; + } else if (strcmp(symname, "Mod5") == 0) { + return WLR_MODIFIER_MOD5; + } else { + return 0; + } +} + static const char *output_prefix = "output:"; static const char *device_prefix = "device:"; @@ -171,6 +193,15 @@ static int config_ini_handler(void *user, const char *section, const char *name, } else { wlr_log(L_ERROR, "got unknown device config: %s", name); } + } else if (strcmp(section, "keyboard") == 0) { + if (strcmp(name, "meta-key") == 0) { + config->keyboard.meta_key = parse_modifier(value); + if (config->keyboard.meta_key == 0) { + wlr_log(L_ERROR, "got unknown meta key: %s", name); + } + } else { + wlr_log(L_ERROR, "got unknown keyboard config: %s", name); + } } else if (strcmp(section, "bindings") == 0) { struct binding_config *bc = calloc(1, sizeof(struct binding_config)); wl_list_insert(&config->bindings, &bc->link); @@ -190,22 +221,9 @@ static int config_ini_handler(void *user, const char *section, const char *name, bc->keysyms = calloc(1, keysyms_len * sizeof(xkb_keysym_t)); char *symname = symnames; for (size_t i = 0; i < keysyms_len; i++) { - if (strcmp(symname, "Shift") == 0) { - bc->modifiers |= WLR_MODIFIER_SHIFT; - } else if (strcmp(symname, "Caps") == 0) { - bc->modifiers |= WLR_MODIFIER_CAPS; - } else if (strcmp(symname, "Ctrl") == 0) { - bc->modifiers |= WLR_MODIFIER_CTRL; - } else if (strcmp(symname, "Alt") == 0) { - bc->modifiers |= WLR_MODIFIER_ALT; - } else if (strcmp(symname, "Mod2") == 0) { - bc->modifiers |= WLR_MODIFIER_MOD2; - } else if (strcmp(symname, "Mod3") == 0) { - bc->modifiers |= WLR_MODIFIER_MOD3; - } else if (strcmp(symname, "Logo") == 0) { - bc->modifiers |= WLR_MODIFIER_LOGO; - } else if (strcmp(symname, "Mod5") == 0) { - bc->modifiers |= WLR_MODIFIER_MOD5; + uint32_t modifier = parse_modifier(symname); + if (modifier != 0) { + bc->modifiers |= modifier; } else { xkb_keysym_t sym = xkb_keysym_from_name(symname, XKB_KEYSYM_NO_FLAGS); diff --git a/rootston/cursor.c b/rootston/cursor.c index 00218064..c26ca43a 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -166,12 +166,17 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) { event->orientation, event->delta); } -static bool is_logo_pressed(struct roots_input *input) { +static bool is_meta_pressed(struct roots_input *input) { + uint32_t meta_key = input->server->config->keyboard.meta_key; + if (meta_key == 0) { + return false; + } + struct roots_keyboard *keyboard; wl_list_for_each(keyboard, &input->keyboards, link) { uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard); - if ((modifiers ^ WLR_MODIFIER_LOGO) == 0) { + if ((modifiers ^ meta_key) == 0) { return true; } } @@ -187,7 +192,7 @@ static void do_cursor_button_press(struct roots_input *input, struct roots_view *view = view_at(desktop, input->cursor->x, input->cursor->y, &surface, &sx, &sy); - if (state == WLR_BUTTON_PRESSED && view && is_logo_pressed(input)) { + if (state == WLR_BUTTON_PRESSED && view && is_meta_pressed(input)) { set_view_focus(input, desktop, view); switch (button) { diff --git a/rootston/rootston.ini.example b/rootston/rootston.ini.example index 8dd51ea2..9960cae1 100644 --- a/rootston/rootston.ini.example +++ b/rootston/rootston.ini.example @@ -25,8 +25,11 @@ map-to-output = VGA-1 # Restrict cursor movements for this mouse to concrete rectangle geometry = 2500x800 +[keyboard] +meta-key = Logo + # Keybindings # Maps key combinations with commands to execute # The special command "exit" stops the compositor [bindings] -Logo+q=exit +Logo+q = exit |