From f14275633851b047e5aecfa6d12f160ee4c2f149 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 26 Jun 2015 08:45:29 +0200 Subject: [PATCH] Fix invisible mouse pointers on Windows. * src/w32fns.c: Include windowsx.h. (w32_wnd_proc): If the mouse moved and the mouse pointer is invisible, make it visible again even when the main (Lisp) thread is busy. * src/w32term.c (w32_toggle_invisible_pointer): Rather then garbaging the frame have the input thread call SetCursor. --- src/w32fns.c | 31 +++++++++++++++++++++++++------ src/w32term.c | 8 ++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/w32fns.c b/src/w32fns.c index 180d326bc98..836dc10118d 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -73,6 +73,7 @@ along with GNU Emacs. If not, see . */ #include #include +#include #include "font.h" #include "w32font.h" @@ -3493,13 +3494,31 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONUP); case WM_MOUSEMOVE: - /* Ignore mouse movements as long as the menu is active. These - movements are processed by the window manager anyway, and - it's wrong to handle them as if they happened on the - underlying frame. */ f = x_window_to_frame (dpyinfo, hwnd); - if (f && f->output_data.w32->menubar_active) - return 0; + if (f) + { + /* Ignore mouse movements as long as the menu is active. + These movements are processed by the window manager + anyway, and it's wrong to handle them as if they happened + on the underlying frame. */ + if (f->output_data.w32->menubar_active) + return 0; + + /* If the mouse moved, and the mouse pointer is invisible, + make it visible again. We do this here so as to be able + to show the mouse pointer even when the main + (a.k.a. "Lisp") thread is busy doing something. */ + static int last_x, last_y; + int x = GET_X_LPARAM (lParam); + int y = GET_Y_LPARAM (lParam); + + if (f->pointer_invisible + && (x != last_x || y != last_y)) + f->pointer_invisible = false; + + last_x = x; + last_y = y; + } /* If the mouse has just moved into the frame, start tracking it, so we will be notified when it leaves the frame. Mouse diff --git a/src/w32term.c b/src/w32term.c index 7c5f2db3a4c..fbd31b15de2 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -6613,14 +6613,10 @@ w32_toggle_invisible_pointer (struct frame *f, bool invisible) if (f->pointer_invisible != invisible) { f->pointer_invisible = invisible; - SET_FRAME_GARBAGED (f); + w32_define_cursor (FRAME_W32_WINDOW (f), + f->output_data.w32->current_cursor); } - if (invisible) - SetCursor (NULL); - else - SetCursor (f->output_data.w32->current_cursor); - unblock_input (); } -- 2.39.2