Index: metacity/metacity-2.14.5/src/display.c
===================================================================
--- metacity.orig/metacity-2.14.5/src/display.c	2006-06-10 23:41:41.000000000 +0100
+++ metacity/metacity-2.14.5/src/display.c	2006-06-19 23:45:17.000000000 +0100
@@ -40,6 +40,7 @@
 #include "bell.h"
 #include "effects.h"
 #include "compositor.h"
+#include "window.h"
 #include <X11/Xatom.h>
 #include <X11/cursorfont.h>
 #ifdef HAVE_SOLARIS_XINERAMA
@@ -1334,81 +1335,32 @@
   return meta_ui_get_double_click_timeout (screen->ui);
 }                                
 
-#if 0
 static void
 handle_net_moveresize_window (MetaDisplay* display,
                               XEvent *event)
 {
   MetaWindow *window;
-  int x, y, width, height;
-  gboolean only_resize;
-  unsigned int gravity;
-  unsigned int mode;
+  guint gravity, mode, source;
 
   window = meta_display_lookup_x_window (display,
                                          event->xclient.window);
+  if(!window)
+    return;
 
-  /*
-   * FIXME: The specification seems to have serious endian issues
-   * here.  Does bits 8-11 mean the high-order byte, or the low-order
-   * byte?
-   */
-  gravity = (event->xclient.data.l[0] & ~0xff);
-  mode = (event->xclient.data.l[0] & ~0xff00) >> 8;
-
-  if (window)
-    {
-      /* FIXME!!!!  This function is _wrong_ except for the resize-only
-       * case.  Even then, it sucks to special case the code instead of
-       * factoring out common functionality with the configure reqest
-       * handling, especially since the EWMH says this message should be
-       * treated identically to a configure request with the exception of
-       * having a special gravity specified.
-       */
-      meta_window_get_gravity_position (window, &x, &y);
-      width = window->rect.width;
-      height = window->rect.height;
-
-      if (mode & (CWX | CWY))
-        only_resize = FALSE;
-      else
-        only_resize = TRUE;
-
-      if (mode & CWX)
-        x = event->xclient.data.l[1];
-      if (mode & CWY)
-        y = event->xclient.data.l[2];
-      if (mode & CWWidth)
-        width = event->xclient.data.l[3];
-      if (mode & CWHeight)
-        height = event->xclient.data.l[4];
-
-      if (only_resize)
-        {
-          if (gravity)
-	    meta_window_resize_with_gravity (window,
-					     FALSE,
-					     width,
-					     height,
-					     gravity);
-          else
-            meta_window_resize (window,
-				FALSE,
-				width,
-				height);
-        }
-      else
-        {
-          meta_window_move_resize (window,
-                                   FALSE,
-                                   x,
-                                   y,
-                                   width,
-                                   height);
-        }
-    }
+  gravity = (event->xclient.data.l[0] & 0xff);
+  mode = (event->xclient.data.l[0] & 0xf00) >> 8;
+  source = (event->xclient.data.l[0] & 0xf000) >> 12;
+
+  meta_window_move_resize_request(window,
+                                  mode,
+                                  gravity,
+                                  event->xclient.data.l[1],  // x
+                                  event->xclient.data.l[2],  // y
+                                  event->xclient.data.l[3],  // width
+                                  event->xclient.data.l[4]); // height
 }
 
+#if 0
 static void
 handle_net_restack_window (MetaDisplay* display,
                            XEvent *event)
@@ -2200,13 +2152,13 @@
             else if (event->xproperty.atom ==
                      display->atom_net_desktop_names)
               meta_screen_update_workspace_names (screen);
+            else if (event->xproperty.atom ==
+                     display->atom_net_moveresize_window)
+              handle_net_moveresize_window (display, event);
 #if 0
             else if (event->xproperty.atom ==
                      display->atom_net_restack_window)
               handle_net_restack_window (display, event);
-            else if (event->xproperty.atom ==
-                     display->atom_net_moveresize_window)
-              handle_net_moveresize_window (display, event);
 #endif
 
             /* we just use this property as a sentinel to avoid
Index: metacity/metacity-2.14.5/src/window.c
===================================================================
--- metacity.orig/metacity-2.14.5/src/window.c	2006-06-19 23:09:31.000000000 +0100
+++ metacity/metacity-2.14.5/src/window.c	2006-06-19 23:50:36.000000000 +0100
@@ -4092,15 +4092,20 @@
     meta_error_trap_pop (window->display, FALSE);
 }
 
-gboolean
-meta_window_configure_request (MetaWindow *window,
-                               XEvent     *event)
+void
+meta_window_move_resize_request(MetaWindow *window,
+                                guint flags,
+                                guint new_gravity,
+                                gint new_x,
+                                gint new_y,
+                                gint new_width,
+                                gint new_height)
 {
   int x, y, width, height;
   gboolean only_resize;
   gboolean allow_position_change;
   gboolean in_grab_op;
-  MetaMoveResizeFlags flags;
+  MetaMoveResizeFlags meta_flags;
 
   /* We ignore configure requests while the user is moving/resizing
    * the window, since these represent the app sucking and fighting
@@ -4140,7 +4145,6 @@
    * server-side position in effect when the configure request was
    * generated.
    */
-
   meta_window_get_gravity_position (window, &x, &y);
 
   only_resize = TRUE;
@@ -4171,13 +4175,11 @@
   
   if (allow_position_change)
     {
-      if (event->xconfigurerequest.value_mask & CWX)
-        x = event->xconfigurerequest.x;
-      
-      if (event->xconfigurerequest.value_mask & CWY)
-        y = event->xconfigurerequest.y;
-
-      if (event->xconfigurerequest.value_mask & (CWX | CWY))
+      if (flags & CWX)
+        x = new_x;
+      if (flags & CWY)
+        y = new_y;
+      if (flags & (CWX | CWY))
         {
           only_resize = FALSE;
 
@@ -4198,35 +4200,26 @@
 
   width = window->rect.width;
   height = window->rect.height;
-
   if (!in_grab_op)
     {
-      if (event->xconfigurerequest.value_mask & CWWidth)
-        width = event->xconfigurerequest.width;
+      if (flags & CWWidth)
+        width = new_width;
       
-      if (event->xconfigurerequest.value_mask & CWHeight)
-        height = event->xconfigurerequest.height;
+      if (flags & CWHeight)
+        height = new_height;
     }
 
   /* ICCCM 4.1.5 */
   
-  /* Note that x, y is the corner of the window border,
-   * and width, height is the size of the window inside
-   * its border, but that we always deny border requests
-   * and give windows a border of 0. But we save the
-   * requested border here.
-   */
-  if (event->xconfigurerequest.value_mask & CWBorderWidth)
-    window->border_width = event->xconfigurerequest.border_width;
-
   /* We're ignoring the value_mask here, since sizes
    * not in the mask will be the current window geometry.
    */
-  
   window->size_hints.x = x;
   window->size_hints.y = y;
   window->size_hints.width = width;
   window->size_hints.height = height;
+  if (new_gravity)
+    window->size_hints.win_gravity = new_gravity;
 
   /* FIXME passing the gravity on only_resize thing is kind of crack-rock.
    * Basically I now have several ways of handling gravity, and things
@@ -4239,22 +4232,45 @@
    * setup requires the only_resize thing.  Yeah, it'd be much better to
    * have a different setup for meta_window_move_resize_internal()...
    */
-  
-  flags = META_IS_CONFIGURE_REQUEST;
-  if (event->xconfigurerequest.value_mask & (CWX | CWY))
-    flags |= META_IS_MOVE_ACTION;
-  if (event->xconfigurerequest.value_mask & (CWWidth | CWHeight))
-    flags |= META_IS_RESIZE_ACTION;
+  meta_flags = META_IS_CONFIGURE_REQUEST;
+  if (flags & (CWX | CWY))
+    meta_flags |= META_IS_MOVE_ACTION;
+  if (flags & (CWWidth | CWHeight))
+    meta_flags |= META_IS_RESIZE_ACTION;
 
-  if (flags & (META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION))
+  if (meta_flags & (META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION))
     meta_window_move_resize_internal (window, 
-                                      flags,
+                                      meta_flags,
                                       window->size_hints.win_gravity,
                                       window->size_hints.x,
                                       window->size_hints.y,
                                       window->size_hints.width,
                                       window->size_hints.height);
 
+}
+
+gboolean
+meta_window_configure_request (MetaWindow *window,
+                               XEvent     *event)
+{
+  /* Note that x, y is the corner of the window border,
+   * and width, height is the size of the window inside
+   * its border, but that we always deny border requests
+   * and give windows a border of 0. But we save the
+   * requested border here.
+   */
+  if (event->xconfigurerequest.value_mask & CWBorderWidth)
+    window->border_width = event->xconfigurerequest.border_width;
+
+
+  meta_window_move_resize_request(window,
+                                  event->xconfigurerequest.value_mask,
+                                  0,
+                                  event->xconfigurerequest.x,
+                                  event->xconfigurerequest.y,
+                                  event->xconfigurerequest.width,
+                                  event->xconfigurerequest.height);
+
   /* Handle stacking. We only handle raises/lowers, mostly because
    * stack.c really can't deal with anything else.  I guess we'll fix
    * that if a client turns up that really requires it. Only a very
Index: metacity/metacity-2.14.5/src/window.h
===================================================================
--- metacity.orig/metacity-2.14.5/src/window.h	2006-06-19 23:09:44.000000000 +0100
+++ metacity/metacity-2.14.5/src/window.h	2006-06-19 23:42:10.000000000 +0100
@@ -490,6 +490,13 @@
                                      Time        timestamp);
 
 
+void     meta_window_move_resize_request(MetaWindow *window,
+                                         guint flags,
+                                         guint new_gravity,
+                                         gint new_x,
+                                         gint new_y,
+                                         gint new_width,
+                                         gint new_height);
 gboolean meta_window_configure_request (MetaWindow *window,
                                         XEvent     *event);
 gboolean meta_window_property_notify   (MetaWindow *window,
