Index: session.c
===================================================================
RCS file: /cvs/gnome/metacity/src/session.c,v
retrieving revision 1.34
diff -u -r1.34 session.c
--- session.c	25 Sep 2003 01:50:30 -0000	1.34
+++ session.c	6 Jul 2004 06:34:32 -0000
@@ -907,6 +907,7 @@
    *     <workspace index="4"/>
    *     <sticky/> <minimized/> <maximized/>
    *     <geometry x="100" y="100" width="200" height="200" gravity="northwest"/>
+   *     <resolution width=\"1024\" height=\"768\"/> 	//== Added by me
    *   </window>
    * </metacity_session>
    *
@@ -1026,7 +1027,14 @@
                          x, y, w, h,
                          window_gravity_to_string (window->size_hints.win_gravity));
               }
-              
+
+	      /* Resolution */
+	      {
+                fprintf (outfile, 
+			 "   <resolution width=\"%d\" height=\"%d\"/>\n", 
+			 window->screen->width, window->screen->height);
+	      }
+		
               fputs ("  </window>\n", outfile);
             }
           else
@@ -1316,6 +1324,43 @@
           ++i;
         }
     }
+  else if (strcmp (element_name, "resolution") == 0)
+    {
+      int i;
+      
+      pd->info->resolution_set = TRUE;
+
+      i = 0;
+      while (attribute_names[i])
+        {
+          const char *name;
+          const char *val;
+      
+	  name = attribute_names[i];
+	  val = attribute_values[i];
+
+      	  if (strcmp (name, "width") == 0)
+	     {
+		  if (*val)
+			pd->info->screen_width = atoi (val);
+             }
+	  else if (strcmp (name, "height") == 0)
+	     {
+                  if (*val)
+            		pd->info->screen_height = atoi (val);
+	     }
+   	  else
+            {
+              	  g_set_error (error,
+                           G_MARKUP_ERROR,
+                           G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
+                           _("Unknown attribute %s on <resolution> element"),
+                           name);
+              return;
+            }
+          ++i;
+	}
+    }
   else if (strcmp (element_name, "workspace") == 0)
     {
       int i;
Index: session.h
===================================================================
RCS file: /cvs/gnome/metacity/src/session.h,v
retrieving revision 1.9
diff -u -r1.9 session.h
--- session.h	4 Sep 2002 02:44:52 -0000	1.9
+++ session.h	6 Jul 2004 06:34:32 -0000
@@ -61,6 +61,10 @@
   guint minimized_set : 1;
   guint maximized_set : 1;
   guint saved_rect_set : 1;
+
+  guint resolution_set : 1;
+  unsigned int screen_width;
+  unsigned int screen_height;
 };
 
 /* If lookup_saved_state returns something, it should be used,
Index: window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.325
diff -u -r1.325 window.c
--- window.c	28 Feb 2004 02:53:55 -0000	1.325
+++ window.c	6 Jul 2004 06:34:34 -0000
@@ -858,6 +858,33 @@
                                         NorthWestGravity,
                                         x, y, w, h);
     }
+
+  if (info->resolution_set)
+    {
+      int x, y, w, h;
+      float rfactor_x = (float) window->screen->width / info->screen_width;
+      float rfactor_y = (float) window->screen->height / info->screen_height;
+      if ((window->screen->width == info->screen_width) 
+		      && (window->screen->height == info->screen_height))
+	      return;
+      
+      x = info->rect.x * rfactor_x;
+      y = info->rect.y * rfactor_y;
+
+      w = window->size_hints.base_width +
+        (info->rect.width * rfactor_x) * window->size_hints.width_inc;
+      h = window->size_hints.base_height +
+        (info->rect.height * rfactor_y) * window->size_hints.height_inc;
+
+      meta_topic (META_DEBUG_SM,
+                  "Restoring pos %d,%d size %d x %d for %s\n taking care of changed resolution if any",
+                  x, y, w, h, window->desc);
+      
+      meta_window_move_resize_internal (window,
+                                        META_DO_GRAVITY_ADJUST,
+                                        NorthWestGravity,
+                                        x, y, w, h);
+    }
 }
 
 void
