mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-11 19:19:35 +02:00
Prevent Fn key from scrolling to the bottom
When the Fn key is pressed it should not cause us to scroll to the bottom of the scrollback. This is because Fn may be used to access movement keys (e.g. on a MacBook keyboard, Fn+Up = Page Up). Most keyboards do not expose Fn to the operating system as a separate key event, but there are two known exceptions: Macs running Linux (generates XF86Fn) and some ThinkPads (generates XF86WakeUp). Ignore both key events when deciding whether to scroll to the bottom. For consistency, do the same when deciding whether key events should hide the mouse.
This commit is contained in:
21
kitty/keys.c
21
kitty/keys.c
@@ -11,6 +11,10 @@
|
||||
#include "glfw-wrapper.h"
|
||||
#include <structmember.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#endif
|
||||
|
||||
// python KeyEvent object {{{
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
@@ -44,6 +48,19 @@ is_modifier_key(const uint32_t key) {
|
||||
END_ALLOW_CASE_RANGE
|
||||
}
|
||||
|
||||
static bool
|
||||
is_no_action_key(const uint32_t key, const uint32_t native_key) {
|
||||
switch (native_key) {
|
||||
#ifndef __APPLE__
|
||||
case XKB_KEY_XF86Fn:
|
||||
case XKB_KEY_XF86WakeUp:
|
||||
return true;
|
||||
#endif
|
||||
default:
|
||||
return is_modifier_key(key);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dealloc(PyKeyEvent* self) {
|
||||
Py_CLEAR(self->key); Py_CLEAR(self->shifted_key); Py_CLEAR(self->alternate_key);
|
||||
@@ -163,7 +180,7 @@ on_key_input(GLFWkeyevent *ev) {
|
||||
}
|
||||
}
|
||||
if (!w) { debug("no active window, ignoring\n"); return; }
|
||||
if (OPT(mouse_hide_wait) < 0 && !is_modifier_key(key)) hide_mouse(global_state.callback_os_window);
|
||||
if (OPT(mouse_hide_wait) < 0 && !is_no_action_key(key, native_key)) hide_mouse(global_state.callback_os_window);
|
||||
Screen *screen = w->render_data.screen;
|
||||
id_type active_window_id = w->id;
|
||||
|
||||
@@ -227,7 +244,7 @@ on_key_input(GLFWkeyevent *ev) {
|
||||
debug("discarding repeat key event as DECARM is off\n");
|
||||
return;
|
||||
}
|
||||
if (screen->scrolled_by && action == GLFW_PRESS && !is_modifier_key(key)) {
|
||||
if (screen->scrolled_by && action == GLFW_PRESS && !is_no_action_key(key, native_key)) {
|
||||
screen_history_scroll(screen, SCROLL_FULL, false); // scroll back to bottom
|
||||
}
|
||||
char encoded_key[KEY_BUFFER_SIZE] = {0};
|
||||
|
||||
Reference in New Issue
Block a user