diff -Npur metacity-old/src/core/workspace.c metacity-new/src/core/workspace.c
--- metacity-old/src/core/workspace.c	2009-04-03 15:15:25.000000000 +0800
+++ metacity-new/src/core/workspace.c	2009-04-03 15:07:02.000000000 +0800
@@ -761,39 +761,37 @@ meta_workspace_get_neighbor (MetaWorkspa
   
   ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR;
 
-  switch (direction) 
-    {
-    case META_MOTION_LEFT:
-      layout.current_col -= ltr ? 1 : -1;
-      break;
-    case META_MOTION_RIGHT:
-      layout.current_col += ltr ? 1 : -1;
-      break;
-    case META_MOTION_UP:
-      layout.current_row -= 1;
-      break;
-    case META_MOTION_DOWN:
-      layout.current_row += 1;
-      break;
-    }
+  do {
+    switch (direction) 
+      {
+        case META_MOTION_LEFT:
+          layout.current_col -= ltr ? 1 : -1;
+          break;
+        case META_MOTION_RIGHT:
+          layout.current_col += ltr ? 1 : -1;
+          break;
+        case META_MOTION_UP:
+          layout.current_row -= 1;
+          break;
+        case META_MOTION_DOWN:
+          layout.current_row += 1;
+          break;
+      }
 
-  if (layout.current_col < 0)
-    layout.current_col = 0;
-  if (layout.current_col >= layout.cols)
-    layout.current_col = layout.cols - 1;
-  if (layout.current_row < 0)
-    layout.current_row = 0;
-  if (layout.current_row >= layout.rows)
-    layout.current_row = layout.rows - 1;
+      if (layout.current_col < 0) {
+        layout.current_col = layout.cols - 1;
+        layout.current_row -= ltr ? 1 : -1;
+      } else if (layout.current_col >= layout.cols) {
+	layout.current_col = 0;
+	layout.current_row += ltr ? 1: -1;
+      }
+      if (layout.current_row < 0)
+        layout.current_row = layout.rows - 1;
+      else if (layout.current_row >= layout.rows)
+	layout.current_row = 0;
 
-  i = layout.grid[layout.current_row * layout.cols + layout.current_col];
-
-  if (i < 0)
-    i = current_space;
-
-  if (i >= num_workspaces)
-    meta_bug ("calc_workspace_layout left an invalid (too-high) workspace number %d in the grid\n",
-              i);
+      i = layout.grid[layout.current_row * layout.cols + layout.current_col];
+  } while ((i < 0) || (i >= num_workspaces));
     
   meta_verbose ("Neighbor workspace is %d at row %d col %d\n",
                 i, layout.current_row, layout.current_col);
