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-18 21:52:44.000000000 +0100
@@ -1334,7 +1334,6 @@
   return meta_ui_get_double_click_timeout (screen->ui);
 }                                
 
-#if 0
 static void
 handle_net_moveresize_window (MetaDisplay* display,
                               XEvent *event)
@@ -1342,73 +1341,108 @@
   MetaWindow *window;
   int x, y, width, height;
   gboolean only_resize;
-  unsigned int gravity;
-  unsigned int mode;
+  gboolean in_grab_op;
+  unsigned int gravity, mode, source;
+  MetaMoveResizeFlags flags;
 
   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;
+  gravity = (event->xclient.data.l[0] & 0xff);
+  mode = (event->xclient.data.l[0] & 0xf00) >> 8;
+  source = (event->xclient.data.l[0] & 0xf000) >> 12;
+
+  in_grab_op = FALSE;
+  if (window->display->grab_op != META_GRAB_OP_NONE &&
+      window == window->display->grab_window)
+    {
+      switch (window->display->grab_op)
+        {
+        case META_GRAB_OP_MOVING:
+        case META_GRAB_OP_RESIZING_SE:
+        case META_GRAB_OP_RESIZING_S:
+        case META_GRAB_OP_RESIZING_SW:
+        case META_GRAB_OP_RESIZING_N:
+        case META_GRAB_OP_RESIZING_NE:
+        case META_GRAB_OP_RESIZING_NW:
+        case META_GRAB_OP_RESIZING_W:
+        case META_GRAB_OP_RESIZING_E:
+          in_grab_op = TRUE;
+          break;
+        default:
+          break;
+        }
+    }
 
-  if (window)
+  meta_window_get_gravity_position (window, &x, &y);
+  allow_position_change = FALSE;
+
+  if (meta_prefs_get_disable_workarounds ())
     {
-      /* 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 (window->type == META_WINDOW_DIALOG ||
+          window->type == META_WINDOW_MODAL_DIALOG ||
+          window->type == META_WINDOW_SPLASHSCREEN)
+        ; /* No position change for these */
+      else if ((window->size_hints.flags & PPosition) ||
+               /* USPosition is just stale if window is placed;
+                * no --geometry involved here.
+                */
+               ((window->size_hints.flags & USPosition) &&
+                !window->placed))
+        allow_position_change = TRUE;
+    }
+  else
+    {
+      allow_position_change = TRUE;
+    }
 
-      if (mode & (CWX | CWY))
-        only_resize = FALSE;
-      else
-        only_resize = TRUE;
+  if (in_grab_op)
+    allow_position_change = FALSE;
 
+  only_resize = TRUE;
+  if (allow_position_change)
+    {
       if (mode & CWX)
         x = event->xclient.data.l[1];
       if (mode & CWY)
         y = event->xclient.data.l[2];
+      if (mode & (CWX | CWY))
+        only_resize = FALSE;
+    }
+
+  width = window->rect.width;
+  height = window->rect.height;
+  if (!in_grap_op)
+    {
       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);
-        }
     }
+
+  window->size_hints.x = x;
+  window->size_hints.y = y;
+  window->size_hints.width = width;
+  window->size_hints.height = height;
+
+  flags = 0;
+  if (mode & (CWX | CWY))
+    flags |= META_IS_MOVE_ACTION;
+  if (mode & (CWWidth | CWHeight))
+    flags |= META_IS_RESIZE_ACTION;
+  if (flags & (META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION))
+    meta_window_move_resize_internal (window, 
+                                      flags,
+                                      window->size_hints.win_gravity,
+                                      window->size_hints.x,
+                                      window->size_hints.y,
+                                      window->size_hints.width,
+                                      window->size_hints.height);
 }
 
+#if 0
 static void
 handle_net_restack_window (MetaDisplay* display,
                            XEvent *event)
