=== modified file 'src/core/display.c'
--- src/core/display.c	2009-08-22 17:12:35 +0000
+++ src/core/display.c	2009-08-22 19:44:42 +0000
@@ -77,6 +77,7 @@
 #include <X11/extensions/Xfixes.h>
 #endif
 #include <string.h>
+#include <gdk/gdk.h>
 
 #define GRAB_OP_IS_WINDOW_SWITCH(g)                     \
         (g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL  ||  \
@@ -1777,9 +1778,38 @@
         }
       break;
     case ButtonRelease:
-      if (display->grab_window == window &&
-          grab_op_is_mouse (display->grab_op))
-        meta_window_handle_mouse_grab_op_event (window, event);
+      if (display->grab_window == window)
+        {
+          if (grab_op_is_mouse (display->grab_op))
+            meta_window_handle_mouse_grab_op_event (window, event);
+          else if (display->grab_op == META_GRAB_OP_CLICKING_MENU &&
+              meta_prefs_get_close_on_double_click_menu ())
+            {
+              /* We can't rely on GTK's idea of what a double-click is
+               * here, since we're on our own during a grab. And X itself
+               * doesn't grok the concept of double-clicks. So we keep a
+               * track of when they last clicked on the menu button...
+               */
+              static unsigned long previous_menu_click = 0;
+
+              guint click_delay = event->xbutton.time - previous_menu_click;
+              previous_menu_click = event->xbutton.time;
+
+              /* But we *can* ask GDK how long it thinks a double-click
+               * should take.
+               */
+              if (click_delay <= gdk_display_get_default ()->double_click_time
+                  && click_delay >= 0 /* being careful of wraps */ )
+                {
+                  /* Okay, so they double-clicked the menu button. */
+                  meta_display_end_grab_op (display,
+                                            event->xbutton.time);
+
+                  if (window && window->has_close_func)
+                    meta_window_delete (window, event->xbutton.time);
+                }
+            }
+        }
       break;
     case MotionNotify:
       if (display->grab_window == window &&

=== modified file 'src/core/prefs.c'
--- src/core/prefs.c	2009-08-22 17:12:35 +0000
+++ src/core/prefs.c	2009-08-22 19:44:42 +0000
@@ -50,6 +50,7 @@
 #define KEY_TITLEBAR_FONT "/apps/metacity/general/titlebar_font"
 #define KEY_NUM_WORKSPACES "/apps/metacity/general/num_workspaces"
 #define KEY_COMPOSITOR "/apps/metacity/general/compositing_manager"
+#define KEY_CLOSE_ON_DOUBLE_CLICK_MENU "/apps/metacity/general/close_on_double_click_menu"
 #define KEY_GNOME_ACCESSIBILITY "/desktop/gnome/interface/accessibility"
 
 #define KEY_COMMAND_PREFIX "/apps/metacity/keybinding_commands/command_"
@@ -89,6 +90,7 @@
 static gboolean provide_visual_bell = FALSE;
 static gboolean bell_is_audible = TRUE;
 static gboolean reduced_resources = FALSE;
+static gboolean close_on_double_click_menu = FALSE;
 static gboolean gnome_accessibility = FALSE;
 static gboolean gnome_animations = TRUE;
 static char *cursor_theme = NULL;
@@ -389,6 +391,11 @@
       &reduced_resources,
       FALSE,
     },
+    { "/apps/metacity/general/close_on_double_click_menu",
+      META_PREF_CLOSE_ON_DOUBLE_CLICK_MENU,
+      &close_on_double_click_menu,
+      FALSE,
+    },
     { "/desktop/gnome/interface/accessibility",
       META_PREF_GNOME_ACCESSIBILITY,
       &gnome_accessibility,
@@ -1734,6 +1741,9 @@
     case META_PREF_REDUCED_RESOURCES:
       return "REDUCED_RESOURCES";
 
+    case META_PREF_CLOSE_ON_DOUBLE_CLICK_MENU:
+      return "CLOSE_ON_DOUBLE_CLICK_MENU";
+
     case META_PREF_GNOME_ACCESSIBILITY:
       return "GNOME_ACCESSIBILTY";
 
@@ -2647,6 +2657,12 @@
 }
 
 gboolean
+meta_prefs_get_close_on_double_click_menu (void)
+{
+  return close_on_double_click_menu;
+}
+
+gboolean
 meta_prefs_get_gnome_accessibility ()
 {
   return gnome_accessibility;

=== modified file 'src/include/prefs.h'
--- src/include/prefs.h	2009-08-22 17:12:35 +0000
+++ src/include/prefs.h	2009-08-22 19:44:42 +0000
@@ -54,6 +54,7 @@
   META_PREF_AUDIBLE_BELL,
   META_PREF_VISUAL_BELL_TYPE,
   META_PREF_REDUCED_RESOURCES,
+  META_PREF_CLOSE_ON_DOUBLE_CLICK_MENU,
   META_PREF_GNOME_ACCESSIBILITY,
   META_PREF_GNOME_ANIMATIONS,
   META_PREF_CURSOR_THEME,
@@ -88,6 +89,7 @@
 gboolean                    meta_prefs_get_auto_raise         (void);
 int                         meta_prefs_get_auto_raise_delay   (void);
 gboolean                    meta_prefs_get_reduced_resources  (void);
+gboolean                    meta_prefs_get_close_on_double_click_menu (void);
 gboolean                    meta_prefs_get_gnome_accessibility (void);
 gboolean                    meta_prefs_get_gnome_animations   (void);
 

=== modified file 'src/metacity.schemas'
--- src/metacity.schemas	2009-08-22 17:12:35 +0000
+++ src/metacity.schemas	2009-08-22 19:44:42 +0000
@@ -7750,6 +7750,23 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/metacity/general/close_on_double_click_menu</key>
+      <applyto>/apps/metacity/general/close_on_double_click_menu</applyto>
+      <owner>metacity</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+         <short>If true, close windows when their menu icon is double clicked</short>
+         <long>
+           If true, user will be able to close the window by double clicking
+           its menu button.  This can be considered harmful if the application
+           does not ask to save changes prior to exit, as the user may
+           accidentally lose its work.
+         </long>
+      </locale>
+    </schema>
+
     <!-- Keybindings -->
 
     <schema>

=== modified file 'src/metacity.schemas.in'
--- src/metacity.schemas.in	2009-08-22 17:12:35 +0000
+++ src/metacity.schemas.in	2009-08-22 19:44:42 +0000
@@ -421,6 +421,24 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/metacity/general/close_on_double_click_menu</key>
+      <applyto>/apps/metacity/general/close_on_double_click_menu</applyto>
+      <owner>metacity</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+         <short>If true, close windows when their menu icon is double clicked</short>
+         <long>
+           If true, user will be able to close the window by double clicking
+           its menu button.  This can be considered harmful if the application
+           does not ask to save changes prior to exit, as the user may
+           accidentally lose its work.
+         </long>
+      </locale>
+    </schema>
+
+
     <!-- Keybindings -->
 
     <schema>

