all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#447: last-nonmenu-event and sub-menus
@ 2008-06-18 23:06 Glenn Morris
  0 siblings, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2008-06-18 23:06 UTC (permalink / raw
  To: bug-gnu-emacs


last-nonmenu-event returns a bad value when submenus are involved.
This applies to 22.2 and the current CVS. As an example:

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.







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#447: last-nonmenu-event and sub-menus
@ 2008-10-08 22:41 Chong Yidong
  2008-10-09 16:55 ` Glenn Morris
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2008-10-08 22:41 UTC (permalink / raw
  To: Glenn Morris; +Cc: 447

> last-nonmenu-event returns a bad value when submenus are involved.
> This applies to 22.2 and the current CVS. As an example:
>
> 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 submenu, `bar' returns a bad result:
>
> bar :: #<window 7 on *Messages*>
>
> The window is wrong, etc.

Hi Glenn,

I can't seem to reproduce this now, using the latest Emacs CVS.  Maybe
it's been fixed in the meantime.  Do you still see this behavior?






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#447: last-nonmenu-event and sub-menus
  2008-10-08 22:41 bug#447: last-nonmenu-event and sub-menus Chong Yidong
@ 2008-10-09 16:55 ` Glenn Morris
  0 siblings, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2008-10-09 16:55 UTC (permalink / raw
  To: Chong Yidong; +Cc: 447

Chong Yidong wrote:

> I can't seem to reproduce this now, using the latest Emacs CVS.  Maybe
> it's been fixed in the meantime.  Do you still see this behavior?

I still see it. Do you see it with Emacs 22 even?






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#447: last-nonmenu-event and sub-menus
@ 2009-01-04 13:07 martin rudalics
  2009-01-09 20:01 ` Glenn Morris
  0 siblings, 1 reply; 5+ messages in thread
From: martin rudalics @ 2009-01-04 13:07 UTC (permalink / raw
  To: 447

[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]

 > 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

[-- Attachment #2: keyboard.c.diff --]
[-- Type: text/plain, Size: 1234 bytes --]

*** 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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#447: last-nonmenu-event and sub-menus
  2009-01-04 13:07 martin rudalics
@ 2009-01-09 20:01 ` Glenn Morris
  0 siblings, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2009-01-09 20:01 UTC (permalink / raw
  To: martin rudalics; +Cc: 447

martin rudalics wrote:

> 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.

Yes, it seems to fix the problem, thank you.






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-09 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08 22:41 bug#447: last-nonmenu-event and sub-menus Chong Yidong
2008-10-09 16:55 ` Glenn Morris
  -- strict thread matches above, loose matches on Subject: below --
2009-01-04 13:07 martin rudalics
2009-01-09 20:01 ` Glenn Morris
2008-06-18 23:06 Glenn Morris

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.