Ensure mouse cursor is in default state when focus is switched to the OSWindow

This commit is contained in:
Kovid Goyal
2017-12-13 08:54:11 +05:30
parent a1b4f7c92d
commit 77f0328f4f
3 changed files with 16 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;