Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/metacity/ChangeLog,v
retrieving revision 1.216
diff -u -r1.216 ChangeLog
--- ChangeLog	1 May 2002 16:31:57 -0000	1.216
+++ ChangeLog	2 May 2002 16:49:04 -0000
@@ -1,3 +1,9 @@
+2002-05-02  Bastien Nocera  <hadess@hadess.net>
+
+	* src/display.c: (meta_display_get_workspace_by_index):
+	Wrap-around workspaces (ie. when on the last workspace,
+	"switch_to_workspace_right" goes back to the first one)
+
 2002-05-01  Havoc Pennington  <hp@redhat.com>
 
 	* src/screen.c (meta_screen_new): Xlib doesn't like NULL for out
Index: src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.96
diff -u -r1.96 display.c
--- src/display.c	29 Apr 2002 20:20:38 -0000	1.96
+++ src/display.c	2 May 2002 16:49:49 -0000
@@ -1814,14 +1814,21 @@
 
   /* should be robust, index is maybe from an app */
   if (idx < 0)
-    return NULL;
+    /* if the idx is negative, get the last workspace */
+    tmp = g_list_last (display->workspaces);
+  else
+    tmp = g_list_nth (display->workspaces, idx);
   
-  tmp = g_list_nth (display->workspaces, idx);
-
   if (tmp == NULL)
-    return NULL;
-  else
-    return tmp->data;
+  {
+    /* if the idx is out of bounds, get the first workspace */
+    tmp = g_list_first (display->workspaces);
+    /* No first workspace, shouldn't happen */
+    if (tmp == NULL)
+      return NULL;
+  }
+
+  return tmp->data;
 }
 
 MetaWorkspace*
