From: Jason Rumney <jasonr@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [hober0@gmail.com: Re: mode-line redisplay bug]
Date: Sat, 08 Oct 2005 22:26:59 +0100 [thread overview]
Message-ID: <uek6vzom4.fsf@jasonrumney.net> (raw)
In-Reply-To: <uu0huzrva.fsf@jasonrumney.net> (Jason Rumney's message of "Fri, 12 Aug 2005 23:56:41 +0100")
[-- Attachment #1: Type: text/plain, Size: 2922 bytes --]
Jason Rumney <jasonr@gnu.org> writes:
> On GNU/Linux:
>
> The highlit area flickers. On W32 it flickers once when the tooltip
> pops up, but on X, it flickers constantly. I remember fixing something
> like this on W32 years ago, it was in the code that detected mouse
> movement - movement events were being sent for zero movement when
> inside track-mouse forms. But my recollection is that the same bug did
> not appear on X at the time, so even though the code appeared to be
> the same, I did not try to apply my fix to the X code.
I have looked at this and narrowed down the changes I made to
w32term.c. Looking at the code again, I am sure that my changes should
be applied to xterm.c as well, but applying them does not seem to make
any difference to the flickering. It probably needs an X expert to
look at it as I may have some misunderstanding here.
In note_mouse_movement, which is called from handle_one_xevent in
response to several types of event, we check the event's mouse position
against last_mouse_glyph, to limit the number of events we pass
through to lisp.
last_mouse_glyph is updated in XTmouse_position, nowhere else as far
as I can tell. XTmouse_position is installed as mouse_position_hook.
As far as I can tell, it is called only when do_mouse_tracking is
non-nil (in keyboard.c), or when the functions mouse-position and
mouse-pixel-position (both in frame.c) are explicitly called.
This means that last_mouse_glyph normally won't get updated, so it
doesn't serve the purpose that we use it for.
I fixed this in w32term.c by factoring out the code that updates
last_mouse_glyph from w32_mouse_position (the equivalent of
XTmouse_position) into a new function remember_mouse_glyph, and call
it from note_mouse_movement when we notice the glyph has changed, to
ensure it is always up to date.
Having done that, I also noticed the following code from
XTmouse_position:
/* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
round down even for negative values. */
if (gx < 0)
gx -= width - 1;
if (gy < 0)
gy -= height - 1;
gx = (gx + width - 1) / width * width;
gy = (gy + height - 1) / height * height;
last_mouse_glyph.width = width;
last_mouse_glyph.height = height;
last_mouse_glyph.x = gx;
last_mouse_glyph.y = gy;
gx and gy are initially the position of the mouse. We are trying to
find the rectangle around the glyph under the mouse here.
On Windows, I found that this code returns the rectangle of a glyph
diagonally adjacent to the glyph we want. I am not sure if I am
missing something about the way X co-ordinates work, but I think the
two lines that round gx and gy should be simply:
gx = gx / width * width;
gy = gy / height * height;
Here is the full patch adapted to xterm.c. As I said, it does not seem
to have any effect, so it needs someone more familiar with X to look
at it further:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xterm.patch --]
[-- Type: text/x-patch, Size: 2180 bytes --]
3584a3585,3586
> static void remember_mouse_glyph P_ ((struct frame *, int, int));
>
3609a3612,3613
> /* Remember which glyph we're now on. */
> remember_mouse_glyph (frame, event->x, event->y);
3679a3684,3724
> /* Remember which glyph the mouse is over.
> */
> static void
> remember_mouse_glyph (f1, win_x, win_y)
> FRAME_PTR f1;
> int win_x, win_y;
> {
> int width, height, gx, gy;
>
> /* Try getting the rectangle of the actual glyph. */
> if (!glyph_rect (f1, win_x, win_y, &last_mouse_glyph))
> {
> /* If there is no glyph under the mouse, then we divide the screen
> into a grid of the smallest glyph in the frame, and use that
> as our "glyph". */
> width = FRAME_SMALLEST_CHAR_WIDTH (f1);
> height = FRAME_SMALLEST_FONT_HEIGHT (f1);
> gx = win_x;
> gy = win_y;
>
> /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
> round down even for negative values. */
> if (gx < 0)
> gx -= width - 1;
> if (gy < 0)
> gy -= height - 1;
> #if 0
> gx = (gx + width - 1) / width * width;
> gy = (gy + height - 1) / height * height;
> #else
> gx = gx / width * width;
> gy = gy / width * width;
> #endif
> last_mouse_glyph.width = width;
> last_mouse_glyph.height = height;
> last_mouse_glyph.x = gx;
> last_mouse_glyph.y = gy;
> }
> }
>
>
3866,3891c3911
< int width, height, gx, gy;
< XRectangle rect;
<
< if (glyph_rect (f1, win_x, win_y, &rect))
< last_mouse_glyph = rect;
< else
< {
< width = FRAME_SMALLEST_CHAR_WIDTH (f1);
< height = FRAME_SMALLEST_FONT_HEIGHT (f1);
< gx = win_x;
< gy = win_y;
<
< /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
< round down even for negative values. */
< if (gx < 0)
< gx -= width - 1;
< if (gy < 0)
< gy -= height - 1;
< gx = (gx + width - 1) / width * width;
< gy = (gy + height - 1) / height * height;
<
< last_mouse_glyph.width = width;
< last_mouse_glyph.height = height;
< last_mouse_glyph.x = gx;
< last_mouse_glyph.y = gy;
< }
---
> remember_mouse_glyph (f1, win_x, win_y);
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2005-10-08 21:26 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-12 14:59 [hober0@gmail.com: Re: mode-line redisplay bug] Richard M. Stallman
2005-08-12 16:58 ` Eli Zaretskii
2005-08-12 17:19 ` Edward O'Connor
2005-08-12 17:31 ` Edward O'Connor
2005-08-12 18:58 ` Henrik Enberg
2005-08-16 12:58 ` Kim F. Storm
2005-08-12 18:19 ` Robert J. Chassell
2005-08-12 22:56 ` Jason Rumney
2005-08-13 21:54 ` Richard M. Stallman
2005-08-13 22:51 ` Jason Rumney
2005-10-08 21:26 ` Jason Rumney [this message]
2005-10-09 1:57 ` mituharu
2005-10-09 6:11 ` Jan D.
2005-10-10 19:40 ` Jason Rumney
[not found] ` <wlwtp6ijoz.wl%mituharu@math.s.chiba-u.ac.jp>
2005-10-11 1:21 ` YAMAMOTO Mitsuharu
2005-10-11 10:21 ` Kim F. Storm
2005-10-11 12:38 ` YAMAMOTO Mitsuharu
2005-10-11 15:14 ` Kim F. Storm
2005-10-11 14:50 ` Jason Rumney
2005-10-11 22:43 ` Kim F. Storm
2005-10-12 3:15 ` YAMAMOTO Mitsuharu
2005-10-12 8:39 ` Kim F. Storm
2005-10-12 8:41 ` YAMAMOTO Mitsuharu
2005-10-12 9:29 ` Kim F. Storm
2005-10-12 9:59 ` YAMAMOTO Mitsuharu
2005-10-11 10:47 ` Jason Rumney
2005-10-11 11:25 ` Kim F. Storm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uek6vzom4.fsf@jasonrumney.net \
--to=jasonr@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).