emacs-devel
[Top][All Lists]
Advanced

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

Re: [patch v2] showing menu bar temporarily when f10 is pressed


From: Masatake YAMATO
Subject: Re: [patch v2] showing menu bar temporarily when f10 is pressed
Date: Wed, 20 Jun 2012 15:17:38 +0900 (JST)

>> +      (unless visible
>> +        (menu-bar-mode 1))
> 
> Here we have a problem: if you have several frames, some of which have
> a menu-bar and some don't, this will add a menu-bar to all of them, and
> then (menu-bar-mode -1) will remove it from all the frames.

Thank you for reviewing.
I've revised my patch to handle the case you pointed out. 
In the new patch, I deal with only frame local parameter.
I don't touch the minor mode.
I have still one un solved(TODO) item. 

> Why do you need the menu-bar?  Why not pop up the menu usually bound to
> C-mouse-3?

To be honest, I didn't know that.
I've just tried C-mouse-3; and found some advantages of C-mouse-3
comparing with f10 for KEYBOARD USER. 

1. With C-mouse-3, the menu is pop up where mouse pointer is.
   With f10, the menu is appeared at the top of frame.
   With f10, the position is predictable.

   Following the cases user may lost the mouse pointer:

   * using large display,
   * editing text with keyboard long time, and/or
   * turning on mouse-avoidance-mode.
   
   In addition it seems that emacs hides the mouse pointer 
   while the user editing text continuously. 

   So with C-moues-3, the user have to search the menu
   popup'ed. Time taking searching is very short but
   some user may feel frustration when the menu appeared
   on somewhere far away from (point). 

   In other hand, with f10, the user can predict the 
   place where menu appears. No mental overload.

2. With C-mouse-3, the contents of menu is chosen based
   on the window where the mouse pointer is.

   Consider a frame is splited into two windows.
   Each window holds different buffer. And different
   major modes are activated on buffers:

   Window A -> Buffer B -> Major mode C.
   Window D -> Buffer D -> Major mode E.

   Consider the following situation:
      You are editing text on buffer B, and
      Mouse pointer is at D.

   When C-mouse-3 is operated in this situation, a popup menu(P0)
   which includes a menu entry for major mode E will be appeared. But
   user may exepct a popup menu(P1) which includes a menu entry for
   major mode C is appeared.

   To show P1 in this situation, the user must move the
   mouse pointer to somewhere Window A.
   It doesn't take long time to move the mouse pointer to 
   Window A. some user may feel frustration. 

Moving the mouse cursor to (point) automatically before
C-mouse-3 may convers two disadvantage of C-mouse-3 with
keyboard operation. This is interesting idea, However, I 
feel extending [f10] is natural.

Masatake YAMATO
   

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2012-06-14 14:22:37 +0000
+++ lisp/ChangeLog      2012-06-20 03:28:45 +0000
@@ -1,3 +1,9 @@
+2012-06-19  Masatake YAMATO  <address@hidden>
+
+       * term/x-win.el (x-menu-bar-temorary-visibility): New custom var.
+       (x-menu-bar-open): Show menu bar temporarily if 
`x-menu-bar-temorary-visibility'.
+       (x-accelerate-menu-with-temporary-visible-menu-bar): New function.
+
 2012-06-14  Andreas Schwab  <address@hidden>
 
        * play/doctor.el (doctor-doc): Remove parameter and use

=== modified file 'lisp/term/x-win.el'
--- lisp/term/x-win.el  2012-04-27 05:40:46 +0000
+++ lisp/term/x-win.el  2012-06-20 03:43:31 +0000
@@ -1,4 +1,4 @@
-;;; x-win.el --- parse relevant switches and set up for X  -*-coding: 
iso-2022-7bit;-*-
+;;; x-win.el --- parse relevant switches and set up for X  -*-coding: 
iso-2022-7bit; lexical-binding: t; -*-
 
 ;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc.
 
@@ -1190,6 +1190,15 @@
                      (const TEXT)))
   :group 'killing)
 
+(defcustom x-menu-bar-temorary-visibility t
+  "Control whether use menu bar or `tmm-menubar' when `x-menu-bar-open' is 
invoked.
+Non-nil means showing menu bar temporarily even if `menu-bar-mode' is turned 
off.
+If nil, the behavior is changed whether `menu-bar-mode' is on or off. See 
`x-menu-bar-open'
+for more detail."
+  :type 'boolean
+  :group 'x
+  :version "24.2")
+
 ;; Get a selection value of type TYPE by calling x-get-selection with
 ;; an appropriate DATA-TYPE argument decided by `x-select-request-type'.
 ;; The return value is already decoded.  If x-get-selection causes an
@@ -1304,12 +1313,35 @@
 
 (declare-function accelerate-menu "xmenu.c" (&optional frame) t)
 
+(defun x-accelerate-menu-with-temporary-visible-menu-bar (frame)
+  "Do `accelerate-menu' with temporarily visible menu bar of FRAME."
+  (let ((old-menu-bar-lines (frame-parameter frame 'menu-bar-lines))
+       (old-frame (or frame (selected-frame))))
+    (if (menu-bar-positive-p old-menu-bar-lines)
+       (accelerate-menu frame)
+      (letrec ((hide (lambda ()
+                      (remove-hook 'deactivate-menubar-hook hide)
+                      ;; TODO: How can I handle the case the menu bar 
visibility is 
+                      ;;       changed as the effect of menu item choice.
+                      (when (frame-live-p old-frame)
+                        (set-frame-parameter old-frame 
+                                             'menu-bar-lines 
old-menu-bar-lines)))))
+       (set-frame-parameter old-frame 'menu-bar-lines 1)
+       (prog1
+           (accelerate-menu frame)
+         (add-hook 'deactivate-menubar-hook hide))))))
+
 (defun x-menu-bar-open (&optional frame)
-  "Open the menu bar if `menu-bar-mode' is on, otherwise call `tmm-menubar'."
+  "Open the menu bar if `menu-bar-mode' is on or 
`x-menu-bar-temorary-visibility' is non-nil, otherwise call `tmm-menubar'."
   (interactive "i")
-  (if (and menu-bar-mode
-          (fboundp 'accelerate-menu))
-      (accelerate-menu frame)
+  (if (fboundp 'accelerate-menu)
+      (cond
+       (x-menu-bar-temorary-visibility
+       (x-accelerate-menu-with-temporary-visible-menu-bar frame))
+       (menu-bar-mode
+       (accelerate-menu frame))
+       (t
+       (tmm-menubar)))
     (tmm-menubar)))
 
 

=== modified file 'src/ChangeLog'
--- src/ChangeLog       2012-06-14 04:02:35 +0000
+++ src/ChangeLog       2012-06-20 03:29:35 +0000
@@ -1,3 +1,11 @@
+2012-06-19  Masatake YAMATO  <address@hidden>
+
+       * xmenu.c (popup_deactivate_callback): Run Qdeactivate_menubar_hook.
+
+       * keyboard.c (Qdeactivate_menubar_hook): Define a new hook.
+
+       * keyboard.h (Qdeactivate_menubar_hook): Declare the new hook.
+
 2012-06-14  Paul Eggert  <address@hidden>
 
        * .gdbinit (xgetint): Fix recently-introduced paren typo.

=== modified file 'src/keyboard.c'
--- src/keyboard.c      2012-06-02 19:21:34 +0000
+++ src/keyboard.c      2012-06-19 17:10:11 +0000
@@ -257,6 +257,7 @@
 static Lisp_Object Qdeactivate_mark;
 
 Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+Lisp_Object Qdeactivate_menubar_hook;
 
 static Lisp_Object Qecho_area_clear_hook;
 
@@ -11535,6 +11536,7 @@
 
   DEFSYM (Qrecompute_lucid_menubar, "recompute-lucid-menubar");
   DEFSYM (Qactivate_menubar_hook, "activate-menubar-hook");
+  DEFSYM (Qdeactivate_menubar_hook, "deactivate-menubar-hook");
 
   DEFSYM (Qpolling_period, "polling-period");
 

=== modified file 'src/keyboard.h'
--- src/keyboard.h      2012-02-10 18:58:48 +0000
+++ src/keyboard.h      2012-06-19 17:08:30 +0000
@@ -212,6 +212,7 @@
 extern Lisp_Object internal_last_event_frame;
 
 extern Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+extern Lisp_Object Qdeactivate_menubar_hook;
 
 /* This holds a Lisp vector that holds the properties of a single
    menu item while decoding it in parse_menu_item.

=== modified file 'src/xmenu.c'
--- src/xmenu.c 2012-02-10 18:58:48 +0000
+++ src/xmenu.c 2012-06-19 17:07:58 +0000
@@ -686,12 +686,14 @@
 static void
 popup_deactivate_callback (GtkWidget *widget, gpointer client_data)
 {
+  safe_run_hooks (Qdeactivate_menubar_hook);
   popup_activated_flag = 0;
 }
 #else
 static void
 popup_deactivate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
 {
+  safe_run_hooks (Qdeactivate_menubar_hook);
   popup_activated_flag = 0;
 }
 #endif




reply via email to

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