mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 10:41:58 +02:00
Basic changes for new glfw keyboard API
This commit is contained in:
@@ -266,5 +266,5 @@ void scroll_event(double, double);
|
|||||||
void fake_scroll(int, bool);
|
void fake_scroll(int, bool);
|
||||||
void set_special_key_combo(int glfw_key, int mods);
|
void set_special_key_combo(int glfw_key, int mods);
|
||||||
void on_text_input(unsigned int codepoint, int mods);
|
void on_text_input(unsigned int codepoint, int mods);
|
||||||
void on_key_input(int key, int scancode, int action, int mods);
|
void on_key_input(int key, int scancode, int action, int mods, const char*, int);
|
||||||
void request_window_attention(id_type, bool);
|
void request_window_attention(id_type, bool);
|
||||||
|
|||||||
15
kitty/glfw.c
15
kitty/glfw.c
@@ -96,20 +96,12 @@ refresh_callback(GLFWwindow *w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
char_mods_callback(GLFWwindow *w, unsigned int codepoint, int mods) {
|
key_callback(GLFWwindow *w, int key, int scancode, int action, int mods, const char* text, int state) {
|
||||||
if (!set_callback_window(w)) return;
|
|
||||||
global_state.callback_os_window->cursor_blink_zero_time = monotonic();
|
|
||||||
if (is_window_ready_for_callbacks()) on_text_input(codepoint, mods);
|
|
||||||
global_state.callback_os_window = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
key_callback(GLFWwindow *w, int key, int scancode, int action, int mods) {
|
|
||||||
if (!set_callback_window(w)) return;
|
if (!set_callback_window(w)) return;
|
||||||
global_state.callback_os_window->cursor_blink_zero_time = monotonic();
|
global_state.callback_os_window->cursor_blink_zero_time = monotonic();
|
||||||
if (key >= 0 && key <= GLFW_KEY_LAST) {
|
if (key >= 0 && key <= GLFW_KEY_LAST) {
|
||||||
global_state.callback_os_window->is_key_pressed[key] = action == GLFW_RELEASE ? false : true;
|
global_state.callback_os_window->is_key_pressed[key] = action == GLFW_RELEASE ? false : true;
|
||||||
if (is_window_ready_for_callbacks()) on_key_input(key, scancode, action, mods);
|
if (is_window_ready_for_callbacks()) on_key_input(key, scancode, action, mods, text, state);
|
||||||
}
|
}
|
||||||
global_state.callback_os_window = NULL;
|
global_state.callback_os_window = NULL;
|
||||||
}
|
}
|
||||||
@@ -375,11 +367,10 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
|||||||
update_os_window_viewport(w, false);
|
update_os_window_viewport(w, false);
|
||||||
glfwSetFramebufferSizeCallback(glfw_window, framebuffer_size_callback);
|
glfwSetFramebufferSizeCallback(glfw_window, framebuffer_size_callback);
|
||||||
glfwSetWindowRefreshCallback(glfw_window, refresh_callback);
|
glfwSetWindowRefreshCallback(glfw_window, refresh_callback);
|
||||||
glfwSetCharModsCallback(glfw_window, char_mods_callback);
|
|
||||||
glfwSetMouseButtonCallback(glfw_window, mouse_button_callback);
|
glfwSetMouseButtonCallback(glfw_window, mouse_button_callback);
|
||||||
glfwSetScrollCallback(glfw_window, scroll_callback);
|
glfwSetScrollCallback(glfw_window, scroll_callback);
|
||||||
glfwSetCursorPosCallback(glfw_window, cursor_pos_callback);
|
glfwSetCursorPosCallback(glfw_window, cursor_pos_callback);
|
||||||
glfwSetKeyCallback(glfw_window, key_callback);
|
glfwSetKeyboardCallback(glfw_window, key_callback);
|
||||||
glfwSetWindowFocusCallback(glfw_window, window_focus_callback);
|
glfwSetWindowFocusCallback(glfw_window, window_focus_callback);
|
||||||
glfwSetDropCallback(glfw_window, drop_callback);
|
glfwSetDropCallback(glfw_window, drop_callback);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|||||||
@@ -153,9 +153,10 @@ send_key_to_child(Window *w, int key, int mods, int action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_key_input(int key, int scancode, int action, int mods) {
|
on_key_input(int key, int scancode, int action, int mods, const char* text, int state) {
|
||||||
Window *w = active_window();
|
Window *w = active_window();
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
|
(void)state; (void)text;
|
||||||
Screen *screen = w->render_data.screen;
|
Screen *screen = w->render_data.screen;
|
||||||
int lkey = get_localized_key(key, scancode);
|
int lkey = get_localized_key(key, scancode);
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user