From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: make-pointer-invisible on Windows Date: Thu, 25 Jun 2015 18:02:25 +0300 Message-ID: <83a8vnesqm.fsf@gnu.org> References: <558A75C6.7040003@gmx.at> <83zj3pdusu.fsf@gnu.org> <558AEB8D.4070603@gmx.at> <83k2usewtv.fsf@gnu.org> <558BA156.6090508@gmx.at> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1435244592 11749 80.91.229.3 (25 Jun 2015 15:03:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Jun 2015 15:03:12 +0000 (UTC) Cc: emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 25 17:03:03 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z88g9-0007Jv-F2 for ged-emacs-devel@m.gmane.org; Thu, 25 Jun 2015 17:03:01 +0200 Original-Received: from localhost ([::1]:56126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z88g8-0001KW-T8 for ged-emacs-devel@m.gmane.org; Thu, 25 Jun 2015 11:03:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z88fo-0001BZ-2P for emacs-devel@gnu.org; Thu, 25 Jun 2015 11:02:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z88fj-0003o2-3Z for emacs-devel@gnu.org; Thu, 25 Jun 2015 11:02:40 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:45028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z88fi-0003n6-Mu for emacs-devel@gnu.org; Thu, 25 Jun 2015 11:02:35 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NQI008009QMAO00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Thu, 25 Jun 2015 18:02:33 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NQI0077A9S8UKA0@a-mtaout22.012.net.il>; Thu, 25 Jun 2015 18:02:32 +0300 (IDT) In-reply-to: <558BA156.6090508@gmx.at> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187518 Archived-At: > Date: Thu, 25 Jun 2015 08:36:06 +0200 > From: martin rudalics > CC: emacs-devel@gnu.org > > > There are less radical ways of triggering more thorough redisplay, > > than redrawing the whole frame. I will look into this when I have > > time, if no one beats me to it. > > Please do that. It turns out this has nothing to do with redisplay. Inserting a single character is enough to turn off the mouse pointer with your original patch, after removing the call to SET_FRAME_GARBAGED. The problem is that sometimes the effect is far from immediate, you need to wait for a second or so. Looking into this, I concluded that calling SetCursor from the main (a.k.a. "Lisp") thread has no effect whatsoever. For some reason, only the input thread can do that. And it already does, whenever it gets an appropriate message. So all we have to do in the main thread is send that message to the input thread. This is what the first hunk below, to be applied on top of your patch, does. > >> > Also, what about the equivalent of the X code that makes the pointer > >> > visible on focus-in events -- don't we need that on MS-Windows? > >> > >> I don't know. It's certainly not necessary on XP here. People would > >> have to try though. In general, it seems that X and Windows differ > >> quite substantially in their respective behaviors. For example, on X, > >> when a synchronous shell operation is active, the cursor becomes visible > >> as soon as the mouse is moved. On Windows, the cursor remains invisible > >> until the shell operation terminates and the frame gets redrawn > >> (obviously, the frame doesn't look very decent in that period either, so > >> there are worse problems). > > > > I don't think this is related to the issue at hand. > > I don't think so either. My point was that X and Windows run into > different problems when trying to make the pointer invisible. Well, actually, it _is_ related, albeit to a different aspect of this. The code that turns the mouse pointer back on when mouse moves also runs in the main thread. So whenever the main thread is busy with some long calculation, or waits for some synchronous system call, we cannot rely on this mechanism to timely turn the pointer back on. But the input thread can very well do that, so the second hunk of changes below makes that happen. So please install your changes, followed by mine (or tell me to do the latter). Thanks for working on this. As for not redrawing the frame during these synchronous operations, I will try to see why it happens (strangely, I only see it on XP, but not on Windows 7). --- src/w32term.c~0 2015-06-25 12:10:25 +0300 +++ src/w32term.c 2015-06-25 17:52:04 +0300 @@ -6613,14 +6613,10 @@ w32_toggle_invisible_pointer (struct fra 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 (); } --- src/w32fns.c~0 2015-06-25 12:29:41 +0300 +++ src/w32fns.c 2015-06-25 17:50:19 +0300 @@ -73,6 +73,7 @@ along with GNU Emacs. If not, see #include +#include #include "font.h" #include "w32font.h" @@ -3492,13 +3493,31 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARA 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