Subject: Maximize vs. offscreen windows

From: Matthias Clasen <[email-masked]>
Date: Tue, 12 Jan 1999 21:17:54 +0100

This patch corrects the behaviour of Maximize when used on 
offscreen windows. They stay on their page now. 

Matthias

--- builtins.c1	Tue Jan 12 19:22:02 1999
+++ builtins.c2	Tue Jan 12 20:37:42 1999
@@ -328,7 +328,7 @@
 void Maximize(XEvent *eventp,Window w,FvwmWindow *tmp_win,
 	      unsigned long context, char *action, int *Module)
 {
-  int new_width, new_height,new_x,new_y;
+  int new_width, new_height,new_x,new_y, page_x, page_y;
   int val1, val2, val1_unit,val2_unit,n;
 
   if (DeferExecution(eventp,&w,&tmp_win,&context, SELECT,ButtonRelease))
@@ -357,13 +357,20 @@
 
   if (tmp_win->flags & MAXIMIZED)
   {
+   /* Unmaximizing is slightly tricky since we want the window to
+      stay on the same page, even if we have move to a different page
+      in the meantime. */
+    new_x = tmp_win->frame_x + (tmp_win->orig_x % Scr.MyDisplayWidth);
+    new_y = tmp_win->frame_y + (tmp_win->orig_y % Scr.MyDisplayHeight);
     tmp_win->flags &= ~MAXIMIZED;
-    SetupFrame(tmp_win, tmp_win->orig_x, tmp_win->orig_y, tmp_win->orig_wd,
+    SetupFrame(tmp_win, new_x, new_y, tmp_win->orig_wd,
                tmp_win->orig_ht,TRUE);
     SetBorder(tmp_win,True,True,True,None);
   }
   else
   {
+    page_x = Scr.MyDisplayWidth * (tmp_win->frame_x / Scr.MyDisplayWidth);
+    page_y = Scr.MyDisplayHeight * (tmp_win->frame_y / Scr.MyDisplayHeight);
     new_width = tmp_win->frame_width;
     new_height = tmp_win->frame_height;
     new_x = tmp_win->frame_x;
@@ -371,17 +378,17 @@
     if(val1 >0)
     {
       new_width = val1*val1_unit/100-2;
-      new_x = 0;
+      new_x = page_x;
     }
     if(val2 >0)
     {
       new_height = val2*val2_unit/100-2;
-      new_y = 0;
+      new_y = page_y;
     }
     if((val1==0)&&(val2==0))
     {
-      new_x = 0;
-      new_y = 0;
+      new_x = page_x;
+      new_y = page_y;
       new_height = Scr.MyDisplayHeight-2;
       new_width = Scr.MyDisplayWidth-2;
     }

-- 
Matthias Clasen, 
Tel. 0761/203-5606
Email: [email-masked]
Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].