mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
keybind: implement allowWhenLocked
fixes #2034
see bc258a3be2/sway/sway.5.scd (L409)
This commit is contained in:
parent
6dd0d69889
commit
116382fd89
4 changed files with 21 additions and 16 deletions
|
|
@ -499,7 +499,7 @@ extending outward from the snapped edge.
|
|||
Stores the keyboard layout either globally or per window and restores
|
||||
it when switching back to the window. Default is global.
|
||||
|
||||
*<keyboard><keybind key="" layoutDependent="" onRelease="">*
|
||||
*<keyboard><keybind key="" layoutDependent="" onRelease="" allowWhenLocked="">*
|
||||
Define a *key* binding in the format *modifier-key*, where supported
|
||||
modifiers are:
|
||||
- S (shift)
|
||||
|
|
@ -541,6 +541,9 @@ extending outward from the snapped edge.
|
|||
</keybind>
|
||||
```
|
||||
|
||||
*allowWhenLocked* [yes|no]
|
||||
Make this keybind work even if the screen is locked. Default is no.
|
||||
|
||||
*<keyboard><keybind key=""><action name="">*
|
||||
Keybind action. See labwc-actions(5).
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ struct keybind {
|
|||
xkb_keycode_t keycodes[MAX_KEYCODES];
|
||||
size_t keycodes_len;
|
||||
int keycodes_layout;
|
||||
bool allow_when_locked;
|
||||
struct wl_list actions; /* struct action.link */
|
||||
struct wl_list link; /* struct rcxml.keybinds */
|
||||
bool on_release;
|
||||
|
|
|
|||
|
|
@ -407,6 +407,8 @@ fill_keybind(char *nodename, char *content)
|
|||
set_bool(content, ¤t_keybind->on_release);
|
||||
} else if (!strcasecmp(nodename, "layoutDependent")) {
|
||||
set_bool(content, ¤t_keybind->use_syms_only);
|
||||
} else if (!strcasecmp(nodename, "allowWhenLocked")) {
|
||||
set_bool(content, ¤t_keybind->allow_when_locked);
|
||||
} else if (!strcmp(nodename, "name.action")) {
|
||||
current_keybind_action = action_create(content);
|
||||
if (current_keybind_action) {
|
||||
|
|
|
|||
|
|
@ -449,6 +449,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
struct server *server = seat->server;
|
||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||
struct keyinfo keyinfo = get_keyinfo(wlr_keyboard, event->keycode);
|
||||
bool locked = seat->server->session_lock_manager->locked;
|
||||
|
||||
key_state_set_pressed(event->keycode,
|
||||
event->state == WL_KEYBOARD_KEY_STATE_PRESSED,
|
||||
|
|
@ -457,7 +458,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||
if (cur_keybind && cur_keybind->on_release) {
|
||||
key_state_bound_key_remove(event->keycode);
|
||||
if (seat->server->session_lock_manager->locked) {
|
||||
if (locked && !cur_keybind->allow_when_locked) {
|
||||
cur_keybind = NULL;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -479,27 +480,25 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
* It's important to do this after key_state_set_pressed() to ensure
|
||||
* _all_ key press/releases are registered
|
||||
*/
|
||||
if (seat->server->session_lock_manager->locked) {
|
||||
return false;
|
||||
}
|
||||
if (!locked) {
|
||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
handle_menu_keys(server, &keyinfo.translated);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
handle_menu_keys(server, &keyinfo.translated);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (server->osd_state.cycle_view) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
handle_cycle_view_key(server, &keyinfo);
|
||||
return true;
|
||||
if (server->osd_state.cycle_view) {
|
||||
key_state_store_pressed_key_as_bound(event->keycode);
|
||||
handle_cycle_view_key(server, &keyinfo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle compositor keybinds
|
||||
*/
|
||||
cur_keybind = match_keybinding(server, &keyinfo, keyboard->is_virtual);
|
||||
if (cur_keybind) {
|
||||
if (cur_keybind && (!locked || cur_keybind->allow_when_locked)) {
|
||||
/*
|
||||
* Update key-state before action_run() because the action
|
||||
* might lead to seat_focus() in which case we pass the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue