From dc71d5d162a7e2e4e9e7b3e253648afd629d53ab Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Sun, 27 Aug 2023 12:27:23 +0200 Subject: [PATCH] Add callback function for mouse scroll events. See https://www.glfw.org/docs/3.3/input_guide.html#scrolling for details. This should work with a mouse scrollwheel and with touchpad gestures. --- hintview/Linux/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hintview/Linux/main.c b/hintview/Linux/main.c index 63ce023..3be9e21 100644 --- a/hintview/Linux/main.c +++ b/hintview/Linux/main.c @@ -528,6 +528,21 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) } } +void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) +{ + if (yoffset > 0.0) + { + pos=hint_page_prev(); + hint_page(); + clear_cursor(); + } else if (yoffset < 0.0) + { + pos=hint_page_next(); + hint_page(); + clear_cursor(); + } +} + void cursor_enter_callback(GLFWwindow* window, int entered) { if (entered && autoreload && new_file_time()) reload_file(); @@ -573,6 +588,7 @@ int create_window(void) glfwSetKeyCallback(window, key_callback); glfwSetCursorEnterCallback(window,cursor_enter_callback); glfwSetMouseButtonCallback(window, mouse_button_callback); + glfwSetScrollCallback(window, scroll_callback); glfwSetCursorPosCallback(window, cursor_position_callback); glfwSetCursorPos(window, px_h/2, px_v/2);