Subject: bug#30955: closed (Re: bug#30955: 27.0.50; Mouse clicks on header-line in Info are broken)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 27 Mar 2018 19:28:02 +0000

Your bug report

#30955: 27.0.50; Mouse clicks on header-line in Info are broken

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
30955: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=30955
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#30955: 27.0.50; Mouse clicks on header-line in Info are broken
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Cc: Colin Baxter <[email-masked]>, Eli Zaretskii <[email-masked]>
Date: Tue, 27 Mar 2018 15:27:10 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

>         Stefan "not looking forward to debug sessions in read_key_sequence"

Ha, I found the sucker!
Installed,

        Stefan

--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8701,10 +8701,19 @@ follow_key (Lisp_Object keymap, Lisp_Object key)
 }
 
 static Lisp_Object
-active_maps (Lisp_Object first_event)
+active_maps (Lisp_Object first_event, Lisp_Object second_event)
 {
   Lisp_Object position
-    = CONSP (first_event) ? CAR_SAFE (XCDR (first_event)) : Qnil;
+    = EVENT_HAS_PARAMETERS (first_event) ? EVENT_START (first_event) : Qnil;
+  /* The position of a click can be in the second event if the first event
+     is a pseudo-event like `header-line` or `mode-line`.  */
+  if (SYMBOLP (first_event)
+      && EVENT_HAS_PARAMETERS (second_event)
+      && EQ (first_event, POSN_POSN (EVENT_START (second_event))))
+    {
+      eassert (NILP (position));
+      position = EVENT_START (second_event);
+    }
   return Fcons (Qkeymap, Fcurrent_active_maps (Qt, position));
 }
 
@@ -9016,13 +9025,14 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
   starting_buffer = current_buffer;
   first_unbound = bufsize + 1;
   Lisp_Object first_event = mock_input > 0 ? keybuf[0] : Qnil;
+  Lisp_Object second_event = mock_input > 1 ? keybuf[1] : Qnil;
 
   /* Build our list of keymaps.
      If we recognize a function key and replace its escape sequence in
      keybuf with its symbol, or if the sequence starts with a mouse
      click and we need to switch buffers, we jump back here to rebuild
      the initial keymaps from the current buffer.  */
-  current_binding = active_maps (first_event);
+  current_binding = active_maps (first_event, second_event);
 
   /* Start from the beginning in keybuf.  */
   t = 0;
@@ -9282,7 +9292,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
 		  && (XBUFFER (XWINDOW (selected_window)->contents)
 		      != current_buffer))
 		Fset_buffer (XWINDOW (selected_window)->contents);
-	      current_binding = active_maps (first_event);
+	      current_binding = active_maps (first_event, Qnil);
 	    }
 
 	  GROW_RAW_KEYBUF;

Subject: 27.0.50; Mouse clicks on header-line in Info are broken
From: Eli Zaretskii <[email-masked]>
To: [email-masked]
Date: Mon, 26 Mar 2018 17:54:19 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

To reproduce:

  emacs -Q
  C-u C-h i /path/to/info/elisp.info RET
  2
  3
  4
  Click mouse-1 on the "Up: Programming Types" link on the header-line

This results in an error:

  <header-line> <header-line> <mouse-2> is undefined

If you now type "C-h c" followed by the same mouse-1 click, you will
see

  <header-line> <down-mouse-1> (translated from <down-mouse-1>) at that spot runs the command mouse-drag-header-line

as expected, but before that, momentarily, the echo area will flash
this:

  header-line header-line mouse-2-

Reverting the following commit fixes the problem:

  commit 3d5e31eceb9dc1fb62b2b27bcab549df3bd04ce9
  Author:     Stefan Monnier <[email-masked]>
  AuthorDate: Tue Jan 30 12:41:29 2018 -0500
  Commit:     Stefan Monnier <[email-masked]>
  CommitDate: Tue Jan 30 12:41:29 2018 -0500

      * lisp/mouse.el: Rework the mouse-1-click remapping

      Avoid peeking ahead at the next event because this had undesirable effects,
      such as making 'this-single-command-raw-keys' return bogus information.

      (mouse--last-down): New variable.
      (mouse--down-1-maybe-follows-link): Don't do the remapping here.
      Instead, just keep track of the time when the down happened.
      (mouse--down-1-maybe-follows-link): Do the remapping here.
      (key-translation-map): Add bindings for (double-)mouse-1.

In GNU Emacs 27.0.50 (build 169, i686-pc-mingw32)
 of 2018-03-25 built on HOME-C4E4A596F7
Repository revision: 1be6a21fd8b5ade67f7f69f964331aa570623683
Windowing system distributor 'Microsoft Corp.', version 5.1.2600
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
<header-line> <header-line> <mouse-2> is undefined

Configured using:
 'configure --prefix=/d/usr --enable-checking=yes,glyphs --with-wide-int
 --with-modules --enable-check-lisp-object-type 'CFLAGS=-O0 -gdwarf-4
 -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS MODULES THREADS JSON LCMS2

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1255

Major mode: Info

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils info easymenu time-date
elec-pair mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win
w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote w32notify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 132974 9857)
 (symbols 56 21395 1)
 (miscs 48 58 152)
 (strings 16 36869 2443)
 (string-bytes 1 867215)
 (vectors 16 15422)
 (vector-slots 8 580149 18798)
 (floats 8 59 58)
 (intervals 40 4939 217)
 (buffers 880 13))