From 65f9ac32ef1edf2ca17791b40a75b5efe7a7dfdd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Oct 2018 14:01:55 +0530 Subject: [PATCH] Fix :opt:`mouse_hide_wait` only taking effect after an event such as cursor blink or key press Fixes #1073 --- docs/changelog.rst | 3 +++ kitty/child-monitor.c | 5 ++++- kitty/glfw.c | 6 ++++++ kitty/state.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 4fe64e360..0f00782fc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,9 @@ Changelog - Fix expansion of env vars not working in the :opt:`env` directive (:iss:`1075`) +- Fix :opt:`mouse_hide_wait` only taking effect after an event such as cursor + blink or key press (:iss:`1073`) + 0.12.3 [2018-09-29] ------------------------------ diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 063baa0a6..225abdad8 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -565,7 +565,10 @@ prepare_to_render_os_window(OSWindow *os_window, double now, unsigned int *activ } if (send_cell_data_to_gpu(TD.vao_idx, 0, TD.xstart, TD.ystart, TD.dx, TD.dy, TD.screen, os_window)) needs_render = true; } - if (OPT(mouse_hide_wait) > 0 && now - os_window->last_mouse_activity_at > OPT(mouse_hide_wait)) hide_mouse(os_window); + if (OPT(mouse_hide_wait) > 0 && !is_mouse_hidden(os_window)) { + if (now - os_window->last_mouse_activity_at >= OPT(mouse_hide_wait)) hide_mouse(os_window); + else set_maximum_wait(OPT(mouse_hide_wait) - now + os_window->last_mouse_activity_at); + } Tab *tab = os_window->tabs + os_window->active_tab; *active_window_bg = OPT(background); for (unsigned int i = 0; i < tab->num_windows; i++) { diff --git a/kitty/glfw.c b/kitty/glfw.c index 13ebddd99..74063c3e2 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -808,6 +808,12 @@ hide_mouse(OSWindow *w) { glfwSetInputMode(w->handle, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); } +bool +is_mouse_hidden(OSWindow *w) { + return w->handle && glfwGetInputMode(w->handle, GLFW_CURSOR) == GLFW_CURSOR_HIDDEN; +} + + void swap_window_buffers(OSWindow *w) { #ifdef __APPLE__ diff --git a/kitty/state.h b/kitty/state.h index 95cd2dcec..8cad2e058 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -173,6 +173,7 @@ void event_loop_wait(double timeout); void swap_window_buffers(OSWindow *w); void make_window_context_current(OSWindow *w); void hide_mouse(OSWindow *w); +bool is_mouse_hidden(OSWindow *w); void destroy_os_window(OSWindow *w); void focus_os_window(OSWindow *w, bool also_raise); void set_os_window_title(OSWindow *w, const char *title);