GNU bug report logs - #447
last-nonmenu-event and sub-menus

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Wed, 18 Jun 2008 23:15:03 UTC

Severity: normal

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 447 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: 447 <at> debbugs.gnu.org
Cc: Glenn Morris <rgm <at> gnu.org>
Subject: Re: last-nonmenu-event and sub-menus
Date: Sun, 04 Jan 2009 14:07:58 +0100
[Message part 1 (text/plain, inline)]
> emacs -Q
>
> ;; Evaluate this code:
>
> (defun bar ()
>   (interactive)
>   (message "%s :: %s" last-nonmenu-event
>      (posn-window (event-start last-nonmenu-event)))
>   (sit-for 5))
>
> (global-set-key
>  [down-mouse-2]
>  '(menu-item "foo"
>              (keymap "foo"
>                      (bar menu-item "bar" bar)
>                      (submenu menu-item "submenu"
>                               (keymap "submenu" (bar menu-item "bar" bar))))))
>
> C-x 2
> Put "scratch" in one window, "messages" in the other.
> Select "messages" window.
> Move mouse over "scratch", but do not select it.
> Press mouse-2, and select the "bar" menu-item.
>
>
> When called from the top-level menu, `bar' correctly returns:
>
> (down-mouse-2 (#<window 3 on *scratch*> 534 (251 . 101) 2649593899 nil
> 534 (27 . 6) nil (8 . 11) (9 . 15))) :: #<window 3 on *scratch*>
>
>
> When called from the submenu, `bar' returns a bad result:
>
> bar :: #<window 7 on *Messages*>
>
> The window is wrong, etc.

Glenn, just for fun please try the attached patch.  It seems to solve
your problem here but I have no idea whether it has any detrimental
side-effects.

martin
[keyboard.c.diff (text/plain, inline)]
*** keyboard.c.~1.986.~	2009-01-03 17:35:34.328125000 +0100
--- keyboard.c	2009-01-04 13:59:34.328125000 +0100
***************
*** 2548,2553 ****
--- 2548,2555 ----
  
    if (CONSP (Vunread_command_events))
      {
+       int was_disabled = 0;
+ 
        c = XCAR (Vunread_command_events);
        Vunread_command_events = XCDR (Vunread_command_events);
  
***************
*** 2568,2579 ****
        if (CONSP (c)
  	  && EQ (XCDR (c), Qdisabled)
  	  && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c))))
! 	c = XCAR (c);
  
        /* If the queued event is something that used the mouse,
           set used_mouse_menu accordingly.  */
        if (used_mouse_menu
! 	  && (EQ (c, Qtool_bar) || EQ (c, Qmenu_bar)))
  	*used_mouse_menu = 1;
  
        goto reread_for_input_method;
--- 2570,2584 ----
        if (CONSP (c)
  	  && EQ (XCDR (c), Qdisabled)
  	  && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c))))
! 	{
! 	  was_disabled = 1;
! 	  c = XCAR (c);
! 	}
  
        /* If the queued event is something that used the mouse,
           set used_mouse_menu accordingly.  */
        if (used_mouse_menu
! 	  && (EQ (c, Qtool_bar) || EQ (c, Qmenu_bar) || was_disabled))
  	*used_mouse_menu = 1;
  
        goto reread_for_input_method;

This bug report was last modified 16 years and 133 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.