From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Simplification to mouse-avoidance-mode (patch) + redisplay bug? Date: Thu, 11 May 2006 12:03:15 +0200 Message-ID: References: <4462ECD7.7020106@swipnet.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1147341922 11961 80.91.229.2 (11 May 2006 10:05:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 May 2006 10:05:22 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 11 12:05:20 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fe82k-0007yS-LZ for ged-emacs-devel@m.gmane.org; Thu, 11 May 2006 12:05:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fe82k-0006uJ-86 for ged-emacs-devel@m.gmane.org; Thu, 11 May 2006 06:05:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fe82W-0006to-2J for emacs-devel@gnu.org; Thu, 11 May 2006 06:05:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fe82U-0006tT-VZ for emacs-devel@gnu.org; Thu, 11 May 2006 06:04:59 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fe82U-0006tN-MZ for emacs-devel@gnu.org; Thu, 11 May 2006 06:04:58 -0400 Original-Received: from [195.41.46.236] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fe83w-0004Jj-5D; Thu, 11 May 2006 06:06:28 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepb.post.tele.dk (Postfix) with SMTP id 9FEA2A50071; Thu, 11 May 2006 12:04:53 +0200 (CEST) Original-To: Jan =?utf-8?Q?Dj=C3=A4rv?= In-Reply-To: <4462ECD7.7020106@swipnet.se> (Jan =?utf-8?Q?Dj=C3=A4rv's?= message of "Thu, 11 May 2006 09:50:47 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:54253 Archived-At: Jan Dj=C3=A4rv writes: > Kim F. Storm skrev: > >> I've debugged this far -- and need an X-pert (Jan?) to take over: >> >> >> mouse-avoidance-mode 'animate uses set-mouse-position to move >> the mouse cursor in ~10 steps to reach its end position. >> >> If I type very slowly, approaching the window cursor to the mouse >> cursor -- and don't type anything while the mouse cursor is moving, >> everything works, i.e. the mouse cursor shape at the final destination >> is ok. >> >> If I type more quickly, the mouse cursor still moves in steps, but >> it may end up with any of the cursor shapes it had along the path. >> >> I put some trace output into xterm.c, and it seems that (in the first >> case) for each call to x_set_mouse_position (which calls >> XWarpPointer), the event loop receives a MotionNotify event >> (event.type =3D 6) with the new mouse cursor position. >> >> .. unless I hit a key while the mouse is moving (the second case). >> >> As soon as emacs gets the key event (event.type =3D 2), no further >> MotionNotify events are delivered for the remaining mouse positions >> along the path. >> >> This looks like an X bug. This is the Xfree server from redhat 9.0. > > Are you sure x_set_mouse_position is called? I put trace output int x_set_mouse_position, and it definitely gets called (several times). > When I hold down a key > and let it repeat, mouse avoidance is not working at all > (i.e. x_set_mouse_position is not called). I suspect event processing > takes all time so mouse avoidance does not get time to check where the > cursor is. mouse-avoidance-mode runs via the idle timer, so if your keyboard repeats too fast, emacs probably never runs the timer. > > Another thing is that X is not guaranteed to deliver MotionNotify for > every pixel the mouse moves through. Sure -- but it should deliver events for the (discrete) positions set via XWarpPointer (according to the docs). > It is actually undefined how > many MotionNotify you will get when moiving the mouse, but you are > guaranteed to get one MotionNotify when the mouse movement stops. The problem is that the MotionNotify event that you get is not the final mouse position. > > A third thing to check is if the XWarpPointer requests are queued or > not. You can add a call to XFlush after XWarpPointer and see if that > improves the situation. It actually makes the situation worse -- now the final mouse shape is wrong also when I type slowly, i.e. when I don't hit a key after the mouse cursor starts moving. > > I tried, but could not reproduce the situation where the cursor shape > is wrong. I'm sure it is timing related, i.e. events not sent or > received when expected to. So, it is probably a bug in the (old) version of Xfree that I'm using, and it looks like the bug is fixed in later versions. I tried to add an explicit call to note_mouse_highlight after the call to XWarpPointer, and it definitely has a positive effect, but even with that change, the pointer shape ends up wrong in some cases. I'm not sure how important it is to fix this, but there is=20 a patch which works for me -- of course a similar change is probably needed in x_set_mouse_pixel_position. *** xterm.c 10 May 2006 16:58:38 +0200 1.910 --- xterm.c 11 May 2006 11:52:27 +0200=09 *************** *** 226,231 **** --- 226,233 ---- =20=20 static unsigned long ignore_next_mouse_click_timeout; =20=20 + static int ignore_next_motion_event; +=20 /* Mouse movement. =20=20 Formerly, we used PointerMotionHintMask (in standard_event_mask) *************** *** 6543,6548 **** --- 6545,6556 ---- =20=20 case MotionNotify: { + if (ignore_next_motion_event) + { + ignore_next_motion_event =3D 0; + goto OTHER; + } +=20 previous_help_echo_string =3D help_echo_string; help_echo_string =3D Qnil; =20=20 *************** *** 8453,8458 **** --- 8461,8471 ---- =20=20 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 0, 0, 0, 0, pix_x, pix_y); +=20 + last_mouse_motion_event.x =3D pix_x; + last_mouse_motion_event.y =3D pix_y; + note_mouse_movement (f, &last_mouse_motion_event); + ignore_next_motion_event =3D 1; UNBLOCK_INPUT; } =20=20 *************** *** 10795,10800 **** --- 10808,10814 ---- last_tool_bar_item =3D -1; any_help_event_p =3D 0; ignore_next_mouse_click_timeout =3D 0; + ignore_next_motion_event =3D 0; #ifdef HAVE_X_SM x_session_initialized =3D 0; #endif -- Kim F. Storm http://www.cua.dk