]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/term/x-win.el (x-menu-bar-open): Use `frame-parameter'
authorMasatake YAMATO <yamato@redhat.com>
Fri, 20 Jul 2012 11:32:30 +0000 (07:32 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 20 Jul 2012 11:32:30 +0000 (07:32 -0400)
to check whether menu-bar is shown or not.  If not shown,
show the menu-bar as a popup menu instead of using tmm.
* lisp/mouse.el (popup-menu): Accept `point' as `position' argument.

lisp/ChangeLog
lisp/mouse.el
lisp/term/x-win.el

index d7cb05c0664fd3b1375beeceecad6988700239fd..969f36c84571a73ef11b028daea257e3207dae21 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-20  Masatake YAMATO  <yamato@redhat.com>
+
+       * term/x-win.el (x-menu-bar-open): Use `frame-parameter'
+       to check whether menu-bar is shown or not.  If not shown,
+       show the menu-bar as a popup menu instead of using tmm.
+       * mouse.el (popup-menu): Accept `point' as `position' argument.
+
 2012-07-20  Dmitry Gutov  <dgutov@yandex.ru>
 
        * progmodes/ruby-mode.el (ruby-parse-partial): No error when end
index a0d10a6494550befc5f25c17a5ac0bc26b216357..84b76e184a8d80e47a0a438eb1d9b3b1d18e00b5 100644 (file)
@@ -102,7 +102,8 @@ point at the click position."
 MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
 `x-popup-menu'.
 POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to
-  the current mouse position.
+  the current mouse position. If POSITION is a symbol, `point' the current point
+position is used.
 PREFIX is the prefix argument (if any) to pass to the command."
   (let* ((map (cond
               ((keymapp menu) menu)
@@ -112,9 +113,17 @@ PREFIX is the prefix argument (if any) to pass to the command."
                                   (plist-get (get map 'menu-prop) :filter))))
                    (if filter (funcall filter (symbol-function map)) map)))))
         event cmd)
-    (unless position
-      (let ((mp (mouse-pixel-position)))
-       (setq position (list (list (cadr mp) (cddr mp)) (car mp)))))
+  (setq position
+       (cond
+        ((eq position 'point)
+         (let* ((pp (posn-at-point pos window))
+                 (xy (posn-x-y pp)))
+           (list (list (car xy) (cdr xy)) (posn-window pp))))
+        ((not position)
+         (let ((mp (mouse-pixel-position)))
+           (list (list (cadr mp) (cddr mp)) (car mp))))
+        (t
+         position)))
     ;; The looping behavior was taken from lmenu's popup-menu-popup
     (while (and map (setq event
                          ;; map could be a prefix key, in which case
index 498cc01fe226ae4dea0184d6af3aedb309083e5e..fb7389b856ca8c17bfbab94259fcf0e0042127eb 100644 (file)
@@ -1305,12 +1305,18 @@ Request data types in the order specified by `x-select-request-type'."
 (declare-function accelerate-menu "xmenu.c" (&optional frame) t)
 
 (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 it is shown.
+`popup-menu' is used if it is off "
   (interactive "i")
-  (if (and menu-bar-mode
-          (fboundp 'accelerate-menu))
-      (accelerate-menu frame)
-    (tmm-menubar)))
+  (cond
+   ((and (not (zerop (or (frame-parameter nil 'menu-bar-lines) 0)))
+        (fboundp 'accelerate-menu))
+    (accelerate-menu frame))
+   (t
+    (popup-menu (mouse-menu-bar-map)
+               (if (listp last-nonmenu-event)
+                   nil
+                 'point)))))
 
 \f
 ;;; Window system initialization.