? stamp-h1
Index: src/constraints.c
===================================================================
RCS file: /cvs/gnome/metacity/src/constraints.c,v
retrieving revision 1.21
diff -u -u -r1.21 constraints.c
--- src/constraints.c	23 Feb 2004 01:48:29 -0000	1.21
+++ src/constraints.c	4 Oct 2004 14:36:26 -0000
@@ -690,7 +690,7 @@
  *
  */
 
-#define USE_HINTS_FOR_WINDOW_STATE(window) (!((window)->fullscreen || (window)->maximized))
+#define USE_HINTS_FOR_WINDOW_STATE(window) (!((window)->fullscreen || META_WINDOW_MAXIMIZED(window)))
 
 static gboolean
 constraint_hints_applies_func (MetaWindow *window)
@@ -1179,7 +1179,7 @@
    * other windows we see which struts apply based on the
    * window's position later on
    */
-  if (window->maximized)
+  if (META_WINDOW_MAXIMIZED(window))
     {
       nw_x = MIN (info->work_area_xinerama.x, info->work_area_screen.x);
       nw_y = MIN (info->work_area_xinerama.y, info->work_area_screen.y);
@@ -1285,7 +1285,7 @@
   did_placement = FALSE;
   if (!window->placed &&
       window->calc_placement &&
-      !window->maximized &&
+      !META_WINDOW_MAXIMIZED(window) &&
       !window->fullscreen)
     {
       MetaRectangle placed_rect = current;
@@ -1367,7 +1367,7 @@
                       info.xinerama->y_origin - current.y + info.fgeom.top_height,
                       new);
     }
-  else if (window->maximized)
+  else if (META_WINDOW_MAXIMIZED(window))
     {
       constrain_resize_bottom (window, &info, &current,
                                (info.work_area_xinerama.height - OUTER_HEIGHT (current)),
Index: src/core.c
===================================================================
RCS file: /cvs/gnome/metacity/src/core.c,v
retrieving revision 1.40
diff -u -u -r1.40 core.c
--- src/core.c	16 Sep 2004 00:06:38 -0000	1.40
+++ src/core.c	4 Oct 2004 14:36:26 -0000
@@ -383,7 +383,7 @@
   if (window == NULL || window->frame == NULL)
     meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);  
 
-  if (window->maximized)
+  if (META_WINDOW_MAXIMIZED(window))
     meta_window_unmaximize (window);
   else
     meta_window_maximize (window);
Index: src/frame.c
===================================================================
RCS file: /cvs/gnome/metacity/src/frame.c,v
retrieving revision 1.62
diff -u -u -r1.62 frame.c
--- src/frame.c	16 Sep 2004 23:18:22 -0000	1.62
+++ src/frame.c	4 Oct 2004 14:36:26 -0000
@@ -319,7 +319,7 @@
   if (frame->window->on_all_workspaces)
     flags |= META_FRAME_STUCK;
 
-  if (frame->window->maximized)
+  if (META_WINDOW_MAXIMIZED(frame->window))
     flags |= META_FRAME_MAXIMIZED;
 
   if (frame->window->fullscreen)
Index: src/keybindings.c
===================================================================
RCS file: /cvs/gnome/metacity/src/keybindings.c,v
retrieving revision 1.102
diff -u -u -r1.102 keybindings.c
--- src/keybindings.c	22 Sep 2004 19:15:26 -0000	1.102
+++ src/keybindings.c	4 Oct 2004 14:36:27 -0000
@@ -2624,11 +2624,14 @@
                       XEvent         *event,
                       MetaKeyBinding *binding)
 {
-  if (window)
-    {
-      if (window->has_resize_func)
-        meta_window_fill_vertical (window);
-    }
+     if (window)
+	  if (window->has_resize_func)
+	  {
+	       if (window->maximized_vertically)
+		    meta_window_unfill_vertical(window);
+	       else
+		    meta_window_fill_vertical (window);
+	  }
 }
 
 static void
@@ -2638,11 +2641,14 @@
                        XEvent         *event,
                        MetaKeyBinding *binding)
 {
-  if (window)
-    {
-      if (window->has_resize_func)
-        meta_window_fill_horizontal (window);
-    }
+     if (window)
+	  if (window->has_resize_func)
+	  {
+	       if (window->maximized_horizontally)
+		    meta_window_unfill_horizontal(window);
+	       else
+		    meta_window_fill_horizontal (window);
+	  }
 }
 
 static gboolean
@@ -3057,7 +3063,7 @@
 {
   if (window)
     {
-      if (window->maximized)
+      if (META_WINDOW_MAXIMIZED(window))
         meta_window_unmaximize (window);
       else if (window->has_maximize_func)
         meta_window_maximize (window);
@@ -3087,7 +3093,7 @@
 {
   if (window)
     {
-      if (window->maximized)
+      if (META_WINDOW_MAXIMIZED(window))
         meta_window_unmaximize (window);
     }
 }
Index: src/session.c
===================================================================
RCS file: /cvs/gnome/metacity/src/session.c,v
retrieving revision 1.36
diff -u -u -r1.36 session.c
--- src/session.c	26 Aug 2004 00:59:12 -0000	1.36
+++ src/session.c	4 Oct 2004 14:36:27 -0000
@@ -993,7 +993,7 @@
                 fputs ("    <minimized/>\n", outfile);
 
               /* Maximized */
-              if (window->maximized)
+              if (META_WINDOW_MAXIMIZED(window))
 		{
                   fprintf (outfile,
                            "    <maximized saved_x=\"%d\" saved_y=\"%d\" saved_width=\"%d\" saved_height=\"%d\"/>\n", 
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.345
diff -u -u -r1.345 window.c
--- src/window.c	15 Sep 2004 15:54:51 -0000	1.345
+++ src/window.c	4 Oct 2004 14:36:28 -0000
@@ -434,7 +434,8 @@
 
   window->user_has_move_resized = FALSE;
   
-  window->maximized = FALSE;
+  window->maximized_vertically = FALSE;
+  window->maximized_horizontally = FALSE;
   window->maximize_after_placement = FALSE;
   window->fullscreen = FALSE;
   window->on_all_workspaces = FALSE;
@@ -782,11 +783,8 @@
                           info->saved_rect.width,
                           info->saved_rect.height,
                           window->desc);
-              
-              window->saved_rect.x = info->saved_rect.x;
-              window->saved_rect.y = info->saved_rect.y;
-              window->saved_rect.width = info->saved_rect.width;
-              window->saved_rect.height = info->saved_rect.height;
+
+              window->saved_rect = info->saved_rect;
             }
 	}
     }
@@ -1148,7 +1146,7 @@
       data[i] = window->display->atom_net_wm_state_skip_taskbar;
       ++i;
     }
-  if (window->maximized)
+  if (META_WINDOW_MAXIMIZED(window))
     {
       data[i] = window->display->atom_net_wm_state_maximized_horz;
       ++i;
@@ -1926,7 +1924,7 @@
 static void
 meta_window_save_rect (MetaWindow *window)
 {
-  if (!(window->maximized || window->fullscreen))
+  if (!(META_WINDOW_MAXIMIZED(window) || window->fullscreen))
     {
       /* save size/pos as appropriate args for move_resize */
       window->saved_rect = window->rect;
@@ -1944,13 +1942,14 @@
 {
   meta_topic (META_DEBUG_WINDOW_OPS,
               "Maximizing %s\n", window->desc);
-  
+
   if (saved_rect != NULL)
     window->saved_rect = *saved_rect;
   else
     meta_window_save_rect (window);
-  
-  window->maximized = TRUE;
+
+  window->maximized_horizontally = TRUE;
+  window->maximized_vertically = TRUE;
   
   recalc_window_features (window);
   set_net_wm_state (window);
@@ -1959,7 +1958,7 @@
 void
 meta_window_maximize (MetaWindow  *window)
 {
-  if (!window->maximized)
+  if (!META_WINDOW_MAXIMIZED(window))
     {
       if (window->shaded)
         meta_window_unshade (window);
@@ -1983,12 +1982,13 @@
 void
 meta_window_unmaximize (MetaWindow  *window)
 {
-  if (window->maximized)
+  if (META_WINDOW_MAXIMIZED(window))
     {
       meta_topic (META_DEBUG_WINDOW_OPS,
                   "Unmaximizing %s\n", window->desc);
       
-      window->maximized = FALSE;
+      window->maximized_vertically = FALSE;
+      window->maximized_horizontally = FALSE;
 
       /* When we unmaximize, if we're doing a mouse move also we could
        * get the window suddenly jumping to the upper left corner of
@@ -1998,7 +1998,7 @@
       if (meta_grab_op_is_moving (window->display->grab_op) &&
           window->display->grab_window == window)
         {
-          window->display->grab_anchor_window_pos = window->saved_rect;
+	   window->display->grab_anchor_window_pos = window->saved_rect;
         }
 
       meta_window_move_resize (window,
@@ -2905,15 +2905,14 @@
   if (!window->has_maximize_func)
     return;
   
-  meta_window_get_outer_rect (window, &rect);
-
-  if ( rect.x >= work_area->x &&
-       rect.y >= work_area->y &&
-       (((work_area->width - work_area->x) - rect.width) <
-        window->size_hints.width_inc) &&
-       (((work_area->height - work_area->y) - rect.height) <
-        window->size_hints.height_inc) )
-    meta_window_maximize (window);
+  if ( ( rect.x >= work_area->x &&
+	 rect.y >= work_area->y &&
+	 (((work_area->width - work_area->x) - rect.width) <
+	  window->size_hints.width_inc) &&
+	 (((work_area->height - work_area->y) - rect.height) <
+	  window->size_hints.height_inc) )
+       || META_WINDOW_MAXIMIZED(window) )
+       meta_window_maximize (window);
 }
 
 void
@@ -2934,14 +2933,39 @@
   
   if (window->frame != NULL)
     {
-      x += window->frame->child_x;
-      w -= (window->frame->child_x + window->frame->right_width);
+	 x += window->frame->child_x;
+	 w -= (window->frame->child_x + window->frame->right_width);
     }
   
+  window->saved_rect.x = window->rect.x;
+  window->saved_rect.width = window->rect.width;
+  if(window->frame)
+       window->saved_rect.x += window->frame->rect.x;
+
+  window->maximized_horizontally = TRUE;
+
   meta_window_move_resize (window, TRUE,
                            x, y, w, h);
 
-  check_maximize_to_work_area (window, &work_area);
+}
+
+void
+meta_window_unfill_horizontal (MetaWindow  *window)
+{
+  if (window->maximized_horizontally)
+    {
+      window->maximized_horizontally = FALSE;
+
+      meta_window_move_resize (window,
+                               TRUE,
+                               window->saved_rect.x,
+                               window->user_rect.y,
+                               window->saved_rect.width,
+                               window->user_rect.height);
+
+      recalc_window_features (window);
+      set_net_wm_state (window);
+    }
 }
 
 void
@@ -2966,10 +2990,35 @@
       h -= (window->frame->child_y + window->frame->bottom_height);
     }
   
+  window->saved_rect.y = window->rect.y;
+  window->saved_rect.height = window->rect.height;
+  if(window->frame)
+       window->saved_rect.y += window->frame->rect.y;
+
+  window->maximized_vertically = TRUE;
+
   meta_window_move_resize (window, TRUE,
                            x, y, w, h);
 
-  check_maximize_to_work_area (window, &work_area);
+}
+
+void
+meta_window_unfill_vertical (MetaWindow  *window)
+{
+  if (window->maximized_vertically)
+    {
+      window->maximized_vertically = FALSE;
+
+      meta_window_move_resize (window,
+                               TRUE,
+                               window->user_rect.x,
+                               window->saved_rect.y,
+                               window->user_rect.width,
+                               window->saved_rect.height);
+
+      recalc_window_features (window);
+      set_net_wm_state (window);
+    }
 }
 
 static guint move_resize_idle = 0;
@@ -3920,7 +3969,7 @@
           gboolean max;
 
           max = (action == _NET_WM_STATE_ADD ||
-                 (action == _NET_WM_STATE_TOGGLE && !window->maximized));
+                 (action == _NET_WM_STATE_TOGGLE && !META_WINDOW_MAXIMIZED(window)));
           if (max && window->has_maximize_func)
             meta_window_maximize (window);
           else
@@ -4635,7 +4684,6 @@
   Atom *atoms;
 
   window->shaded = FALSE;
-  window->maximized = FALSE;
   window->wm_state_modal = FALSE;
   window->wm_state_skip_taskbar = FALSE;
   window->wm_state_skip_pager = FALSE;
@@ -5969,7 +6017,7 @@
         ops |= META_MENU_OP_MOVE_DOWN;
     }
 
-  if (window->maximized)
+  if (META_WINDOW_MAXIMIZED(window))
     ops |= META_MENU_OP_UNMAXIMIZE;
   else
     ops |= META_MENU_OP_MAXIMIZE;
@@ -6160,7 +6208,7 @@
   shake_threshold = meta_ui_get_drag_threshold (window->screen->ui) *
     DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR;
     
-  if (window->maximized && ABS (dy) >= shake_threshold)
+  if (META_WINDOW_MAXIMIZED(window) && ABS (dy) >= shake_threshold)
     {
       double prop;
 
@@ -6193,7 +6241,7 @@
   /* remaximize window on an other xinerama monitor if window has
    * been shaken loose or it is still maximized (then move straight)
    */
-  else if (window->shaken_loose || window->maximized)
+  else if (window->shaken_loose || META_WINDOW_MAXIMIZED(window))
     {
       const MetaXineramaScreenInfo *wxinerama;
       MetaRectangle work_area;
@@ -6241,7 +6289,7 @@
     }
 
   /* don't allow a maximized window to move */
-  if (window->maximized)
+  if (META_WINDOW_MAXIMIZED(window))
     return;
 
   if (window->display->grab_wireframe_active)
Index: src/window.h
===================================================================
RCS file: /cvs/gnome/metacity/src/window.h,v
retrieving revision 1.107
diff -u -u -r1.107 window.h
--- src/window.h	19 Aug 2004 02:05:24 -0000	1.107
+++ src/window.h	4 Oct 2004 14:36:28 -0000
@@ -106,10 +106,14 @@
   /* Initial timestamp property */
   Time initial_timestamp;  
   
-  /* Whether we're maximized */
-  guint maximized : 1;
   guint maximize_after_placement : 1;
 
+  /* Whether we're maximized vertically */
+  guint maximized_vertically : 1;
+
+  /* Whether we're maximized horizontally */
+  guint maximized_horizontally : 1;
+
   /* Whether we're shaded */
   guint shaded : 1;
 
@@ -322,8 +326,9 @@
  * the dynamic window state such as "maximized", not just the
  * window's type
  */
+#define META_WINDOW_MAXIMIZED(w)       ((w)->maximized_vertically && (w)->maximized_horizontally)
 #define META_WINDOW_ALLOWS_MOVE(w)     ((w)->has_move_func && !(w)->fullscreen)
-#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w)   ((w)->has_resize_func && !(w)->maximized && !(w)->fullscreen && !(w)->shaded)
+#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w)   ((w)->has_resize_func && !META_WINDOW_MAXIMIZED(w) && !(w)->fullscreen && !(w)->shaded)
 #define META_WINDOW_ALLOWS_RESIZE(w)   (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) &&                \
                                         (((w)->size_hints.min_width < (w)->size_hints.max_width) ||  \
                                          ((w)->size_hints.min_height < (w)->size_hints.max_height)))
@@ -383,7 +388,10 @@
 
 
 void        meta_window_fill_horizontal     (MetaWindow  *window);
+void        meta_window_unfill_horizontal (MetaWindow  *window);
+
 void        meta_window_fill_vertical       (MetaWindow  *window);
+void        meta_window_unfill_vertical (MetaWindow  *window);
 
 /* This recalcs the window/frame size, and recalcs the frame
  * size/contents as well.
