Subject: FVWM: GotoDesk could remember previous position on the desk?

From: Jacek Kopecky <[email-masked]>
Date: Sun, 29 Jul 2001 14:38:51 +0200 (CEST)

(I apologize I forgot to specify the subject last time, so I'm
resending it properly now. If you read my mail with no subject,
you need not read this one.)

Hi, I have this enhancement request:

I use different desktops for different tasks, e.g. desk 0 for
mail and www, desk 1 for development.

When I'm switching among the desktops, I usually want to go to a
different page as well (I have 3x4 pages), like I'm on the page 1
0 on desk 1 and I'd like to go directly to 0 0 on desk 0 because
that's where I was last time.

Imagine I have a terminal with a long compilation on desk 1, page
1 0 (quite a common situation ) and I want to be there
automagically when the compilation ends and it beeps and I press
the button that gets me to desk 1. And all that regardless of
where I was on the other desktop, reading fvwm news while the
compilation was in progress. 8-)

Maybe the attached diff of my quick-and-dirty solution will help
if my previous text is not clear enough.

(I'm not on the list so please cc your replies to me.)

                            Jacek Kopecky

                            Idoox
                            http://www.idoox.com/

diff -rubB fvwm-2.4.0.orig/fvwm/virtual.c fvwm-2.4.0/fvwm/virtual.c
--- fvwm-2.4.0.orig/fvwm/virtual.c	Tue Jun  5 11:42:03 2001
+++ fvwm-2.4.0/fvwm/virtual.c	Sun Jul 29 01:19:55 2001
@@ -61,6 +61,8 @@
 static unsigned int prev_page_x = 0;
 static unsigned int prev_page_y = 0;
 static int prev_desk = 0;
+static int per_desk_x[10];
+static int per_desk_y[10];
 
 /**************************************************************************
  *
@@ -1087,7 +1089,7 @@
  *   - maps from the top of the stack down
  *
  ************************************************************************/
-static void MapDesk(int desk, Bool grab)
+static void MapDesk(int desk, int newx, int newy, Bool grab)
 {
   FvwmWindow *t;
   FvwmWindow *FocusWin = NULL;
@@ -1120,6 +1122,10 @@
       }
     }
   }
+  if (newx >= 0) 
+  {
+    MoveViewport(newx, newy, False);
+  }
   if (grab)
   {
     MyXUngrabServer(dpy);
@@ -1188,9 +1194,11 @@
   if (Scr.CurrentDesk != desk)
   {
     prev_desk = Scr.CurrentDesk;
+    per_desk_x[prev_desk] = Scr.Vx;
+    per_desk_y[prev_desk] = Scr.Vy;
     UnmapDesk(Scr.CurrentDesk, True);
     Scr.CurrentDesk = desk;
-    MapDesk(desk, True);
+    MapDesk(desk, per_desk_x[desk], per_desk_y[desk], True);
     BroadcastPacket(M_NEW_DESK, 1, Scr.CurrentDesk);
     /* FIXME: domivogt (22-Apr-2000): Fake a 'restack' for sticky window
      * upon desk change.  This is a workaround for a problem in FvwmPager:
@@ -1243,7 +1251,7 @@
   {
     prev_desk = Scr.CurrentDesk;
     Scr.CurrentDesk = val[0];
-    MapDesk(val[0], True);
+    MapDesk(val[0], -1, -1, True);
     BroadcastPacket(M_NEW_DESK, 1, Scr.CurrentDesk);
     /* FIXME: domivogt (22-Apr-2000): Fake a 'restack' for sticky window
      * upon desk change.  This is a workaround for a problem in FvwmPager:
Only in fvwm-2.4.0/fvwm: virtual.c.bak