Skip to content

Commit

Permalink
Merge branch 'fn' of https://github.com/pcc/kitty
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jun 18, 2024
2 parents 48f053b + be10006 commit fbdc2b4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions kitty/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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};
Expand Down

0 comments on commit fbdc2b4

Please sign in to comment.