mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
Merge branch 'modkeys' into magnifier
This commit is contained in:
commit
9a2279ef7b
4 changed files with 31 additions and 7 deletions
|
|
@ -20,6 +20,7 @@ struct keybind {
|
||||||
int keycodes_layout;
|
int keycodes_layout;
|
||||||
struct wl_list actions; /* struct action.link */
|
struct wl_list actions; /* struct action.link */
|
||||||
struct wl_list link; /* struct rcxml.keybinds */
|
struct wl_list link; /* struct rcxml.keybinds */
|
||||||
|
bool mod_only; /* set if only modifier keys used */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,6 @@ void keyboard_set_numlock(struct wlr_keyboard *keyboard);
|
||||||
void keyboard_update_layout(struct seat *seat, xkb_layout_index_t layout);
|
void keyboard_update_layout(struct seat *seat, xkb_layout_index_t layout);
|
||||||
void keyboard_cancel_keybind_repeat(struct keyboard *keyboard);
|
void keyboard_cancel_keybind_repeat(struct keyboard *keyboard);
|
||||||
bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard);
|
bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard);
|
||||||
|
bool keyboard_is_modifier_key(xkb_keysym_t sym);
|
||||||
|
|
||||||
#endif /* LABWC_KEYBOARD_H */
|
#endif /* LABWC_KEYBOARD_H */
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "config/keybind.h"
|
#include "config/keybind.h"
|
||||||
#include "config/rcxml.h"
|
#include "config/rcxml.h"
|
||||||
|
#include "input/keyboard.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
@ -121,6 +122,7 @@ keybind_create(const char *keybind)
|
||||||
xkb_keysym_t sym;
|
xkb_keysym_t sym;
|
||||||
struct keybind *k = znew(*k);
|
struct keybind *k = znew(*k);
|
||||||
xkb_keysym_t keysyms[MAX_KEYSYMS];
|
xkb_keysym_t keysyms[MAX_KEYSYMS];
|
||||||
|
bool mod_only = TRUE;
|
||||||
gchar **symnames = g_strsplit(keybind, "-", -1);
|
gchar **symnames = g_strsplit(keybind, "-", -1);
|
||||||
for (size_t i = 0; symnames[i]; i++) {
|
for (size_t i = 0; symnames[i]; i++) {
|
||||||
char *symname = symnames[i];
|
char *symname = symnames[i];
|
||||||
|
|
@ -129,6 +131,9 @@ keybind_create(const char *keybind)
|
||||||
k->modifiers |= modifier;
|
k->modifiers |= modifier;
|
||||||
} else {
|
} else {
|
||||||
sym = xkb_keysym_from_name(symname, XKB_KEYSYM_CASE_INSENSITIVE);
|
sym = xkb_keysym_from_name(symname, XKB_KEYSYM_CASE_INSENSITIVE);
|
||||||
|
if (!keyboard_is_modifier_key(sym)) {
|
||||||
|
mod_only = FALSE;
|
||||||
|
}
|
||||||
if (sym == XKB_KEY_NoSymbol && g_utf8_strlen(symname, -1) == 1) {
|
if (sym == XKB_KEY_NoSymbol && g_utf8_strlen(symname, -1) == 1) {
|
||||||
/*
|
/*
|
||||||
* xkb_keysym_from_name() only handles a legacy set of single
|
* xkb_keysym_from_name() only handles a legacy set of single
|
||||||
|
|
@ -163,6 +168,7 @@ keybind_create(const char *keybind)
|
||||||
if (!k) {
|
if (!k) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
k->mod_only = mod_only;
|
||||||
wl_list_append(&rc.keybinds, &k->link);
|
wl_list_append(&rc.keybinds, &k->link);
|
||||||
k->keysyms = xmalloc(k->keysyms_len * sizeof(xkb_keysym_t));
|
k->keysyms = xmalloc(k->keysyms_len * sizeof(xkb_keysym_t));
|
||||||
memcpy(k->keysyms, keysyms, k->keysyms_len * sizeof(xkb_keysym_t));
|
memcpy(k->keysyms, keysyms, k->keysyms_len * sizeof(xkb_keysym_t));
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ struct keyinfo {
|
||||||
|
|
||||||
static bool should_cancel_cycling_on_next_key_release;
|
static bool should_cancel_cycling_on_next_key_release;
|
||||||
|
|
||||||
|
struct keybind *cur_keybind;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
change_vt(struct server *server, unsigned int vt)
|
change_vt(struct server *server, unsigned int vt)
|
||||||
{
|
{
|
||||||
|
|
@ -207,8 +209,8 @@ process_syms:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
is_modifier_key(xkb_keysym_t sym)
|
keyboard_is_modifier_key(xkb_keysym_t sym)
|
||||||
{
|
{
|
||||||
switch (sym) {
|
switch (sym) {
|
||||||
case XKB_KEY_Shift_L: case XKB_KEY_Shift_R:
|
case XKB_KEY_Shift_L: case XKB_KEY_Shift_R:
|
||||||
|
|
@ -273,7 +275,7 @@ get_keyinfo(struct wlr_keyboard *wlr_keyboard, uint32_t evdev_keycode)
|
||||||
keyinfo.is_modifier = false;
|
keyinfo.is_modifier = false;
|
||||||
for (int i = 0; i < keyinfo.translated.nr_syms; i++) {
|
for (int i = 0; i < keyinfo.translated.nr_syms; i++) {
|
||||||
keyinfo.is_modifier |=
|
keyinfo.is_modifier |=
|
||||||
is_modifier_key(keyinfo.translated.syms[i]);
|
keyboard_is_modifier_key(keyinfo.translated.syms[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyinfo;
|
return keyinfo;
|
||||||
|
|
@ -407,8 +409,19 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
||||||
keyinfo.is_modifier);
|
keyinfo.is_modifier);
|
||||||
|
|
||||||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||||
|
if (cur_keybind && cur_keybind->mod_only) {
|
||||||
|
if (seat->active_client_while_inhibited
|
||||||
|
|| seat->server->session_lock) {
|
||||||
|
cur_keybind = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
actions_run(NULL, server, &cur_keybind->actions, 0);
|
||||||
|
cur_keybind = NULL;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
return handle_key_release(server, event->keycode);
|
return handle_key_release(server, event->keycode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Catch C-A-F1 to C-A-F12 to change tty */
|
/* Catch C-A-F1 to C-A-F12 to change tty */
|
||||||
if (handle_change_vt_key(server, keyboard, &keyinfo.translated)) {
|
if (handle_change_vt_key(server, keyboard, &keyinfo.translated)) {
|
||||||
|
|
@ -443,16 +456,19 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
||||||
/*
|
/*
|
||||||
* Handle compositor keybinds
|
* Handle compositor keybinds
|
||||||
*/
|
*/
|
||||||
struct keybind *keybind =
|
cur_keybind =
|
||||||
match_keybinding(server, &keyinfo, keyboard->is_virtual);
|
match_keybinding(server, &keyinfo, keyboard->is_virtual);
|
||||||
if (keybind) {
|
if (cur_keybind) {
|
||||||
/*
|
/*
|
||||||
* Update key-state before action_run() because the action
|
* Update key-state before action_run() because the action
|
||||||
* might lead to seat_focus() in which case we pass the
|
* might lead to seat_focus() in which case we pass the
|
||||||
* 'pressed-sent' keys to the new surface.
|
* 'pressed-sent' keys to the new surface.
|
||||||
*/
|
*/
|
||||||
key_state_store_pressed_key_as_bound(event->keycode);
|
key_state_store_pressed_key_as_bound(event->keycode);
|
||||||
actions_run(NULL, server, &keybind->actions, 0);
|
if (!cur_keybind->mod_only) {
|
||||||
|
actions_run(NULL, server, &cur_keybind->actions, 0);
|
||||||
|
cur_keybind = NULL;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue