From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: mouse position bug and half a fix Date: Sat, 24 Jan 2009 22:15:13 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: multipart/signed; boundary=Apple-Mail-13--1004440821; micalg=sha1; protocol="application/pkcs7-signature" X-Trace: ger.gmane.org 1232853337 20115 80.91.229.12 (25 Jan 2009 03:15:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Jan 2009 03:15:37 +0000 (UTC) To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 25 04:16:50 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LQvUM-0005p6-DE for ged-emacs-devel@m.gmane.org; Sun, 25 Jan 2009 04:16:47 +0100 Original-Received: from localhost ([127.0.0.1]:58833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQvT4-0006VD-Kh for ged-emacs-devel@m.gmane.org; Sat, 24 Jan 2009 22:15:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQvT0-0006TV-15 for emacs-devel@gnu.org; Sat, 24 Jan 2009 22:15:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQvSy-0006Qs-FJ for emacs-devel@gnu.org; Sat, 24 Jan 2009 22:15:20 -0500 Original-Received: from [199.232.76.173] (port=39332 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQvSy-0006Qp-92 for emacs-devel@gnu.org; Sat, 24 Jan 2009 22:15:20 -0500 Original-Received: from mail-gx0-f20.google.com ([209.85.217.20]:33958) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LQvSx-0008OK-RP for emacs-devel@gnu.org; Sat, 24 Jan 2009 22:15:20 -0500 Original-Received: by gxk13 with SMTP id 13so4837922gxk.18 for ; Sat, 24 Jan 2009 19:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:mime-version:subject:date:x-mailer; bh=gaci/IyFJY0ixL9Gzwv73S8LUKVwNstNpscUYodxHss=; b=iXVauV4UK/EEWwTNYha72a2/lBiKGZRedgXzqErYJvLUm2Mkpi0Hr4RmYTxX+pubx8 fwtLaK5bQxgITYv/v9PSuJvJJoCXbAYGhpKt++5/D9Rb5qmm/2iMuYroK3hEOZda2A9u TQAdodB00jwtEGO7hP8T2IWDX51z4mFBXrtjo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:x-mailer; b=BtJ6oSnphriLacrjSYOFnOQ4GhdaXnM9OwWNKJCDhwhVcHVgngEpc6tNGiKDV8Ir4g y8AbgMqW28W8NrWFCf/zTf0U4JxjRUV6kFr04Ak0JwJZS901EBm8pCp8IRAkNrnb/ipi ckBh2h0CDEINmsquQpM8iMgHUNE72eXlHma78= Original-Received: by 10.150.189.2 with SMTP id m2mr6104322ybf.103.1232853318433; Sat, 24 Jan 2009 19:15:18 -0800 (PST) Original-Received: from scarlett.local (pool-71-162-19-14.pitbpa.east.verizon.net [71.162.19.14]) by mx.google.com with ESMTPS id s30sm25666998elf.11.2009.01.24.19.15.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 24 Jan 2009 19:15:16 -0800 (PST) X-Mailer: Apple Mail (2.930.3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:108217 Archived-At: --Apple-Mail-13--1004440821 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit 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; } --Apple-Mail-13--1004440821 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIFxDCCAn0w ggHmoAMCAQICED6shx13jEDrq0eL8FRq5ykwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA4MTIwOTAyMDgwMVoXDTA5MTIwOTAyMDgw MVowYjEQMA4GA1UEBBMHUmVpdHRlcjEOMAwGA1UEKhMFRGF2aWQxFjAUBgNVBAMTDURhdmlkIFJl aXR0ZXIxJjAkBgkqhkiG9w0BCQEWF2RhdmlkLnJlaXR0ZXJAZ21haWwuY29tMIGfMA0GCSqGSIb3 DQEBAQUAA4GNADCBiQKBgQDOdo6kAwlkBxUb8dj4saMbYg4SVng8CUePFn3cjjWrakBTbUVa4Z0n wlUxr7AitEeKhB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