changeset 109467:d92d0e17a7ce

Merge from mainline.
author Katsumi Yamaoka <katsumi@flagship2>
date Sat, 17 Jul 2010 10:55:12 +0000
parents 11d5817a8846 (current diff) 7648120ec325 (diff)
children af1c1a57ee7f
files lisp/vc/vc.el
diffstat 22 files changed, 205 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/ChangeLog	Fri Jul 16 12:36:52 2010 +0000
+++ b/doc/misc/ChangeLog	Sat Jul 17 10:55:12 2010 +0000
@@ -1,3 +1,10 @@
+2010-07-17  Michael Albinus  <michael.albinus@gmx.de>
+
+	* tramp.texi (Inline methods): Remove remark about doubled "-t"
+	argument.
+	(Frequently Asked Questions): Recommend "sshx" and "scpx" for
+	echoing shells.
+
 2010-07-10  Michael Albinus  <michael.albinus@gmx.de>
 
 	* tramp.texi (Inline methods): Remove "kludgy" phrase.
Binary file doc/misc/tramp.texi has changed
--- a/etc/NEWS	Fri Jul 16 12:36:52 2010 +0000
+++ b/etc/NEWS	Sat Jul 17 10:55:12 2010 +0000
@@ -183,6 +183,8 @@
 
 *** `x-select-enable-clipboard' now defaults to t.
 
+*** `x-select-enable-primary' now defaults to nil.
+
 *** `mouse-drag-copy-region' now defaults to nil.
 
 *** `mouse-2' is now bound to `mouse-yank-primary'.
--- a/lisp/ChangeLog	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/ChangeLog	Sat Jul 17 10:55:12 2010 +0000
@@ -1,3 +1,28 @@
+2010-07-17  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-get-ls-command-with-dired): Make test for
+	"--dired" stronger.
+
+2010-07-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* term/x-win.el (x-select-enable-primary): Change default to nil.
+	(x-select-enable-clipboard): Add :version keyword.
+
+	* mouse.el (mouse-drag-copy-region):
+	* simple.el (select-active-regions): Likewise.
+
+2010-07-16  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* vc.el (vc-coding-system-inherit-eol): New defvar.
+	(vc-coding-system-for-diff): Use it to decide whether to inherit
+	from the file the EOL format for reading the diffs of that file.
+	(Bug#4451)
+
+2010-07-16  Eli Zaretskii  <eliz@gnu.org>
+
+	* mail/rmailmm.el (rmail-mime-save): Make the temp buffer
+	unibyte, so compressed attachments are not compressed again.
+
 2010-07-16  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp.el (tramp-handle-shell-command): Don't use hard-wired
@@ -22,6 +47,11 @@
 	* bookmark.el (bookmark-load-hook): Fix doc string as suggested
 	by Drew Adams (Bug#5504).
 
+2010-07-14  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xt-mouse.el (xterm-mouse-event-read): Fix for characters > 127
+	now that unicode is used (Bug#6594).
+
 2010-07-14  Chong Yidong  <cyd@stupidchicken.com>
 
 	* term/x-win.el (x-select-enable-clipboard): Default to t.
@@ -120,6 +150,20 @@
 	* net/tramp-gvfs.el (tramp-gvfs-handle-copy-file): Do not pass
 	empty argument to gvfs-copy.
 
+2010-07-10  Glenn Morris  <rgm@gnu.org>
+
+	* calendar/calendar.el (calendar-week-end-day): New function.
+	* calendar/cal-tex.el (cal-tex-cursor-month): Remove unused vars.
+	Respect calendar-week-start-day.  (Bug#6606)
+	(cal-tex-insert-day-names, cal-tex-insert-blank-days)
+	(cal-tex-insert-blank-days-at-end): Respect calendar-week-start-day.
+	(cal-tex-first-blank-p, cal-tex-last-blank-p): Simplify, and
+	respect calendar-week-start-day.
+
+2010-07-10  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (use-region-p): Doc fix (Bug#6607).
+
 2010-07-10  Aleksei Gusev  <aleksei.gusev@gmail.com>  (tiny change)
 
 	* progmodes/compile.el (compilation-error-regexp-alist-alist): Add
--- a/lisp/calendar/cal-tex.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/calendar/cal-tex.el	Sat Jul 17 10:55:12 2010 +0000
@@ -1,7 +1,7 @@
 ;;; cal-tex.el --- calendar functions for printing calendars with LaTeX
 
-;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Steve Fisk <fisk@bowdoin.edu>
 ;;         Edward M. Reingold <reingold@cs.uiuc.edu>
@@ -507,6 +507,7 @@
          (year (calendar-extract-year date))
          (end-month month)
          (end-year year)
+         ;; FIXME -landscape sets cal-tex-which-days?
          (d1 (calendar-absolute-from-gregorian (list month 1 year)))
          (d2 (progn
                (calendar-increment-month end-month end-year (1- n))
@@ -515,8 +516,7 @@
                       (calendar-last-day-of-month end-month end-year)
                       end-year))))
          (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2)))
-         (holidays (if cal-tex-holidays (cal-tex-list-holidays d1 d2)))
-         other-month other-year)
+         (holidays (if cal-tex-holidays (cal-tex-list-holidays d1 d2))))
     (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil "12pt")
     (if (> n 1)
         (cal-tex-cmd cal-tex-cal-multi-month)
@@ -526,14 +526,12 @@
     (cal-tex-nl ".2cm")
     (cal-tex-insert-blank-days month year cal-tex-day-prefix)
     (dotimes (idummy n)
-      (setq other-month month
-            other-year year)
       (cal-tex-insert-days month year diary-list holidays cal-tex-day-prefix)
-      (when (= 6 (mod (calendar-absolute-from-gregorian
-                       (list month
-                             (calendar-last-day-of-month month year)
-                             year))
-                      7))           ; last day of month was Saturday
+      (when (= (calendar-week-end-day)
+               (calendar-day-of-week
+                (list month
+                      (calendar-last-day-of-month month year)
+                      year))) ; last day of month was last day of week
         (cal-tex-hfill)
         (cal-tex-nl))
       (calendar-increment-month month year 1))
@@ -570,13 +568,14 @@
 
 (defun cal-tex-insert-day-names ()
   "Insert the names of the days at top of a monthly calendar."
-  (dotimes (i 7)
-    (if (memq i cal-tex-which-days)
-        (insert (format cal-tex-day-name-format
-                        (cal-tex-LaTeXify-string
-                         (aref calendar-day-name-array
-                               (mod (+ calendar-week-start-day i) 7))))))
-    (cal-tex-comment)))
+  (let (j)
+    (dotimes (i 7)
+      (if (memq (setq j (mod (+ calendar-week-start-day i) 7))
+                cal-tex-which-days)
+          (insert (format cal-tex-day-name-format
+                          (cal-tex-LaTeXify-string
+                           (aref calendar-day-name-array j)))))
+      (cal-tex-comment))))
 
 (defun cal-tex-insert-month-header (n month year end-month end-year)
   "Create a title for a calendar.
@@ -603,7 +602,7 @@
                  calendar-week-start-day)
               7)))
         (dotimes (i blank-days)
-          (if (memq i cal-tex-which-days)
+          (if (memq (mod (+ calendar-week-start-day i) 7) cal-tex-which-days)
               (insert (format day-format " " " ") "{}{}{}{}%\n"))))))
 
 (defun cal-tex-insert-blank-days-at-end (month year day-format)
@@ -619,38 +618,37 @@
                7))
              (i blank-days))
         (while (<= (setq i (1+ i)) 6)
-          (if (memq i cal-tex-which-days)
+          (if (memq (mod (+ calendar-week-start-day i) 7) cal-tex-which-days)
               (insert (format day-format "" "") "{}{}{}{}%\n"))))))
 
 (defun cal-tex-first-blank-p (month year)
   "Determine if any days of the first week will be printed.
 Return t if there will there be any days of the first week printed
 in the calendar starting in MONTH YEAR."
-  (let (any-days the-saturday)        ; the day of week of 1st Saturday
-    (dotimes (i 7)
-      (if (= 6 (calendar-day-of-week (list month (1+ i) year)))
-          (setq the-saturday (1+ i))))
-    (dotimes (i the-saturday)
-      (if (memq (calendar-day-of-week (list month (1+ i) year))
-                cal-tex-which-days)
-          (setq any-days t)))
-    any-days))
+  ;; Check days 1-7 of the month, until we find the last day of the week.
+  (catch 'found
+    (let (dow)
+      (dotimes (i 7)
+        (if (memq (setq dow (calendar-day-of-week (list month (1+ i) year)))
+                  cal-tex-which-days)
+            (throw 'found t)
+          (if (= dow (calendar-week-end-day)) (throw 'found nil)))))))
 
 (defun cal-tex-last-blank-p (month year)
   "Determine if any days of the last week will be printed.
 Return t if there will there be any days of the last week printed
 in the calendar starting in MONTH YEAR."
-  (let* ((last-day (calendar-last-day-of-month month year))
-         (i (- last-day 7))
-         any-days the-sunday)          ; the day of week of last Sunday
-    (while (<= (setq i (1+ i)) last-day)
-      (if (zerop (calendar-day-of-week (list month i year)))
-          (setq the-sunday i)))
-    (setq i (1- the-sunday))
-    (while (<= (setq i (1+ i)) last-day)
-      (if (memq (calendar-day-of-week (list month i year)) cal-tex-which-days)
-          (setq any-days t)))
-    any-days))
+  ;; Check backwards from the last day of the month, until we find the
+  ;; start of the last week in the month.
+  (catch 'found
+    (let ((last-day (calendar-last-day-of-month month year))
+          day dow)
+      (dotimes (i 7)
+        (if (memq (setq dow (calendar-day-of-week
+                             (list month (- last-day i) year)))
+                  cal-tex-which-days)
+            (throw 'found t)
+          (if (= dow calendar-week-start-day) (throw 'found nil)))))))
 
 (defun cal-tex-number-weeks (month year n)
   "Determine the number of weeks in a range of dates.
@@ -1499,7 +1497,7 @@
           (- (calendar-day-of-week (list month 1 year))
              calendar-week-start-day)
           7))
-        (last (calendar-last-day-of-month month year))
+        (last( calendar-last-day-of-month month year))
         (str (concat "\\def\\" name "{\\hbox to" width "{%\n"
                      "\\vbox to" height "{%\n"
                      "\\vfil  \\hbox to" width "{%\n"
--- a/lisp/calendar/calendar.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/calendar/calendar.el	Sat Jul 17 10:55:12 2010 +0000
@@ -2226,6 +2226,10 @@
 interpreted as BC; -1 being 1 BC, and so on."
   (mod (calendar-absolute-from-gregorian date) 7))
 
+(defun calendar-week-end-day ()
+  "Return the index (0 for Sunday, etc.) of the last day of the week."
+  (mod (+ calendar-week-start-day 6) 7))
+
 (defun calendar-unmark ()
   "Delete all diary/holiday marks/highlighting from the calendar."
   (interactive)
--- a/lisp/mail/rmail.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/mail/rmail.el	Sat Jul 17 10:55:12 2010 +0000
@@ -4291,7 +4291,7 @@
 
 ;;;***
 
-;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "93033f2136fcd111e2b52a116ff4cf29")
+;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "4a7502b4aeb3bd5f2111b48cc6512924")
 ;;; Generated autoloads from rmailmm.el
 
 (autoload 'rmail-mime "rmailmm" "\
--- a/lisp/mail/rmailmm.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/mail/rmailmm.el	Sat Jul 17 10:55:12 2010 +0000
@@ -112,6 +112,10 @@
 			(file-name-as-directory filename))))
     (with-temp-buffer
       (set-buffer-file-coding-system 'no-conversion)
+      ;; Needed e.g. by jka-compr, so if the attachment is a compressed
+      ;; file, the magic signature compares equal with the unibyte
+      ;; signature string recorded in jka-compr-compression-info-list.
+      (set-buffer-multibyte nil)
       (insert data)
       (write-region nil nil filename nil nil nil t))))
 
--- a/lisp/mouse.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/mouse.el	Sat Jul 17 10:55:12 2010 +0000
@@ -44,7 +44,7 @@
 (defcustom mouse-drag-copy-region nil
   "If non-nil, mouse drag copies region to kill-ring."
   :type 'boolean
-  :version "22.1"
+  :version "24.1"
   :group 'mouse)
 
 (defcustom mouse-1-click-follows-link 450
--- a/lisp/net/tramp.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/net/tramp.el	Sat Jul 17 10:55:12 2010 +0000
@@ -1037,6 +1037,7 @@
 ;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin
 ;; GNU/Linux (Debian, Suse): /bin:/usr/bin
 ;; FreeBSD: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"!
+;; IRIX64: /usr/bin
 (defcustom tramp-remote-path
   '(tramp-default-remote-path "/usr/sbin" "/usr/local/bin"
     "/local/bin" "/local/freeware/bin" "/local/gnu/bin"
@@ -8335,8 +8336,11 @@
   (save-match-data
     (with-connection-property vec "ls-dired"
       (tramp-message vec 5 "Checking, whether `ls --dired' works")
+      ;; Some "ls" versions are sensible wrt the order of arguments,
+      ;; they fail when "-al" is after the "--dired" argument (for
+      ;; example on FreeBSD).
       (zerop (tramp-send-command-and-check
-	      vec (format "%s --dired /" (tramp-get-ls-command vec)))))))
+	      vec (format "%s --dired -al /" (tramp-get-ls-command vec)))))))
 
 (defun tramp-get-test-command (vec)
   (with-connection-property vec "test"
@@ -8936,7 +8940,6 @@
 ;;   without built-in uuencode/uudecode.
 ;; * Let `shell-dynamic-complete-*' and `comint-dynamic-complete' work
 ;;   on remote hosts.
-;; * Use secrets.el for password handling.
 ;; * Load ~/.emacs_SHELLNAME on the remote host for `shell'.
 
 ;; Functions for file-name-handler-alist:
--- a/lisp/simple.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/simple.el	Sat Jul 17 10:55:12 2010 +0000
@@ -3670,7 +3670,7 @@
   "If non-nil, an active region automatically becomes the window selection."
   :type 'boolean
   :group 'killing
-  :version "23.1")
+  :version "24.1")
 
 (declare-function x-selection-owner-p "xselect.c" (&optional selection))
 
@@ -3761,10 +3761,9 @@
 This is used by commands that act specially on the region under
 Transient Mark mode.
 
-The return value is t provided Transient Mark mode is enabled and
-the mark is active; and, when `use-empty-active-region' is
-non-nil, provided the region is empty.  Otherwise, the return
-value is nil.
+The return value is t if Transient Mark mode is enabled and the
+mark is active; furthermore, if `use-empty-active-region' is nil,
+the region must not be empty.  Otherwise, the return value is nil.
 
 For some commands, it may be appropriate to ignore the value of
 `use-empty-active-region'; in that case, use `region-active-p'."
--- a/lisp/term/x-win.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/term/x-win.el	Sat Jul 17 10:55:12 2010 +0000
@@ -1223,12 +1223,14 @@
   "Non-nil means cutting and pasting uses the clipboard.
 This is in addition to, but in preference to, the primary selection."
   :type 'boolean
-  :group 'killing)
+  :group 'killing
+  :version "24.1")
 
-(defcustom x-select-enable-primary t
+(defcustom x-select-enable-primary nil
   "Non-nil means cutting and pasting uses the primary selection."
   :type 'boolean
-  :group 'killing)
+  :group 'killing
+  :version "24.1")
 
 (defun x-select-text (text &optional push)
   "Select TEXT, a string, according to the window system.
--- a/lisp/vc/vc.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/vc/vc.el	Sat Jul 17 10:55:12 2010 +0000
@@ -1437,6 +1437,16 @@
 ;;          (vc-call-backend ',(vc-backend f)
 ;;                           'diff (list ',f) ',rev1 ',rev2))))))
 
+(defvar vc-coding-system-inherit-eol t
+  "When non-nil, inherit the EOL format for reading Diff output from the file.
+
+Used in `vc-coding-system-for-diff' to determine the EOL format to use
+for reading Diff output for a file.  If non-nil, the EOL format is
+inherited from the file itself.
+Set this variable to nil if your Diff tool might use a different
+EOL.  Then Emacs will auto-detect the EOL format in Diff output, which
+gives better results.") ;; Cf. bug#4451.
+
 (defun vc-coding-system-for-diff (file)
   "Return the coding system for reading diff output for FILE."
   (or coding-system-for-read
@@ -1444,7 +1454,12 @@
       ;; use the buffer's coding system
       (let ((buf (find-buffer-visiting file)))
         (when buf (with-current-buffer buf
-		    buffer-file-coding-system)))
+		    (if vc-coding-system-inherit-eol
+			buffer-file-coding-system
+		      ;; Don't inherit the EOL part of the coding-system,
+		      ;; because some Diff tools may choose to use
+		      ;; a different one.  bug#4451.
+		      (coding-system-base buffer-file-coding-system)))))
       ;; otherwise, try to find one based on the file name
       (car (find-operation-coding-system 'insert-file-contents file))
       ;; and a final fallback
--- a/lisp/xt-mouse.el	Fri Jul 16 12:36:52 2010 +0000
+++ b/lisp/xt-mouse.el	Sat Jul 17 10:55:12 2010 +0000
@@ -122,8 +122,8 @@
 ;; read xterm sequences above ascii 127 (#x7f)
 (defun xterm-mouse-event-read ()
   (let ((c (read-char)))
-    (if (< c 0)
-        (+ c #x8000000 128)
+    (if (> c #x3FFF80)
+        (+ 128 (- c #x3FFF80))
       c)))
 
 (defun xterm-mouse-truncate-wrap (f)
--- a/src/ChangeLog	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/ChangeLog	Sat Jul 17 10:55:12 2010 +0000
@@ -1,3 +1,25 @@
+2010-07-14  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xterm.h (x_menubar_window_to_frame): Second parameter is XEvent*.
+
+	* xterm.c (handle_one_xevent): Pass event to x_menubar_window_to_frame.
+
+	* xmenu.c (x_activate_menubar): Revert previous fix for Bug#6499,
+	i.e. don't put back ButtonRelease (Bug#6608).
+
+	* xfns.c (x_menubar_window_to_frame): Take XEvent as second parameter
+	instead of Window.  Call xg_event_is_for_menubar when
+	USE_GTK (Bug#6499).
+
+	* gtkutil.h (xg_event_is_for_menubar): Declare.
+
+	* gtkutil.c (xg_event_is_for_menubar): New function (Bug#6499).
+
+2010-07-14  Eli Zaretskii  <eliz@gnu.org>
+
+	* w32fns.c (x_set_foreground_color): Fix setting the cursor color
+	when it's the same as the old foreground.  (Bug#6609)
+
 2010-07-16  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* xmenu.c (free_frame_menubar): Only call x_set_window_size if
--- a/src/gtkutil.c	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/gtkutil.c	Sat Jul 17 10:55:12 2010 +0000
@@ -2856,6 +2856,38 @@
     }
 }
 
+int
+xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
+{
+  struct x_output *x = f->output_data.x;
+
+  if (! x->menubar_widget) return 0;
+
+  if (! (event->xbutton.x >= 0
+         && event->xbutton.x < FRAME_PIXEL_WIDTH (f)
+         && event->xbutton.y >= 0
+         && event->xbutton.y < f->output_data.x->menubar_height
+         && event->xbutton.same_screen))
+    return 0;
+
+  GList *list = gtk_container_get_children (GTK_CONTAINER (x->menubar_widget));
+  if (! list) return 0;
+  GList *iter;
+  GdkRectangle rec;
+  rec.x = event->xbutton.x;
+  rec.y = event->xbutton.y;
+  rec.width = 1;
+  rec.height = 1;
+  for (iter = list ; iter; iter = g_list_next (iter))
+    {
+      GtkWidget *w = GTK_WIDGET (iter->data);
+      if (GTK_WIDGET_MAPPED (w) && gtk_widget_intersect (w, &rec, NULL))
+        break;
+    }
+  g_list_free (list);
+  return iter == 0 ? 0 : 1;
+}
+
 
 
 /***********************************************************************
--- a/src/gtkutil.h	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/gtkutil.h	Sat Jul 17 10:55:12 2010 +0000
@@ -153,6 +153,8 @@
 
 extern int xg_update_frame_menubar (FRAME_PTR f);
 
+extern int xg_event_is_for_menubar (FRAME_PTR f, XEvent *event);
+
 extern int xg_have_tear_offs (void);
 
 extern int xg_get_scroll_id_for_window (Display *dpy, Window wid);
--- a/src/w32fns.c	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/w32fns.c	Sat Jul 17 10:55:12 2010 +0000
@@ -1333,7 +1333,10 @@
   if (FRAME_W32_WINDOW (f) != 0)
     {
       if (x->cursor_pixel == old_fg)
-	x->cursor_pixel = fg;
+	{
+	  x->cursor_pixel = fg;
+	  x->cursor_gc->background = fg;
+	}
 
       update_face_from_frame_parameter (f, Qforeground_color, arg);
       if (FRAME_VISIBLE_P (f))
--- a/src/xfns.c	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/xfns.c	Sat Jul 17 10:55:12 2010 +0000
@@ -398,8 +398,9 @@
 /* Likewise, but consider only the menu bar widget.  */
 
 struct frame *
-x_menubar_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
+x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event)
 {
+  Window wdesc = event->xany.window;
   Lisp_Object tail, frame;
   struct frame *f;
   struct x_output *x;
@@ -415,21 +416,11 @@
       if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
 	continue;
       x = f->output_data.x;
+#ifdef USE_GTK
+      if (x->menubar_widget && xg_event_is_for_menubar (f, event))
+        return f;
+#else
       /* Match if the window is this frame's menubar.  */
-#ifdef USE_GTK
-      if (x->menubar_widget)
-        {
-          GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
-
-	  /* This gives false positives, but the rectangle check in xterm.c
-	     where this is called takes care of that.  */
-          if (gwdesc != 0
-              && (gwdesc == x->menubar_widget
-                  || gtk_widget_is_ancestor (x->menubar_widget, gwdesc)
-		  || gtk_widget_is_ancestor (gwdesc, x->menubar_widget)))
-            return f;
-        }
-#else
       if (x->menubar_widget
 	  && lw_window_is_in_menubar (wdesc, x->menubar_widget))
 	return f;
--- a/src/xmenu.c	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/xmenu.c	Sat Jul 17 10:55:12 2010 +0000
@@ -664,14 +664,6 @@
   BLOCK_INPUT;
   popup_activated_flag = 1;
 #ifdef USE_GTK
-  /* If we click outside any menu item, the menu bar still grabs.
-     So we send Press and the Release.  If outside, grab is released.
-     If on a menu item, it is popped up normally.
-     PutBack is like a stack, so we put back in reverse order.  */
-  f->output_data.x->saved_menu_event->type = ButtonRelease;
-  XPutBackEvent (f->output_data.x->display_info->display,
-                 f->output_data.x->saved_menu_event);
-  f->output_data.x->saved_menu_event->type = ButtonPress;
   XPutBackEvent (f->output_data.x->display_info->display,
                  f->output_data.x->saved_menu_event);
 #else
--- a/src/xterm.c	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/xterm.c	Sat Jul 17 10:55:12 2010 +0000
@@ -6743,7 +6743,7 @@
 	  f->mouse_moved = 0;
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
-        f = x_menubar_window_to_frame (dpyinfo, event.xbutton.window);
+        f = x_menubar_window_to_frame (dpyinfo, &event);
         /* For a down-event in the menu bar,
            don't pass it to Xt right now.
            Instead, save it away
--- a/src/xterm.h	Fri Jul 16 12:36:52 2010 +0000
+++ b/src/xterm.h	Sat Jul 17 10:55:12 2010 +0000
@@ -381,12 +381,15 @@
 #endif
 
 /* This checks to make sure we have a display.  */
+
 extern void check_x (void);
 
 extern struct frame *x_window_to_frame (struct x_display_info *, int);
 
 extern struct frame *x_any_window_to_frame (struct x_display_info *, int);
-extern struct frame *x_menubar_window_to_frame (struct x_display_info *, int);
+extern struct frame *x_menubar_window_to_frame (struct x_display_info *,
+						XEvent *);
+
 extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
 
 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)