mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 10:29:49 +01:00
rootston: add meta-key to config file
This commit is contained in:
parent
9b88f25208
commit
f9dbc1841d
4 changed files with 50 additions and 20 deletions
|
@ -33,6 +33,10 @@ struct roots_config {
|
||||||
struct wlr_box *mapped_box;
|
struct wlr_box *mapped_box;
|
||||||
} cursor;
|
} cursor;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint32_t meta_key;
|
||||||
|
} keyboard;
|
||||||
|
|
||||||
struct wl_list outputs;
|
struct wl_list outputs;
|
||||||
struct wl_list devices;
|
struct wl_list devices;
|
||||||
struct wl_list bindings;
|
struct wl_list bindings;
|
||||||
|
|
|
@ -86,6 +86,28 @@ invalid_input:
|
||||||
return NULL;
|
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 *output_prefix = "output:";
|
||||||
static const char *device_prefix = "device:";
|
static const char *device_prefix = "device:";
|
||||||
|
|
||||||
|
@ -171,6 +193,15 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "got unknown device config: %s", name);
|
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) {
|
} else if (strcmp(section, "bindings") == 0) {
|
||||||
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);
|
||||||
|
@ -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));
|
bc->keysyms = calloc(1, keysyms_len * sizeof(xkb_keysym_t));
|
||||||
char *symname = symnames;
|
char *symname = symnames;
|
||||||
for (size_t i = 0; i < keysyms_len; i++) {
|
for (size_t i = 0; i < keysyms_len; i++) {
|
||||||
if (strcmp(symname, "Shift") == 0) {
|
uint32_t modifier = parse_modifier(symname);
|
||||||
bc->modifiers |= WLR_MODIFIER_SHIFT;
|
if (modifier != 0) {
|
||||||
} else if (strcmp(symname, "Caps") == 0) {
|
bc->modifiers |= modifier;
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
xkb_keysym_t sym = xkb_keysym_from_name(symname,
|
xkb_keysym_t sym = xkb_keysym_from_name(symname,
|
||||||
XKB_KEYSYM_NO_FLAGS);
|
XKB_KEYSYM_NO_FLAGS);
|
||||||
|
|
|
@ -166,12 +166,17 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
|
||||||
event->orientation, event->delta);
|
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;
|
struct roots_keyboard *keyboard;
|
||||||
wl_list_for_each(keyboard, &input->keyboards, link) {
|
wl_list_for_each(keyboard, &input->keyboards, link) {
|
||||||
uint32_t modifiers =
|
uint32_t modifiers =
|
||||||
wlr_keyboard_get_modifiers(keyboard->device->keyboard);
|
wlr_keyboard_get_modifiers(keyboard->device->keyboard);
|
||||||
if ((modifiers ^ WLR_MODIFIER_LOGO) == 0) {
|
if ((modifiers ^ meta_key) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +192,7 @@ static void do_cursor_button_press(struct roots_input *input,
|
||||||
struct roots_view *view = view_at(desktop,
|
struct roots_view *view = view_at(desktop,
|
||||||
input->cursor->x, input->cursor->y, &surface, &sx, &sy);
|
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);
|
set_view_focus(input, desktop, view);
|
||||||
|
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
|
|
@ -25,8 +25,11 @@ map-to-output = VGA-1
|
||||||
# Restrict cursor movements for this mouse to concrete rectangle
|
# Restrict cursor movements for this mouse to concrete rectangle
|
||||||
geometry = 2500x800
|
geometry = 2500x800
|
||||||
|
|
||||||
|
[keyboard]
|
||||||
|
meta-key = Logo
|
||||||
|
|
||||||
# Keybindings
|
# Keybindings
|
||||||
# Maps key combinations with commands to execute
|
# Maps key combinations with commands to execute
|
||||||
# The special command "exit" stops the compositor
|
# The special command "exit" stops the compositor
|
||||||
[bindings]
|
[bindings]
|
||||||
Logo+q=exit
|
Logo+q = exit
|
||||||
|
|
Loading…
Reference in a new issue