* mouse position bug and half a fix
@ 2009-01-25 3:15 David Reitter
2009-01-25 17:02 ` Chong Yidong
0 siblings, 1 reply; 4+ messages in thread
From: David Reitter @ 2009-01-25 3:15 UTC (permalink / raw
To: Emacs-Devel devel
[-- Attachment #1: Type: text/plain, Size: 3553 bytes --]
Demonstration first:
emacs -Q
(split-window)
(find-file "~/.emacs") ;; any file will do, or switch to another buffer
(set (make-local-variable 'face-remapping-alist) '((default . variable-
pitch)))
The two buffers should now be shown in different faces. Now click
(don't drag) into the windows, alternating between the two of them.
You will see that various regions are marked, each of them between
some seemingly arbitrary point near the mouse click (=mark), and the
the point under the mouse. This shouldn't be. Instead, we would
expect to only set the point, as is the case without the `face-
remapping-alist' use above.
This seems to happen whenever a click into a non-selected window is
evaluated, and the faces differ in the two windows due to an entry in
`face-remapping-alist'.
Some analysis:
The problem is that (posn-point (event-start start-event)) in mouse-
drag-region does not give us the correct location; in fact, the xy
coordinates in the event are wrong.
My guess is that whatever algorithm determines the character position
under the mouse cursor forgets to switch to the appropriate window
buffer before looking up the faces when iterating over the window
contents. I could probably fix this myself if I knew where this bit
of code is... remember_mouse_glyph() probably doesn't have a part in
this (because that one should work as is).
For what its worth, I am using the code below (in xfaces.c) in some
time-critical places to lookup a face in a buffer without having to
make this buffer temporarily current. This may come in handy in order
to fix this.
int
lookup_basic_face_for_buffer (f, face_id, buffer)
struct frame *f;
int face_id;
Lisp_Object buffer;
{
Lisp_Object name, mapping;
int remapped_face_id;
Lisp_Object Vlocal_remapping_alist = Fbuffer_local_value
(intern("face-remapping-alist"), buffer);
if (NILP (Vlocal_remapping_alist))
return face_id; /* Nothing to do. */
switch (face_id)
{
case DEFAULT_FACE_ID: name = Qdefault; break;
case MODE_LINE_FACE_ID: name = Qmode_line; break;
case MODE_LINE_INACTIVE_FACE_ID: name = Qmode_line_inactive; break;
case HEADER_LINE_FACE_ID: name = Qheader_line; break;
case TOOL_BAR_FACE_ID: name = Qtool_bar; break;
case FRINGE_FACE_ID: name = Qfringe; break;
case SCROLL_BAR_FACE_ID: name = Qscroll_bar; break;
case BORDER_FACE_ID: name = Qborder; break;
case CURSOR_FACE_ID: name = Qcursor; break;
case MOUSE_FACE_ID: name = Qmouse; break;
case MENU_FACE_ID: name = Qmenu; break;
default:
abort (); /* the caller is supposed to pass us a basic face
id */
}
/* Do a quick scan through Vface_remapping_alist, and return
immediately
if there is no remapping for face NAME. This is just an
optimization
for the very common no-remapping case. */
mapping = assq_no_quit (name, Vlocal_remapping_alist);
if (NILP (mapping))
return face_id; /* Give up. */
/* If there is a remapping entry, lookup the face using NAME, which
will
handle the remapping too.
Avoid setting current buffer (slow).
*/
Lisp_Object old_face_remapping_alist = Vface_remapping_alist;
Vface_remapping_alist = Vlocal_remapping_alist;
remapped_face_id = lookup_named_face (f, name, 0, 0);
Vface_remapping_alist = old_face_remapping_alist;
if (remapped_face_id < 0)
return face_id; /* Give up. */
return remapped_face_id;
}
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2193 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#2044: posn-point wrong when face-remapping-alist used
@ 2009-01-25 14:39 ` David Reitter
2009-01-25 17:10 ` bug#2044: marked as done (posn-point wrong when face-remapping-alist used) Emacs bug Tracking System
0 siblings, 1 reply; 4+ messages in thread
From: David Reitter @ 2009-01-25 14:39 UTC (permalink / raw
To: emacs-pretest-bug
Demonstration first:
emacs -Q
(split-window)
(find-file "~/.emacs") ;; any file will do, or switch to another buffer
(set (make-local-variable 'face-remapping-alist) '((default . variable-
pitch)))
The two buffers should now be shown in different faces. Now click
(don't drag) into the windows, alternating between the two of them.
You will see that various regions are marked, each of them between
some seemingly arbitrary point near the mouse click (=mark), and the
the point under the mouse. This shouldn't be. Instead, we would
expect to only set the point, as is the case without the `face-
remapping-alist' use above.
This seems to happen whenever a click into a non-selected window is
evaluated, and the faces differ in the two windows due to an entry in
`face-remapping-alist'.
Some analysis:
The problem is that (posn-point (event-start start-event)) in mouse-
drag-region does not give us the correct location; in fact, the xy
coordinates in the event are wrong.
My guess is that whatever algorithm determines the character position
under the mouse cursor forgets to switch to the appropriate window
buffer before looking up the faces when iterating over the window
contents. I could probably fix this myself if I knew where this bit
of code is... remember_mouse_glyph() probably doesn't have a part in
this (because that one should work as is).
For what its worth, I am using the code below (in xfaces.c) in some
time-critical places to lookup a face in a buffer without having to
make this buffer temporarily current. This may come in handy in order
to fix this.
int
lookup_basic_face_for_buffer (f, face_id, buffer)
struct frame *f;
int face_id;
Lisp_Object buffer;
{
Lisp_Object name, mapping;
int remapped_face_id;
Lisp_Object Vlocal_remapping_alist = Fbuffer_local_value
(intern("face-remapping-alist"), buffer);
if (NILP (Vlocal_remapping_alist))
return face_id; /* Nothing to do. */
switch (face_id)
{
case DEFAULT_FACE_ID: name = Qdefault; break;
case MODE_LINE_FACE_ID: name = Qmode_line; break;
case MODE_LINE_INACTIVE_FACE_ID: name = Qmode_line_inactive; break;
case HEADER_LINE_FACE_ID: name = Qheader_line; break;
case TOOL_BAR_FACE_ID: name = Qtool_bar; break;
case FRINGE_FACE_ID: name = Qfringe; break;
case SCROLL_BAR_FACE_ID: name = Qscroll_bar; break;
case BORDER_FACE_ID: name = Qborder; break;
case CURSOR_FACE_ID: name = Qcursor; break;
case MOUSE_FACE_ID: name = Qmouse; break;
case MENU_FACE_ID: name = Qmenu; break;
default:
abort (); /* the caller is supposed to pass us a basic face
id */
}
/* Do a quick scan through Vface_remapping_alist, and return
immediately
if there is no remapping for face NAME. This is just an
optimization
for the very common no-remapping case. */
mapping = assq_no_quit (name, Vlocal_remapping_alist);
if (NILP (mapping))
return face_id; /* Give up. */
/* If there is a remapping entry, lookup the face using NAME, which
will
handle the remapping too.
Avoid setting current buffer (slow).
*/
Lisp_Object old_face_remapping_alist = Vface_remapping_alist;
Vface_remapping_alist = Vlocal_remapping_alist;
remapped_face_id = lookup_named_face (f, name, 0, 0);
Vface_remapping_alist = old_face_remapping_alist;
if (remapped_face_id < 0)
return face_id; /* Give up. */
return remapped_face_id;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mouse position bug and half a fix
2009-01-25 3:15 mouse position bug and half a fix David Reitter
@ 2009-01-25 17:02 ` Chong Yidong
2009-01-25 14:39 ` bug#2044: posn-point wrong when face-remapping-alist used David Reitter
0 siblings, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2009-01-25 17:02 UTC (permalink / raw
To: David Reitter; +Cc: 2044-done, Emacs-Devel devel
David Reitter <david.reitter@gmail.com> writes:
> The problem is that (posn-point (event-start start-event)) in mouse-
> drag-region does not give us the correct location; in fact, the xy
> coordinates in the event are wrong.
>
> My guess is that whatever algorithm determines the character position
> under the mouse cursor forgets to switch to the appropriate window
> buffer before looking up the faces when iterating over the window
> contents.
I've checked in a fix. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#2044: marked as done (posn-point wrong when face-remapping-alist used)
2009-01-25 14:39 ` bug#2044: posn-point wrong when face-remapping-alist used David Reitter
@ 2009-01-25 17:10 ` Emacs bug Tracking System
0 siblings, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2009-01-25 17:10 UTC (permalink / raw
To: Chong Yidong
[-- Attachment #1: Type: text/plain, Size: 866 bytes --]
Your message dated Sun, 25 Jan 2009 12:02:17 -0500
with message-id <87d4ebz5d2.fsf@cyd.mit.edu>
and subject line Re: mouse position bug and half a fix
has caused the Emacs bug report #2044,
regarding posn-point wrong when face-remapping-alist used
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)
--
2044: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=2044
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems
[-- Attachment #2: Type: message/rfc822, Size: 6748 bytes --]
From: David Reitter <david.reitter@gmail.com>
To: emacs-pretest-bug@gnu.org
Subject: posn-point wrong when face-remapping-alist used
Date: Sun, 25 Jan 2009 09:39:08 -0500
Message-ID: <33CE239F-C1F7-49E1-8678-29AE916EBDB8@gmail.com>
Demonstration first:
emacs -Q
(split-window)
(find-file "~/.emacs") ;; any file will do, or switch to another buffer
(set (make-local-variable 'face-remapping-alist) '((default . variable-
pitch)))
The two buffers should now be shown in different faces. Now click
(don't drag) into the windows, alternating between the two of them.
You will see that various regions are marked, each of them between
some seemingly arbitrary point near the mouse click (=mark), and the
the point under the mouse. This shouldn't be. Instead, we would
expect to only set the point, as is the case without the `face-
remapping-alist' use above.
This seems to happen whenever a click into a non-selected window is
evaluated, and the faces differ in the two windows due to an entry in
`face-remapping-alist'.
Some analysis:
The problem is that (posn-point (event-start start-event)) in mouse-
drag-region does not give us the correct location; in fact, the xy
coordinates in the event are wrong.
My guess is that whatever algorithm determines the character position
under the mouse cursor forgets to switch to the appropriate window
buffer before looking up the faces when iterating over the window
contents. I could probably fix this myself if I knew where this bit
of code is... remember_mouse_glyph() probably doesn't have a part in
this (because that one should work as is).
For what its worth, I am using the code below (in xfaces.c) in some
time-critical places to lookup a face in a buffer without having to
make this buffer temporarily current. This may come in handy in order
to fix this.
int
lookup_basic_face_for_buffer (f, face_id, buffer)
struct frame *f;
int face_id;
Lisp_Object buffer;
{
Lisp_Object name, mapping;
int remapped_face_id;
Lisp_Object Vlocal_remapping_alist = Fbuffer_local_value
(intern("face-remapping-alist"), buffer);
if (NILP (Vlocal_remapping_alist))
return face_id; /* Nothing to do. */
switch (face_id)
{
case DEFAULT_FACE_ID: name = Qdefault; break;
case MODE_LINE_FACE_ID: name = Qmode_line; break;
case MODE_LINE_INACTIVE_FACE_ID: name = Qmode_line_inactive; break;
case HEADER_LINE_FACE_ID: name = Qheader_line; break;
case TOOL_BAR_FACE_ID: name = Qtool_bar; break;
case FRINGE_FACE_ID: name = Qfringe; break;
case SCROLL_BAR_FACE_ID: name = Qscroll_bar; break;
case BORDER_FACE_ID: name = Qborder; break;
case CURSOR_FACE_ID: name = Qcursor; break;
case MOUSE_FACE_ID: name = Qmouse; break;
case MENU_FACE_ID: name = Qmenu; break;
default:
abort (); /* the caller is supposed to pass us a basic face
id */
}
/* Do a quick scan through Vface_remapping_alist, and return
immediately
if there is no remapping for face NAME. This is just an
optimization
for the very common no-remapping case. */
mapping = assq_no_quit (name, Vlocal_remapping_alist);
if (NILP (mapping))
return face_id; /* Give up. */
/* If there is a remapping entry, lookup the face using NAME, which
will
handle the remapping too.
Avoid setting current buffer (slow).
*/
Lisp_Object old_face_remapping_alist = Vface_remapping_alist;
Vface_remapping_alist = Vlocal_remapping_alist;
remapped_face_id = lookup_named_face (f, name, 0, 0);
Vface_remapping_alist = old_face_remapping_alist;
if (remapped_face_id < 0)
return face_id; /* Give up. */
return remapped_face_id;
}
[-- Attachment #3: Type: message/rfc822, Size: 1829 bytes --]
From: Chong Yidong <cyd@stupidchicken.com>
To: David Reitter <david.reitter@gmail.com>
Cc: Emacs-Devel devel <emacs-devel@gnu.org>, 2044-done@emacsbugs.donarmstrong.com
Subject: Re: mouse position bug and half a fix
Date: Sun, 25 Jan 2009 12:02:17 -0500
Message-ID: <87d4ebz5d2.fsf@cyd.mit.edu>
David Reitter <david.reitter@gmail.com> writes:
> The problem is that (posn-point (event-start start-event)) in mouse-
> drag-region does not give us the correct location; in fact, the xy
> coordinates in the event are wrong.
>
> My guess is that whatever algorithm determines the character position
> under the mouse cursor forgets to switch to the appropriate window
> buffer before looking up the faces when iterating over the window
> contents.
I've checked in a fix. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-01-25 17:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-25 3:15 mouse position bug and half a fix David Reitter
2009-01-25 17:02 ` Chong Yidong
2009-01-25 14:39 ` bug#2044: posn-point wrong when face-remapping-alist used David Reitter
2009-01-25 17:10 ` bug#2044: marked as done (posn-point wrong when face-remapping-alist used) Emacs bug Tracking System
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.