Index: metacity/src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.286
diff -u -p -r1.286 display.c
--- metacity/src/display.c	26 May 2006 16:51:03 -0000	1.286
+++ metacity/src/display.c	6 Jul 2006 03:43:09 -0000
@@ -3293,24 +3293,19 @@ meta_display_begin_grab_op (MetaDisplay 
       return FALSE;
     }
 
-  if (grab_op_is_keyboard (op))
+  if (window)
+    display->grab_have_keyboard = meta_window_grab_all_keys (window);
+  else
+    display->grab_have_keyboard = meta_screen_grab_all_keys (screen);
+
+  if (!display->grab_have_keyboard)
     {
-      if (window)
-        display->grab_have_keyboard =
-                     meta_window_grab_all_keys (window);
 
-      else
-        display->grab_have_keyboard =
-                     meta_screen_grab_all_keys (screen);
-      
-      if (!display->grab_have_keyboard)
-        {
-          meta_topic (META_DEBUG_WINDOW_OPS,
-                      "grabbing all keys failed, ungrabbing pointer\n");
-          XUngrabPointer (display->xdisplay, CurrentTime);
-	  display->grab_have_pointer = FALSE;
-          return FALSE;
-        }
+      meta_topic (META_DEBUG_WINDOW_OPS,
+                  "grabbing all keys failed, ungrabbing pointer\n");
+      XUngrabPointer (display->xdisplay, CurrentTime);
+      display->grab_have_pointer = FALSE;
+      return FALSE;
     }
   
   display->grab_op = op;
Index: metacity/src/keybindings.c
===================================================================
RCS file: /cvs/gnome/metacity/src/keybindings.c,v
retrieving revision 1.129
diff -u -p -r1.129 keybindings.c
--- metacity/src/keybindings.c	17 Apr 2006 17:23:09 -0000	1.129
+++ metacity/src/keybindings.c	6 Jul 2006 03:43:11 -0000
@@ -196,6 +196,12 @@ static void handle_run_terminal       (M
                                        MetaKeyBinding *binding);
 
 /* debug */
+static gboolean process_mouse_move_grab (MetaDisplay *display,
+                                            MetaScreen  *screen,
+                                            MetaWindow  *window,
+                                            XEvent      *event,
+                                            KeySym       keysym);
+
 static gboolean process_keyboard_move_grab (MetaDisplay *display,
                                             MetaScreen  *screen,
                                             MetaWindow  *window,
@@ -1661,6 +1667,14 @@ meta_display_process_key_event (MetaDisp
     {
       switch (display->grab_op)
         {
+        case META_GRAB_OP_MOVING:
+          meta_topic (META_DEBUG_KEYBINDINGS,
+                      "Processing event for mouse move\n");
+          g_assert (window != NULL);
+          handled = process_mouse_move_grab (display, screen,
+                                                window, event, keysym);
+          break;
+
         case META_GRAB_OP_KEYBOARD_MOVING:
           meta_topic (META_DEBUG_KEYBINDINGS,
                       "Processing event for keyboard move\n");
@@ -1716,6 +1730,45 @@ meta_display_process_key_event (MetaDisp
       meta_display_end_grab_op (display, event->xkey.time);
     }
 }
+
+static gboolean
+process_mouse_move_grab (MetaDisplay *display,
+                            MetaScreen  *screen,
+                            MetaWindow  *window,
+                            XEvent      *event,
+                            KeySym       keysym)
+{
+
+  /* don't care about releases, but eat them, don't end grab */
+  if (event->type == KeyRelease)
+    return TRUE;
+
+  /* don't end grab on modifier key presses */
+  if (is_modifier (display, event->xkey.keycode)){
+      return TRUE;
+    }
+
+  if (keysym == XK_Escape)
+    {
+      /* End resize and restore to original state.
+       * The move_resize is only needed when !wireframe
+       * since in wireframe we always moveresize at the end
+       * of the grab only.
+       */
+      if (!display->grab_wireframe_active)
+        meta_window_move_resize (display->grab_window,
+                                 TRUE,
+                                 display->grab_initial_window_pos.x,
+                                 display->grab_initial_window_pos.y,
+                                 display->grab_initial_window_pos.width,
+                                 display->grab_initial_window_pos.height);
+      display->grab_was_cancelled = TRUE;
+      return FALSE;
+    }
+
+  return TRUE;
+
+} 
 
 static gboolean
 process_keyboard_move_grab (MetaDisplay *display,
