From 9b88f2520862f8707e5e7b91ac0871adbe2edac9 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 3 Oct 2017 21:06:32 +0200 Subject: rootston: rotate views! --- include/rootston/input.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/rootston/input.h b/include/rootston/input.h index 6161eb7a..21120ad2 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -83,6 +83,7 @@ struct roots_input { struct roots_view *active_view; int offs_x, offs_y; int view_x, view_y, view_width, view_height; + float view_rotation; uint32_t resize_edges; // Ring buffer of input events that could trigger move/resize/rotate -- cgit v1.2.3 From f9dbc1841d0a2b4a93cfb9a1783a34ebed426c59 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 3 Oct 2017 22:14:25 +0200 Subject: rootston: add meta-key to config file --- include/rootston/config.h | 4 ++++ rootston/config.c | 50 +++++++++++++++++++++++++++++-------------- rootston/cursor.c | 11 +++++++--- rootston/rootston.ini.example | 5 ++++- 4 files changed, 50 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/rootston/config.h b/include/rootston/config.h index ece11829..545b6742 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -33,6 +33,10 @@ struct roots_config { struct wlr_box *mapped_box; } cursor; + struct { + uint32_t meta_key; + } keyboard; + struct wl_list outputs; struct wl_list devices; struct wl_list bindings; 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 -- cgit v1.2.3