Report modifier key state when sending wheel events to the terminal program

This commit is contained in:
Kovid Goyal 2020-04-29 20:02:55 +05:30
parent b541341681
commit aa9c3cd634
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
11 changed files with 20 additions and 16 deletions

View File

@ -19,6 +19,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- macOS: Fix a regression that broke drag and drop (:iss:`2605`) - macOS: Fix a regression that broke drag and drop (:iss:`2605`)
- Report modifier key state when sending wheel events to the terminal program
0.17.3 [2020-04-23] 0.17.3 [2020-04-23]
-------------------- --------------------

View File

@ -1133,7 +1133,7 @@ is_ascii_control_char(char x) {
break; break;
} }
_glfwInputScroll(window, deltaX, deltaY, flags); _glfwInputScroll(window, deltaX, deltaY, flags, translateFlags([event modifierFlags]));
} }
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender

3
glfw/glfw3.h vendored
View File

@ -1550,6 +1550,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
* value 2 for stationary momentum scrolling, value 3 for momentum scrolling * value 2 for stationary momentum scrolling, value 3 for momentum scrolling
* in progress, value 4 for momentum scrolling ended, value 5 for momentum * in progress, value 4 for momentum scrolling ended, value 5 for momentum
* scrolling cancelled and value 6 if scrolling may begin soon. * scrolling cancelled and value 6 if scrolling may begin soon.
* @param[int] mods The keyboard modifiers
* *
* @sa @ref scrolling * @sa @ref scrolling
* @sa @ref glfwSetScrollCallback * @sa @ref glfwSetScrollCallback
@ -1559,7 +1560,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
* *
* @ingroup input * @ingroup input
*/ */
typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int); typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int,int);
/*! @brief The function pointer type for key callbacks. /*! @brief The function pointer type for key callbacks.
* *

4
glfw/input.c vendored
View File

@ -300,10 +300,10 @@ void _glfwInputKeyboard(_GLFWwindow* window, GLFWkeyevent* ev)
// Notifies shared code of a scroll event // Notifies shared code of a scroll event
// //
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags) void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags, int mods)
{ {
if (window->callbacks.scroll) if (window->callbacks.scroll)
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset, flags); window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset, flags, mods);
} }
// Notifies shared code of a mouse button click event // Notifies shared code of a mouse button click event

2
glfw/internal.h vendored
View File

@ -755,7 +755,7 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
void _glfwInitializeKeyEvent(GLFWkeyevent *ev, int key, int native_key, int action, int mods); void _glfwInitializeKeyEvent(GLFWkeyevent *ev, int key, int native_key, int action, int mods);
void _glfwInputKeyboard(_GLFWwindow *window, GLFWkeyevent *ev); void _glfwInputKeyboard(_GLFWwindow *window, GLFWkeyevent *ev);
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags); void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags, int mods);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
void _glfwInputCursorEnter(_GLFWwindow* window, bool entered); void _glfwInputCursorEnter(_GLFWwindow* window, bool entered);

2
glfw/wl_init.c vendored
View File

@ -334,7 +334,7 @@ static void pointerHandleAxis(void* data UNUSED,
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
y = wl_fixed_to_double(value) * -1; y = wl_fixed_to_double(value) * -1;
_glfwInputScroll(window, x, y, 1); _glfwInputScroll(window, x, y, 1, _glfw.wl.xkb.states.modifiers);
} }
static const struct wl_pointer_listener pointerListener = { static const struct wl_pointer_listener pointerListener = {

8
glfw/x11_window.c vendored
View File

@ -1265,13 +1265,13 @@ static void processEvent(XEvent *event)
// Modern X provides scroll events as mouse button presses // Modern X provides scroll events as mouse button presses
else if (event->xbutton.button == Button4) else if (event->xbutton.button == Button4)
_glfwInputScroll(window, 0.0, 1.0, 0); _glfwInputScroll(window, 0.0, 1.0, 0, mods);
else if (event->xbutton.button == Button5) else if (event->xbutton.button == Button5)
_glfwInputScroll(window, 0.0, -1.0, 0); _glfwInputScroll(window, 0.0, -1.0, 0, mods);
else if (event->xbutton.button == Button6) else if (event->xbutton.button == Button6)
_glfwInputScroll(window, 1.0, 0.0, 0); _glfwInputScroll(window, 1.0, 0.0, 0, mods);
else if (event->xbutton.button == Button7) else if (event->xbutton.button == Button7)
_glfwInputScroll(window, -1.0, 0.0, 0); _glfwInputScroll(window, -1.0, 0.0, 0, mods);
else else
{ {

View File

@ -313,7 +313,7 @@ void set_mouse_cursor(MouseShape);
void enter_event(void); void enter_event(void);
void mouse_event(int, int, int); void mouse_event(int, int, int);
void focus_in_event(void); void focus_in_event(void);
void scroll_event(double, double, int); void scroll_event(double, double, int, int);
void fake_scroll(int, bool); void fake_scroll(int, bool);
void set_special_key_combo(int glfw_key, int mods, bool is_native); void set_special_key_combo(int glfw_key, int mods, bool is_native);
void on_key_input(GLFWkeyevent *ev); void on_key_input(GLFWkeyevent *ev);

3
kitty/glfw-wrapper.h generated
View File

@ -1313,6 +1313,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
* value 2 for stationary momentum scrolling, value 3 for momentum scrolling * value 2 for stationary momentum scrolling, value 3 for momentum scrolling
* in progress, value 4 for momentum scrolling ended, value 5 for momentum * in progress, value 4 for momentum scrolling ended, value 5 for momentum
* scrolling cancelled and value 6 if scrolling may begin soon. * scrolling cancelled and value 6 if scrolling may begin soon.
* @param[int] mods The keyboard modifiers
* *
* @sa @ref scrolling * @sa @ref scrolling
* @sa @ref glfwSetScrollCallback * @sa @ref glfwSetScrollCallback
@ -1322,7 +1323,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
* *
* @ingroup input * @ingroup input
*/ */
typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int); typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int,int);
/*! @brief The function pointer type for key callbacks. /*! @brief The function pointer type for key callbacks.
* *

View File

@ -287,12 +287,12 @@ cursor_pos_callback(GLFWwindow *w, double x, double y) {
} }
static void static void
scroll_callback(GLFWwindow *w, double xoffset, double yoffset, int flags) { scroll_callback(GLFWwindow *w, double xoffset, double yoffset, int flags, int mods) {
if (!set_callback_window(w)) return; if (!set_callback_window(w)) return;
show_mouse_cursor(w); show_mouse_cursor(w);
monotonic_t now = monotonic(); monotonic_t now = monotonic();
global_state.callback_os_window->last_mouse_activity_at = now; global_state.callback_os_window->last_mouse_activity_at = now;
if (is_window_ready_for_callbacks()) scroll_event(xoffset, yoffset, flags); if (is_window_ready_for_callbacks()) scroll_event(xoffset, yoffset, flags, mods);
request_tick_callback(); request_tick_callback();
global_state.callback_os_window = NULL; global_state.callback_os_window = NULL;
} }

View File

@ -613,7 +613,7 @@ mouse_event(int button, int modifiers, int action) {
} }
void void
scroll_event(double UNUSED xoffset, double yoffset, int flags) { scroll_event(double UNUSED xoffset, double yoffset, int flags, int modifiers) {
bool in_tab_bar; bool in_tab_bar;
static id_type window_for_momentum_scroll = 0; static id_type window_for_momentum_scroll = 0;
static bool main_screen_for_momentum_scroll = false; static bool main_screen_for_momentum_scroll = false;
@ -690,7 +690,7 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags) {
screen_history_scroll(screen, abs(s), upwards); screen_history_scroll(screen, abs(s), upwards);
} else { } else {
if (screen->modes.mouse_tracking_mode) { if (screen->modes.mouse_tracking_mode) {
int sz = encode_mouse_event(w, upwards ? GLFW_MOUSE_BUTTON_4 : GLFW_MOUSE_BUTTON_5, PRESS, 0); int sz = encode_mouse_event(w, upwards ? GLFW_MOUSE_BUTTON_4 : GLFW_MOUSE_BUTTON_5, PRESS, modifiers);
if (sz > 0) { if (sz > 0) {
mouse_event_buf[sz] = 0; mouse_event_buf[sz] = 0;
for (s = abs(s); s > 0; s--) { for (s = abs(s); s > 0; s--) {