unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: monnier@IRO.UMontreal.CA
Cc: emacs-devel@gnu.org
Subject: Re: [patch v2] showing menu bar temporarily when f10 is pressed
Date: Wed, 20 Jun 2012 15:17:38 +0900 (JST)	[thread overview]
Message-ID: <20120620.151738.1783513864733342718.yamato@redhat.com> (raw)
In-Reply-To: <jwvr4tbx9os.fsf-monnier+emacs@gnu.org>

>> +	  (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  <yamato@redhat.com>
+
+	* 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  <schwab@linux-m68k.org>
 
 	* 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)))
 
 \f

=== 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  <yamato@redhat.com>
+
+	* 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  <eggert@cs.ucla.edu>
 
 	* .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;
 \f
 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	other threads:[~2012-06-20  6:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19 18:41 [patch] showing menu bar temporarily when f10 is pressed Masatake YAMATO
2012-06-19 20:31 ` Lluís
2012-06-19 21:42 ` Stefan Monnier
2012-06-20  6:17   ` Masatake YAMATO [this message]
2012-07-18 11:29     ` [patch v3] " Masatake YAMATO
2012-07-19  6:54       ` Stefan Monnier
2012-07-19  8:32         ` Where the menu should be appeared when C-mouse-3 is triggered (Was: [patch v3] showing menu bar temporarily when f10 is pressed) Masatake YAMATO
2012-07-19  9:07           ` Where the menu should be appeared when C-mouse-3 is triggered Stefan Monnier
2012-07-20  4:55             ` Masatake YAMATO
2012-07-20 11:38               ` Stefan Monnier
2012-07-20 11:56                 ` Masatake YAMATO
2012-07-28  9:31                   ` Masatake YAMATO
2012-08-09 11:13                     ` Masatake YAMATO
2012-08-10 12:44                       ` Stefan Monnier
2012-08-10 13:21                         ` Drew Adams
2012-08-10 13:52                         ` Masatake YAMATO
2012-08-10 14:47                         ` Stefan Monnier
2012-07-20 12:48                 ` Masatake YAMATO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120620.151738.1783513864733342718.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).