bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#2044: marked as done (posn-point wrong when face-remapping-alist use


From: Emacs bug Tracking System
Subject: bug#2044: marked as done (posn-point wrong when face-remapping-alist used)
Date: Sun, 25 Jan 2009 17:10:10 +0000

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
--- Begin Message --- Subject: posn-point wrong when face-remapping-alist used Date: Sun, 25 Jan 2009 09:39:08 -0500
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;
}





--- End Message ---
--- Begin Message --- Subject: Re: mouse position bug and half a fix Date: Sun, 25 Jan 2009 12:02:17 -0500 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)
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.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]