mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
replay modifier key as well
This commit is contained in:
@@ -47,7 +47,7 @@ from .fast_data_types import (
|
||||
set_options, set_os_window_size, set_os_window_title, thread_write,
|
||||
toggle_fullscreen, toggle_maximized, toggle_secure_input,
|
||||
)
|
||||
from .key_encoding import get_name_to_functional_number_map
|
||||
from .key_encoding import get_name_to_functional_number_map, is_modifier_key
|
||||
from .keys import get_shortcut, shortcut_matches
|
||||
from .layout.base import set_layout_options
|
||||
from .notify import notification_activated
|
||||
@@ -1193,9 +1193,10 @@ class Boss:
|
||||
|
||||
if len(self.current_sequence):
|
||||
self.current_sequence.append(ev)
|
||||
if ev.action == GLFW_RELEASE:
|
||||
if ev.action == GLFW_RELEASE or is_modifier_key(ev.key):
|
||||
return True
|
||||
# For a press/repeat event, try matching with kitty bindings:
|
||||
# For a press/repeat event that's not a modifier, try matching with
|
||||
# kitty bindings:
|
||||
remaining = {}
|
||||
matched_action = None
|
||||
for seq, key_action in self.pending_sequences.items():
|
||||
|
||||
11
kitty/key_encoding.py
generated
11
kitty/key_encoding.py
generated
@@ -426,3 +426,14 @@ def decode_key_event_as_window_system_key(text: str) -> Optional[WindowSystemKey
|
||||
except Exception:
|
||||
return None
|
||||
return k.as_window_system_event()
|
||||
|
||||
|
||||
# The same as `bool is_modifier_key(key)` in key_encoding.c
|
||||
def is_modifier_key(key: int) -> bool:
|
||||
if defines.GLFW_FKEY_LEFT_SHIFT <= key <= defines.GLFW_FKEY_ISO_LEVEL5_SHIFT:
|
||||
return True
|
||||
if key == defines.GLFW_FKEY_CAPS_LOCK or \
|
||||
key == defines.GLFW_FKEY_SCROLL_LOCK or \
|
||||
key == defines.GLFW_FKEY_NUM_LOCK:
|
||||
return True
|
||||
return False
|
||||
|
||||
24
kitty/keys.c
24
kitty/keys.c
@@ -168,19 +168,17 @@ on_key_input(GLFWkeyevent *ev) {
|
||||
#define create_key_event() { ke = convert_glfw_key_event_to_python(ev); if (!ke) { PyErr_Print(); return; } }
|
||||
if (global_state.in_sequence_mode) {
|
||||
debug("in sequence mode, handling as a potential shortcut\n");
|
||||
if (!is_modifier_key(key)) {
|
||||
create_key_event();
|
||||
PyObject *ret = PyObject_CallMethod(
|
||||
global_state.boss, "process_sequence", "O", ke);
|
||||
Py_CLEAR(ke);
|
||||
if (ret == NULL) { PyErr_Print(); }
|
||||
else {
|
||||
bool consumed = ret == Py_True;
|
||||
Py_DECREF(ret);
|
||||
if (consumed && action != GLFW_RELEASE && w) {
|
||||
w->last_special_key_pressed = key;
|
||||
}
|
||||
}
|
||||
create_key_event();
|
||||
PyObject *ret = PyObject_CallMethod(
|
||||
global_state.boss, "process_sequence", "O", ke);
|
||||
Py_CLEAR(ke);
|
||||
if (ret == NULL) { PyErr_Print(); }
|
||||
else {
|
||||
bool consumed = ret == Py_True;
|
||||
Py_DECREF(ret);
|
||||
if (consumed && action != GLFW_RELEASE && w) {
|
||||
w->last_special_key_pressed = key;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user