From 77f0328f4fb3cb6d0c223543e9e1475a3b229520 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 13 Dec 2017 08:54:11 +0530 Subject: [PATCH] Ensure mouse cursor is in default state when focus is switched to the OSWindow --- kitty/data-types.h | 1 + kitty/glfw.c | 5 ++++- kitty/mouse.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/kitty/data-types.h b/kitty/data-types.h index dc0ff3c62..16edf6905 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -274,6 +274,7 @@ unsigned int safe_wcwidth(uint32_t ch); void change_wcwidth(bool use9); void set_mouse_cursor(MouseShape); void mouse_event(int, int); +void focus_in_event(); void scroll_event(double, double); void fake_scroll(bool); void set_special_key_combo(int glfw_key, int mods); diff --git a/kitty/glfw.c b/kitty/glfw.c index d66614c97..c573d74ba 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -145,7 +145,10 @@ static void window_focus_callback(GLFWwindow *w, int focused) { if (!set_callback_window(w)) return; global_state.callback_os_window->is_focused = focused ? true : false; - if (focused) show_mouse_cursor(w); + if (focused) { + show_mouse_cursor(w); + focus_in_event(); + } double now = monotonic(); global_state.callback_os_window->last_mouse_activity_at = now; global_state.callback_os_window->cursor_blink_zero_time = now; diff --git a/kitty/mouse.c b/kitty/mouse.c index a73c30be7..e57410035 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -324,6 +324,17 @@ window_for_event(unsigned int *window_idx, bool *in_tab_bar) { } +void +focus_in_event() { + // Ensure that no URL is highlighted and the mouse cursor is in default shape + bool in_tab_bar; + unsigned int window_idx = 0; + mouse_cursor_shape = BEAM; + set_mouse_cursor(BEAM); + Window *w = window_for_event(&window_idx, &in_tab_bar); + if (w) screen_mark_url(w->render_data.screen, 0, 0, 0, 0); +} + void mouse_event(int button, int modifiers) { MouseShape old_cursor = mouse_cursor_shape;