Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exec release binding even if other keys were pressed #6920

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sway/input/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct sway_keyboard {
struct sway_shortcut_state state_keycodes;
struct sway_shortcut_state state_pressed_sent;
struct sway_binding *held_binding;
uint32_t held_keycode;

struct wl_event_source *key_repeat_source;
struct sway_binding *repeat_binding;
Expand Down
10 changes: 7 additions & 3 deletions sway/input/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,21 @@ static void handle_key_event(struct sway_keyboard *keyboard,
shortcuts_inhibited, device_identifier,
exact_identifier, keyboard->effective_layout);

// Execute stored release binding once no longer active
if (keyboard->held_binding && binding_released != keyboard->held_binding &&
// Execute stored release binding when the key is released
if (keyboard->held_binding &&
keyinfo.keycode == keyboard->held_keycode &&
event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
seat_execute_command(seat, keyboard->held_binding);
handled = true;
}
if (binding_released != keyboard->held_binding) {
if (handled ||
(binding_released && binding_released != keyboard->held_binding)) {
keyboard->held_binding = NULL;
keyboard->held_keycode = 0;
}
if (binding_released && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
keyboard->held_binding = binding_released;
keyboard->held_keycode = keyinfo.keycode;
}

// Identify and execute active pressed binding
Expand Down