From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: [patch v3] showing menu bar temporarily when f10 is pressed Date: Wed, 18 Jul 2012 20:29:01 +0900 (JST) Organization: Red Hat Japan, Inc. Message-ID: <20120718.202901.2035363502190339372.yamato@redhat.com> References: <20120620.034116.1379090244202488621.yamato@redhat.com> <20120620.151738.1783513864733342718.yamato@redhat.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1342610958 2010 80.91.229.3 (18 Jul 2012 11:29:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2012 11:29:18 +0000 (UTC) Cc: emacs-devel@gnu.org To: monnier@IRO.UMontreal.CA Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 18 13:29:14 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SrSRN-0007Tw-Ql for ged-emacs-devel@m.gmane.org; Wed, 18 Jul 2012 13:29:14 +0200 Original-Received: from localhost ([::1]:50339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrSRM-00064R-VM for ged-emacs-devel@m.gmane.org; Wed, 18 Jul 2012 07:29:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrSRI-00064A-KI for emacs-devel@gnu.org; Wed, 18 Jul 2012 07:29:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrSRG-0004eu-Tz for emacs-devel@gnu.org; Wed, 18 Jul 2012 07:29:08 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:15050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrSRG-0004ej-La for emacs-devel@gnu.org; Wed, 18 Jul 2012 07:29:06 -0400 Original-Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6IBT5Ss025595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 18 Jul 2012 07:29:05 -0400 Original-Received: from localhost (dhcp-193-19.nrt.redhat.com [10.64.193.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6IBT1tR016744; Wed, 18 Jul 2012 07:29:04 -0400 In-Reply-To: <20120620.151738.1783513864733342718.yamato@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151729 Archived-At: Hi, If no objection, please, install this patch to the official source tree. I've attached the latest version. (I'm using this patch on gnome-shell, which provides generic(?) full-screen mode. The full-screen mode with this patch is quite nice.) Masatake YAMATO >>> + (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-24 15:06:24 +0000 +++ lisp/ChangeLog 2012-07-04 17:42:24 +0000 @@ -1,3 +1,15 @@ +2012-06-19 Masatake YAMATO + + * 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-24 Chong Yidong * xml.el (xml-parse-tag): Correctly handle comment embedded in === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-25 10:28:47 +0000 +++ src/ChangeLog 2012-06-25 12:38:35 +0000 @@ -1,3 +1,11 @@ +2012-06-19 Masatake YAMATO + + * 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-25 Andreas Schwab * keyboard.c (menu_bar_items, menu_bar_item, read_key_sequence): === 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 07:23:03 +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,38 @@ (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))) + (old-menu-bar-mode menu-bar-mode)) + (if (menu-bar-positive-p old-menu-bar-lines) + (accelerate-menu frame) + (letrec ((hide (lambda () + (remove-hook 'deactivate-menubar-hook hide) + (when (or (frame-live-p old-frame) + ;; Handle the case that if menu-bar-mode is + ;; turned on/off with choosing a menu item for controling the mode. + (or (eq old-menu-bar-mode menu-bar-mode) + (not menu-bar-mode))) + (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/keyboard.c' --- src/keyboard.c 2012-06-25 10:28:47 +0000 +++ src/keyboard.c 2012-06-25 12:37:36 +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; @@ -11527,6 +11528,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-06-25 04:05:48 +0000 +++ src/xmenu.c 2012-06-25 12:37:36 +0000 @@ -684,12 +684,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