Take the mouse wheel multiplier into account when generating keypresses for mouse wheel events. Fixes #262

This commit is contained in:
Kovid Goyal
2018-01-04 12:34:31 +05:30
parent 0305009766
commit 847ce37160
3 changed files with 7 additions and 5 deletions

View File

@@ -278,7 +278,7 @@ void mouse_event(int, int);
void focus_in_event();
void wakeup_io_loop(bool);
void scroll_event(double, double);
void fake_scroll(bool);
void fake_scroll(int, bool);
void set_special_key_combo(int glfw_key, int mods);
void on_text_input(unsigned int codepoint, int mods);
void on_key_input(int key, int scancode, int action, int mods);

View File

@@ -188,12 +188,14 @@ on_key_input(int key, int scancode, int action, int mods) {
}
void
fake_scroll(bool upwards) {
fake_scroll(int amount, bool upwards) {
Window *w = active_window();
if (!w) return;
Screen *screen = w->render_data.screen;
send_key_to_child(w, upwards ? GLFW_KEY_UP : GLFW_KEY_DOWN, 0, GLFW_PRESS);
if (screen->modes.mEXTENDED_KEYBOARD) send_key_to_child(w, upwards ? GLFW_KEY_UP : GLFW_KEY_DOWN, 0, GLFW_RELEASE);
while (amount-- > 0) {
send_key_to_child(w, upwards ? GLFW_KEY_UP : GLFW_KEY_DOWN, 0, GLFW_PRESS);
if (screen->modes.mEXTENDED_KEYBOARD) send_key_to_child(w, upwards ? GLFW_KEY_UP : GLFW_KEY_DOWN, 0, GLFW_RELEASE);
}
}
#define PYWRAP1(name) static PyObject* py##name(PyObject UNUSED *self, PyObject *args)

View File

@@ -375,7 +375,7 @@ scroll_event(double UNUSED xoffset, double yoffset) {
int sz = encode_mouse_event(w, upwards ? GLFW_MOUSE_BUTTON_4 : GLFW_MOUSE_BUTTON_5, PRESS, 0);
if (sz > 0) { mouse_event_buf[sz] = 0; write_escape_code_to_child(screen, CSI, mouse_event_buf); }
} else {
fake_scroll(upwards);
fake_scroll(abs(s), upwards);
}
}
}