Index: src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.297
diff -u -p -r1.297 display.c
--- src/display.c	13 Oct 2006 00:28:23 -0000	1.297
+++ src/display.c	14 Nov 2006 03:10:37 -0000
@@ -66,6 +66,7 @@
 #include <X11/Xcursor/Xcursor.h>
 #endif
 #include <string.h>
+#include <gdk/gdkdisplay.h>
 
 #define GRAB_OP_IS_WINDOW_SWITCH(g)                     \
         (g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL  ||  \
@@ -1811,6 +1812,75 @@ event_callback (XEvent   *event,
           event->xany.serial >= display->grab_start_serial &&
           grab_op_is_mouse (display->grab_op))
         meta_window_handle_mouse_grab_op_event (window, event);
+
+      if (window && window->has_resize_func)
+        {
+          /* We can't rely on GTK's idea of what a double-click is
+           * here. And X itself doesn't grok the concept of
+           * double-clicks. So we keep a track of when they
+           * last clicked on the frame...
+           */
+          static unsigned long previous_frame_click = 0;
+              
+          guint click_delay = event->xbutton.time - previous_frame_click;
+
+          /* But we *can* ask GDK how long it thinks a double-click
+           * should take.
+           */
+          if (click_delay <= gdk_display_get_default()->double_click_time)
+            {
+              /* Okay, so they double-clicked. */
+
+              MetaRectangle work_area;
+              MetaRectangle outer;
+              int x, y;
+              int frame_width, frame_height;
+              int rect_width, rect_height;
+
+              gboolean north, south, west, east;
+
+              meta_window_get_work_area_all_xineramas (window, &work_area);
+              meta_window_get_outer_rect (window, &outer);
+              meta_window_get_position (window, &x, &y);
+
+              west = event->xbutton.x_root <  (x + 1 * window->rect.width  / 3);
+              east = event->xbutton.x_root >  (x + 2 * window->rect.width  / 3);
+              north = event->xbutton.y_root < (y + 1 * window->rect.height / 3);
+              south = event->xbutton.y_root > (y + 2 * window->rect.height / 3);
+
+              frame_width = (window->frame ? window->frame->child_x : 0);
+              frame_height = (window->frame ? window->frame->child_y : 0);
+
+              rect_width = window->rect.width;
+              rect_height = window->rect.height;
+
+              if (west)
+                {
+                  rect_width += x;
+                  x = 0;
+                }
+              else if (east)
+                rect_width = (work_area.width) - (x - frame_width);
+               
+              if (north)
+                {
+                  rect_height += y;
+                  y = 0;
+                }
+              else if (south)
+                rect_height = (work_area.height) - (y - frame_height);
+
+              meta_window_move_resize (window,
+                  FALSE,
+                  x,
+                  y,
+                  rect_width,
+                  rect_height);
+            }
+
+           previous_frame_click = event->xbutton.time;
+        }
+
       break;
     case MotionNotify:
       if (display->grab_window == window &&
