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

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

Re: mouse-autoselect-window with menu pane


From: martin rudalics
Subject: Re: mouse-autoselect-window with menu pane
Date: Mon, 18 Sep 2006 09:51:22 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Please try whether the attached patch works.  If
`mouse-autoselect-window-suspend' causes any problems I'll take it out.

The patch also removes `popup_activated_flag' and `popup_activated' from
w32menu.c since these are completely useless.  In addition I removed a
confusing disjunct from xdisp.c.

For macmenu.c I added a line in `x_activate_menubar' that sets
f->output_data.mac->menubar_active to 1.  I'm not sure know whether this
is needed or useful.  But note that f->output_data.mac->menubar_active
is currently twice reset to zero apparently for no good reason.  Could
someone (YAMAMOTO Mitsuharu) please test whether my change would break
anything on Mac?
*** macmenu.c   Tue Jun  6 19:20:42 2006
--- macmenu.c   Sun Sep 17 10:05:38 2006
***************
*** 1018,1023 ****
--- 1018,1026 ----
    extern Point saved_menu_event_location;

    set_frame_menubar (f, 0, 1);
+ 
+   f->output_data.mac->menubar_active = 1;
+ 
    BLOCK_INPUT;

    menu_choice = MenuSelect (saved_menu_event_location);
***************
*** 1026,1031 ****
--- 1029,1045 ----
    UNBLOCK_INPUT;
  }

+ /* The following is used by delayed window autoselection.  */
+ 
+ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, 
Smenu_or_popup_active_p, 0, 0, 0,
+        doc: /* Return t if a menu or popup dialog is active on selected 
frame.  */)
+      ()
+ {
+   FRAME_PTR f;
+   f = SELECTED_FRAME ();
+   return (f->output_data.mac->menubar_active > 0) ? Qt : Qnil;
+ }
+ 
  /* This callback is called from the menu bar pulldown menu
     when the user makes a selection.
     Figure out what the user chose
***************
*** 2636,2641 ****
--- 2650,2656 ----
    Vmenu_updating_frame = Qnil;

    defsubr (&Sx_popup_menu);
+   defsubr (&Smenu_or_popup_active_p);
  #ifdef HAVE_MENUS
    defsubr (&Sx_popup_dialog);
  #endif

*** w32menu.c   Tue Aug 15 10:01:02 2006
--- w32menu.c   Mon Sep 18 07:49:02 2006
***************
*** 235,244 ****
  /* Current depth within submenus.  */
  static int menu_items_submenu_depth;

- /* Flag which when set indicates a dialog or menu has been posted by
-    Xt on behalf of one of the widget sets.  */
- static int popup_activated_flag;
- 
  static int next_menubar_widget_id;

  /* This is set nonzero after the user activates the menu bar, and set
--- 235,240 ----
***************
*** 994,999 ****
--- 990,1006 ----
    complete_deferred_msg (FRAME_W32_WINDOW (f), WM_INITMENU, 0);
  }

+ /* The following is used by delayed window autoselection.  */
+ 
+ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, 
Smenu_or_popup_active_p, 0, 0, 0,
+        doc: /* Return t if a menu or popup dialog is active on selected 
frame.  */)
+      ()
+ {
+   FRAME_PTR f;
+   f = SELECTED_FRAME ();
+   return (f->output_data.w32->menubar_active > 0) ? Qt : Qnil;
+ }
+ 
  /* This callback is called from the menu bar pulldown menu
     when the user makes a selection.
     Figure out what the user chose
***************
*** 2148,2154 ****

    /* Display the menu.  */
    lw_pop_up_all_widgets (dialog_id);
-   popup_activated_flag = 1;

    /* Process events that apply to the menu.  */
    popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id);
--- 2155,2160 ----
***************
*** 2428,2440 ****
    return 1;
  }

- int
- popup_activated ()
- {
-   /* popup_activated_flag not actually used on W32 */
-   return 0;
- }
- 
  /* Display help string for currently pointed to menu item. Not
     supported on NT 3.51 and earlier, as GetMenuItemInfo is not
     available. */
--- 2434,2439 ----
***************
*** 2554,2559 ****
--- 2553,2559 ----
    Vmenu_updating_frame = Qnil;

    defsubr (&Sx_popup_menu);
+   defsubr (&Smenu_or_popup_active_p);
  #ifdef HAVE_MENUS
    defsubr (&Sx_popup_dialog);
  #endif

*** xdisp.c     Fri Sep  8 18:07:34 2006
--- xdisp.c     Mon Sep 18 07:47:46 2006
***************
*** 22604,22610 ****
    struct buffer *b;

    /* When a menu is active, don't highlight because this looks odd.  */
! #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
    if (popup_activated ())
      return;
  #endif
--- 22604,22610 ----
    struct buffer *b;

    /* When a menu is active, don't highlight because this looks odd.  */
! #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
    if (popup_activated ())
      return;
  #endif

*** xmenu.c     Tue Jun  6 19:20:42 2006
--- xmenu.c     Mon Sep 18 08:32:26 2006
***************
*** 1487,1492 ****
--- 1487,1501 ----
    return popup_activated_flag;
  }

+ /* The following is used by delayed window autoselection.  */
+ 
+ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, 
Smenu_or_popup_active_p, 0, 0, 0,
+        doc: /* Return t if a menu or popup dialog is active.  */)
+      ()
+ {
+   return (popup_activated ()) ? Qt : Qnil;
+ }
+ 
  /* This callback is invoked when the user selects a menubar cascade
     pushbutton, but before the pulldown menu is posted.  */

***************
*** 3769,3774 ****
--- 3778,3784 ----
  #endif

    defsubr (&Sx_popup_menu);
+   defsubr (&Smenu_or_popup_active_p);

  #if defined (USE_GTK) || defined (USE_X_TOOLKIT)
    defsubr (&Smenu_bar_open);

*** window.el   Fri Sep  8 18:07:24 2006
--- window.el   Sat Sep 16 18:15:02 2006
***************
*** 790,795 ****
--- 790,798 ----
  (defvar mouse-autoselect-window-now nil
    "When non-nil don't delay autoselection in `handle-select-window'.")

+ (defvar mouse-autoselect-window-suspend nil
+   "When non-nil suspend autoselection due to a menu interaction.")
+ 
  (defun mouse-autoselect-window-cancel (&optional force)
    "Cancel delayed window autoselection.
  Optional argument FORCE means cancel unconditionally."
***************
*** 812,817 ****
--- 815,822 ----
  mouse position has stabilized or a command is executed."
    ;; Cancel any active window autoselection.
    (mouse-autoselect-window-cancel t)
+   ;; Clear suspended autoselection.
+   (setq mouse-autoselect-window-suspend nil)
    ;; Record current mouse position in `mouse-autoselect-window-position' and
    ;; WINDOW in `mouse-autoselect-window-window'.
    (setq mouse-autoselect-window-position (mouse-position))
***************
*** 835,840 ****
--- 840,851 ----
             (window (window-at (cadr mouse-position) (cddr mouse-position)
                                (car mouse-position))))
        (cond
+        ((and (fboundp 'menu-or-popup-active-p) (menu-or-popup-active-p))
+         ;; A menu or popup dialog is active.  Suspend autoselection.
+         (setq mouse-autoselect-window-suspend t))
+        (mouse-autoselect-window-suspend
+         ;; Autoselection was suspended, reenable it.
+         (setq mouse-autoselect-window-suspend nil))
         ((and window (not (eq window (selected-window)))
               (or (not (numberp mouse-autoselect-window))
                   (and (> mouse-autoselect-window 0)


reply via email to

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