Index: src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.238
diff -p -u -r1.238 display.c
--- src/display.c	20 Dec 2004 02:46:42 -0000	1.238
+++ src/display.c	22 Dec 2004 04:45:45 -0000
@@ -1947,8 +1947,7 @@ event_callback (XEvent   *event,
           if (window->minimized)
             {
               meta_window_unminimize (window);
-              if (!meta_workspace_contains_window (window->screen->active_workspace,
-                                                   window))
+              if (window->workspace != window->screen->active_workspace)
                 {
                   meta_verbose ("Changing workspace due to MapRequest mapped = %d minimized = %d\n",
                                 window->mapped, window->minimized);
Index: src/place.c
===================================================================
RCS file: /cvs/gnome/metacity/src/place.c,v
retrieving revision 1.37
diff -p -u -r1.37 place.c
--- src/place.c	20 Dec 2004 02:53:08 -0000	1.37
+++ src/place.c	22 Dec 2004 04:45:45 -0000
@@ -750,7 +750,7 @@ meta_window_place (MetaWindow        *wi
 
         if (!w->minimized &&
             w != window && 
-            meta_window_shares_some_workspace (window, w))
+            window->workspace == w->workspace)
           windows = g_list_prepend (windows, w);
 
         tmp = tmp->next;
Index: src/session.c
===================================================================
RCS file: /cvs/gnome/metacity/src/session.c,v
retrieving revision 1.36
diff -p -u -r1.36 session.c
--- src/session.c	26 Aug 2004 00:59:12 -0000	1.36
+++ src/session.c	22 Dec 2004 04:45:45 -0000
@@ -1005,17 +1005,10 @@ save_state (void)
               
               /* Workspaces we're on */
               {
-                GList *w;
-                w = window->workspaces;
-                while (w != NULL)
-                  {
-                    int n;
-                    n = meta_workspace_index (w->data);
-                    fprintf (outfile,
-                             "    <workspace index=\"%d\"/>\n", n);
-
-                    w = w->next;
-                  }
+                int n;
+                n = meta_workspace_index (window->workspace);
+                fprintf (outfile,
+                         "    <workspace index=\"%d\"/>\n", n);
               }
 
               /* Gravity */
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.353
diff -p -u -r1.353 window.c
--- src/window.c	20 Dec 2004 02:53:08 -0000	1.353
+++ src/window.c	22 Dec 2004 04:45:48 -0000
@@ -368,7 +368,7 @@ meta_window_new_with_attrs (MetaDisplay 
    * type
    */
   window->display = display;
-  window->workspaces = NULL;
+  window->workspace = NULL;
 
 #ifdef HAVE_XSYNC
   window->sync_request_counter = None;
@@ -652,7 +652,7 @@ meta_window_new_with_attrs (MetaDisplay 
         }
     }
   
-  if (window->workspaces == NULL && 
+  if (window->workspace == NULL && 
       window->xtransient_for != None)
     {
       /* Try putting dialog on parent's workspace */
@@ -663,28 +663,20 @@ meta_window_new_with_attrs (MetaDisplay 
 
       if (parent)
         {
-          GList *tmp_list;
-
           meta_topic (META_DEBUG_PLACEMENT,
-                      "Putting window %s on some workspaces as parent %s\n",
+                      "Putting window %s on same workspace as parent %s\n",
                       window->desc, parent->desc);
           
           if (parent->on_all_workspaces)
             window->on_all_workspaces = TRUE;
           
-          tmp_list = parent->workspaces;
-          while (tmp_list != NULL)
-            {
-	      /* this will implicitly add to the appropriate MRU lists
-	       */
-              meta_workspace_add_window (tmp_list->data, window);
-              
-              tmp_list = tmp_list->next;
-            }
+	  /* this will implicitly add to the appropriate MRU lists
+	   */
+          meta_workspace_add_window (parent->workspace, window);
         }
     }
   
-  if (window->workspaces == NULL)
+  if (window->workspace == NULL)
     {
       meta_topic (META_DEBUG_PLACEMENT,
                   "Putting window %s on active workspace\n",
@@ -831,26 +823,20 @@ meta_window_apply_session_info (MetaWind
            * ensured that one of the workspaces from the session was
            * indeed valid, so we know we'll go right back to one.
            */
-          while (window->workspaces)
-            meta_workspace_remove_window (window->workspaces->data, window);
-
-          tmp = spaces;
-          while (tmp != NULL)
-            {
-              MetaWorkspace *space;
+          if (window->workspace)
+            meta_workspace_remove_window (window->workspace, window);
 
-              space = tmp->data;
-              
-              meta_workspace_add_window (space, window);              
+          /* Only restore to the first workspace if the window
+           * happened to be on more than one, since we have replaces
+           * window->workspaces with window->workspace
+           */
+          meta_workspace_add_window (spaces->data, window);              
 
-              meta_topic (META_DEBUG_SM,
-                          "Restoring saved window %s to workspace %d\n",
-                          window->desc,
-                          meta_workspace_index (space));
+          meta_topic (META_DEBUG_SM,
+                      "Restoring saved window %s to workspace %d\n",
+                      window->desc,
+                      meta_workspace_index (spaces->data));
               
-              tmp = tmp->next;
-            }
-
           g_slist_free (spaces);
         }
     }
@@ -978,20 +964,10 @@ meta_window_free (MetaWindow  *window)
   meta_window_unqueue_update_icon (window);
   meta_window_free_delete_dialog (window);
   
-  tmp = window->workspaces;
-  while (tmp != NULL)
-    {
-      GList *next;
+  if (window->workspace)
+    meta_workspace_remove_window (window->workspace, window);
 
-      next = tmp->next;
-
-      /* pops front of list */
-      meta_workspace_remove_window (tmp->data, window);
-
-      tmp = next;
-    }
-
-  g_assert (window->workspaces == NULL);
+  g_assert (window->workspace == NULL);
 
 #ifndef G_DISABLE_CHECKS
   tmp = window->screen->workspaces;
@@ -1200,7 +1176,7 @@ meta_window_visible_on_workspace (MetaWi
                                   MetaWorkspace *workspace)
 {
   return (window->on_all_workspaces && window->screen == workspace->screen) ||
-    meta_workspace_contains_window (workspace, window);
+    (window->workspace == workspace);
 }
 
 static gboolean
@@ -1250,20 +1226,12 @@ window_showing_on_its_workspace (MetaWin
                                 &is_desktop_or_dock);
 
   if (window->on_all_workspaces)
-    /* Unless the behavior in bug 87531 is implemented, or else
-     * _NET_WM_STATE_HIDDEN can be made per-workspace instead of
-     * global, or else we get rid of on_all_workspaces windows
-     * altogether, then this will be just a hack that only sort of
-     * works.
+    /* Until the behavior in bug 87531 is implemented, this will be
+     * just a hack that only sort of works.
      */
     workspace_of_window = window->screen->active_workspace;
-  else if (window->workspaces)
-    /* This is sort of hacky too; would like to guarantee that
-     * window->workspaces only contains a single workspace.  I believe
-     * that's currently true in Metacity, but it isn't guaranteed to
-     * remain true in the future.
-     */
-    workspace_of_window = window->workspaces->data;
+  else if (window->workspace)
+    workspace_of_window = window->workspace;
   else /* This only seems to be needed for startup */
     workspace_of_window = NULL;
 
@@ -3369,8 +3337,6 @@ static void
 meta_window_change_workspace_without_transients (MetaWindow    *window,
                                                  MetaWorkspace *workspace)
 {
-  GList *next;
-  
   meta_verbose ("Changing window %s to workspace %d\n",
                 window->desc, meta_workspace_index (workspace));
   
@@ -3382,24 +3348,11 @@ meta_window_change_workspace_without_tra
     meta_window_unstick (window);
 
   /* See if we're already on this space. If not, make sure we are */
-  if (g_list_find (window->workspaces, workspace) == NULL)
-    meta_workspace_add_window (workspace, window);
-  
-  /* Remove from all other spaces */
-  next = window->workspaces;
-  while (next != NULL)
+  if (window->workspace != workspace)
     {
-      MetaWorkspace *remove;
-      remove = next->data;
-      next = next->next;
-
-      if (remove != workspace)
-        meta_workspace_remove_window (remove, window);
+      meta_workspace_remove_window (window->workspace, window);
+      meta_workspace_add_window (workspace, window);
     }
-
-  /* list size == 1 */
-  g_assert (window->workspaces != NULL);
-  g_assert (window->workspaces->next == NULL);
 }
 
 static gboolean
@@ -3473,7 +3426,7 @@ meta_window_unstick (MetaWindow  *window
   while (tmp)
     {
       workspace = (MetaWorkspace *) tmp->data;
-      if (!meta_workspace_contains_window (workspace, window))
+      if (window->workspace != workspace)
         workspace->mru_list = g_list_remove (workspace->mru_list, window);
       tmp = tmp->next;
     }
@@ -3483,8 +3436,7 @@ meta_window_unstick (MetaWindow  *window
    * on more than one workspace this should probably be add_workspace
    * not change_workspace.
    */
-  if (!meta_workspace_contains_window (window->screen->active_workspace,
-                                       window))
+  if (window->screen->active_workspace != window->workspace)
     meta_window_change_workspace (window, window->screen->active_workspace);
   
   meta_window_set_current_workspace_hint (window);
@@ -3495,11 +3447,10 @@ meta_window_unstick (MetaWindow  *window
 unsigned long
 meta_window_get_net_wm_desktop (MetaWindow *window)
 {
-  if (window->on_all_workspaces ||
-      g_list_length (window->workspaces) > 1)
+  if (window->on_all_workspaces)
     return 0xFFFFFFFF;
   else
-    return meta_workspace_index (window->workspaces->data);
+    return meta_workspace_index (window->workspace);
 }
 
 static void
@@ -3540,7 +3491,7 @@ meta_window_set_current_workspace_hint (
    */
   unsigned long data[1];
 
-  if (window->workspaces == NULL)
+  if (window->workspace == NULL)
     {
       /* this happens when unmanaging windows */      
       return;
@@ -5189,7 +5140,7 @@ meta_window_get_workspaces (MetaWindow *
   if (window->on_all_workspaces)
     return window->screen->workspaces;
   else
-    return window->workspaces;
+    return g_list_prepend (NULL, window->workspace);
 }
 
 static void
@@ -6589,28 +6540,6 @@ meta_window_handle_mouse_grab_op_event (
     default:
       break;
     }
-}
-
-gboolean
-meta_window_shares_some_workspace (MetaWindow *window,
-                                   MetaWindow *with)
-{
-  GList *tmp;
-  
-  if (window->on_all_workspaces ||
-      with->on_all_workspaces)
-    return TRUE;
-  
-  tmp = window->workspaces;
-  while (tmp != NULL)
-    {
-      if (g_list_find (with->workspaces, tmp->data) != NULL)
-        return TRUE;
-
-      tmp = tmp->next;
-    }
-
-  return FALSE;
 }
 
 void
Index: src/window.h
===================================================================
RCS file: /cvs/gnome/metacity/src/window.h,v
retrieving revision 1.108
diff -p -u -r1.108 window.h
--- src/window.h	20 Dec 2004 02:53:08 -0000	1.108
+++ src/window.h	22 Dec 2004 04:45:48 -0000
@@ -64,7 +64,7 @@ struct _MetaWindow
 {
   MetaDisplay *display;
   MetaScreen *screen;
-  GList *workspaces;
+  MetaWorkspace *workspace;
   Window xwindow;
   /* may be NULL! not all windows get decorated */
   MetaFrame *frame;
@@ -457,9 +457,6 @@ void meta_window_show_menu (MetaWindow *
                             int         root_y,
                             int         button,
                             Time        timestamp);
-
-gboolean meta_window_shares_some_workspace (MetaWindow *window,
-                                            MetaWindow *with);
 
 void meta_window_set_gravity (MetaWindow *window,
                               int         gravity);
Index: src/workspace.c
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.c,v
retrieving revision 1.66
diff -p -u -r1.66 workspace.c
--- src/workspace.c	17 Oct 2004 04:28:29 -0000	1.66
+++ src/workspace.c	22 Dec 2004 04:45:48 -0000
@@ -94,7 +94,7 @@ meta_workspace_free (MetaWorkspace *work
 
       /* pop front of list we're iterating over */
       meta_workspace_remove_window (workspace, window);
-      g_assert (window->workspaces != NULL);
+      g_assert (window->workspace != NULL);
 
       tmp = next;
     }
@@ -125,14 +125,14 @@ void
 meta_workspace_add_window (MetaWorkspace *workspace,
                            MetaWindow    *window)
 {
-  g_return_if_fail (!meta_workspace_contains_window (workspace, window));
+  g_return_if_fail (window->workspace == NULL);
   
   /* If the window is on all workspaces, we want to add it to all mru
    * lists, otherwise just add it to this workspaces mru list
    */
   if (window->on_all_workspaces) 
     {
-      if (window->workspaces == NULL)
+      if (window->workspace == NULL)
         {
           GList* tmp = window->screen->workspaces;
           while (tmp)
@@ -152,7 +152,7 @@ meta_workspace_add_window (MetaWorkspace
     }
 
   workspace->windows = g_list_prepend (workspace->windows, window);
-  window->workspaces = g_list_prepend (window->workspaces, workspace);
+  window->workspace = workspace;
 
   meta_window_set_current_workspace_hint (window);
   
@@ -175,10 +175,10 @@ void
 meta_workspace_remove_window (MetaWorkspace *workspace,
                               MetaWindow    *window)
 {
-  g_return_if_fail (meta_workspace_contains_window (workspace, window));
+  g_return_if_fail (window->workspace == workspace);
 
   workspace->windows = g_list_remove (workspace->windows, window);
-  window->workspaces = g_list_remove (window->workspaces, workspace);
+  window->workspace = NULL;
 
   /* If the window is on all workspaces, we don't want to remove it
    * from the MRU list unless this causes it to be removed from all 
@@ -186,16 +186,13 @@ meta_workspace_remove_window (MetaWorksp
    */
   if (window->on_all_workspaces) 
     {
-      if (window->workspaces == NULL)
+      GList* tmp = window->screen->workspaces;
+      while (tmp)
         {
-          GList* tmp = window->screen->workspaces;
-          while (tmp)
-            {
-              MetaWorkspace* work = (MetaWorkspace*) tmp->data;
-              work->mru_list = g_list_remove (work->mru_list, window);
+          MetaWorkspace* work = (MetaWorkspace*) tmp->data;
+          work->mru_list = g_list_remove (work->mru_list, window);
 
-              tmp = tmp->next;
-            }
+          tmp = tmp->next;
         }
     }
   else
@@ -250,13 +247,6 @@ meta_workspace_relocate_windows (MetaWor
   g_assert (workspace->windows == NULL);
 }
 
-gboolean
-meta_workspace_contains_window (MetaWorkspace *workspace,
-                                MetaWindow    *window)
-{
-  return g_list_find (window->workspaces, workspace) != NULL;
-}
-
 void
 meta_workspace_queue_calc_showing  (MetaWorkspace *workspace)
 {
@@ -317,11 +307,10 @@ meta_workspace_activate_with_focus (Meta
        * never gets unmapped and we maintain the button grab
        * on it.
        */
-      if (move_window)
+      if (move_window && (move_window->workspace != workspace))
         {
-          if (!meta_workspace_contains_window (workspace,
-                                               move_window))
-            meta_workspace_add_window (workspace, move_window);
+          meta_workspace_remove_window (workspace, move_window);
+          meta_workspace_add_window (workspace, move_window);
         }
     }
 
Index: src/workspace.h
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.h,v
retrieving revision 1.20
diff -p -u -r1.20 workspace.h
--- src/workspace.h	17 Oct 2004 04:28:29 -0000	1.20
+++ src/workspace.h	22 Dec 2004 04:45:48 -0000
@@ -61,9 +61,6 @@ void           meta_workspace_remove_win
                                              MetaWindow    *window);
 void           meta_workspace_relocate_windows (MetaWorkspace *workspace,
                                                 MetaWorkspace *new_home);
-/* don't confuse with meta_window_visible_on_workspace() */
-gboolean       meta_workspace_contains_window (MetaWorkspace *workspace,
-                                               MetaWindow  *window);
 void           meta_workspace_activate_with_focus (MetaWorkspace *workspace,
                                                    MetaWindow    *focus_this,
                                                    Time           timestamp);
