Subject: Trial patch for moving with/without warping the pointer

From: Tim Phipps <[email-masked]>
Date: Mon, 09 Nov 1998 17:55:25 +0000

Hi all,
	The following is a trial patch that adds an optional argument "Warp" to
the Move and AnimatedMove commands.  With it the commands warp the
pointer with the window, without it the pointer remains where it is.

It's a trial version because I don't understand how to do parsing
properly so it just looks for Warp in the action string. i.e. it's case
sensitive.  Please feel free to hack it into shape.

Cheers,
Tim.

Index: move.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/move.c,v
retrieving revision 1.12
diff -u -r1.12 move.c
--- move.c	1998/11/09 14:10:19	1.12
+++ move.c	1998/11/09 17:48:35
@@ -119,6 +119,7 @@
   int width, height;
   int page_x, page_y;
   int unit_x, unit_y;
+  Bool fWarp = FALSE;
 
   if (DeferExecution(eventp,&w,&tmp_win,&context, MOVE,ButtonPress))
     return;
@@ -165,6 +166,8 @@
     }
   else
     {
+      /* parse optional Warp argument, this needs cleaning up */
+      if (strstr(action, "Warp")) fWarp = TRUE;
       n = GetPositionArguments(action,x,y,width+tmp_win->bw,
 			       height+tmp_win->bw,&FinalX,&FinalY);
       if (n != 2)
@@ -174,10 +177,12 @@
   if (w == tmp_win->frame)
   {
     if (fAnimated) {
-      AnimatedMoveOfWindow(w,-1,-1,FinalX,FinalY,TRUE,-1,NULL);
+      AnimatedMoveOfWindow(w,-1,-1,FinalX,FinalY,fWarp,-1,NULL);
     }
     SetupFrame (tmp_win, FinalX, FinalY,
 		tmp_win->frame_width, tmp_win->frame_height,FALSE);
+    if (fWarp & !fAnimated) XWarpPointer(dpy, None, None, 0, 0, 0, 0,
+                                         FinalX - x, FinalY - y);
   }
   else /* icon window */
     {
@@ -194,19 +199,23 @@
                       tmp_win->icon_w_height + tmp_win->icon_p_height);
       if (fAnimated) {
         AnimatedMoveOfWindow(tmp_win->icon_w,-1,-1,tmp_win->icon_xl_loc,FinalY+tmp_win->icon_p_height,
-			     TRUE,-1,NULL);
+			     fWarp,-1,NULL);
       } else {
         XMoveWindow(dpy,tmp_win->icon_w,
 		    tmp_win->icon_xl_loc, FinalY+tmp_win->icon_p_height);
+        if (fWarp) XWarpPointer(dpy, None, None, 0, 0, 0, 0,
+                                FinalX - x, FinalY - y);
       }
       if(tmp_win->icon_pixmap_w != None)
 	{
 	  XMapWindow(dpy,tmp_win->icon_w);
 	  if (fAnimated) {
    	    AnimatedMoveOfWindow(tmp_win->icon_pixmap_w, -1,-1,
-				 tmp_win->icon_x_loc,FinalY,TRUE,-1,NULL);
+				 tmp_win->icon_x_loc,FinalY,fWarp,-1,NULL);
 	  } else {
 	    XMoveWindow(dpy, tmp_win->icon_pixmap_w, tmp_win->icon_x_loc,FinalY);
+            if (fWarp) XWarpPointer(dpy, None, None, 0, 0, 0, 0,
+                                    FinalX - x, FinalY - y);
 	  }
 	  XMapWindow(dpy,w);
 	}
Index: fvwm2.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm2.1,v
retrieving revision 1.6
diff -u -r1.6 fvwm2.1
--- fvwm2.1	1998/11/09 10:36:28	1.6
+++ fvwm2.1	1998/11/09 17:49:03
@@ -610,11 +610,12 @@
 stripped of the substrings between the various delimiters.

-.IP "AnimatedMove [ \fIx y\fP ]"
+.IP "AnimatedMove \fIx y\fP [ \fIWarp\fP ]"
 
 Move a window in an animated way. Similar to Move command, below.
 Options are the same, except they are required, since it doesn't make
-sense to have a user move the window interactively and animatedly.
+sense to have a user move the window interactively and animatedly. If the optional
+argument \fIWarp\fP is pecified the pointer is warped with the window.

 .IP "Beep"
@@ -1596,11 +1597,12 @@
 or keyboard keys.

-.IP "Move [ \fIx y\fP ]"
+.IP "Move [ \fIx y\fP ] [ \fIWarp\fP ]"
 Allows the user to move a window.  If called from somewhere in a
 window or its border, then that window will be moved.  If called from
 the root window then the user will be allowed to select the target
-window.
+window. If the optional argument \fIWarp\fP is pecified the pointer is warped
+with the window.
 
 The operation can be aborted with Escape or by pressing any mouse button
 (except button 1 which confirms the move).

---

From: [email-masked] (Paul D. Smith)
Date: 09 Nov 1998 15:48:44 -0500

Just a friendly reminder: please include a ChangeLog snippet with each
patch so we can install it when we apply the patch.  It gives you credit
and it helps people understand what changes have been made.

Also, for those with write access, don't forget to update the ChangeLog
when you make changes...

For Emacs users nothing could be simpler: after you finish editing a
function, just type C-x 4 a (add-change-log-entry-other-buffer) and
everything is filled in for you.  It'll even find the right file for
you.  It takes a bit to get into the habit, but then it's really
second-nature.

For users of other editors... well, cut and paste, I guess :).  Please
try to keep the same format, as much as possible.

This documentation _really_ helps people, esp. in the far future.  Trust
me, I know :)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
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].

---

From: [email-masked]
Date: Tue, 10 Nov 1998 10:58:36 +0100

> sensitive.  Please feel free to hack it into shape.

Perhaps someone should write a paper on how parsing should be done ;-)
Perhaps I will do this someday.

>  			       height+tmp_win->bw,&FinalX,&FinalY);

I would do it like this:

  n = GetPositionArguments(action,x,y,width+tmp_win->bw,
                           height+tmp_win->bw,&FinalX,&FinalY);
  GetNextToken(SkipNTokens(action, n), &token);
  if (StrEquals(token, "Warp"))
    fWarp = TRUE;
  if (token)
    free(token)

BTW, you should do it the other way round since warping was
is the default at the moment:

  fWarp = TRUE;
  if (StrEquals(token, "NoWarp"))
    fWarp = TRUE;

Bye

Dominik
-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
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].

---

From: Steve Robbins <[email-masked]>
Date: Tue, 10 Nov 1998 05:50:01 -0500 (EST)

> Perhaps someone should write a paper on how parsing should be done ;-)

Even better: write some library routines!

--
Steve Robbins                              <[email-masked]>

Is there something wrong with this?
I don't see how there possibly could be:
The waterbed's on fire, 
but everything else is as it should be.

---

From: [email-masked]
Date: Tue, 10 Nov 1998 12:11:19 +0100

> Even better: write some library routines!

That is the reason for the paper: the library routines are already
there. I wrote a number of them (see Parse.c and XResources.c).
Just nobody knows.

Bye

Dominik

---

From: Tim Phipps <[email-masked]>
Date: Tue, 10 Nov 1998 14:54:16 +0000

> I would do it like this:

Thanks Dominik! I was hoping for some help.  Attached is the second
attempt.

> is the default at the moment:

I'd prefer not to warp by default. This patch applies to Move and
AnimatedMove
and since Move is older and it never did warping I think that should be
the default.  AnimatedMove wasn't in 2.0.46 so less people will be
bothered by its default warp setting being changed.

Cheers,
Tim.

Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.25
diff -u -r1.25 ChangeLog
--- ChangeLog	1998/11/10 09:21:21	1.25
+++ ChangeLog	1998/11/10 14:50:08
@@ -1,3 +1,12 @@
+1998-11-10
+
+	* fvwm/misc.{c,h}: changed GetPositionArguments to GetMoveArguments
+	and added parsing for optional Warp flag for Move/AnimatedMove
+
+	* fvwm/move.c: Added optional Warp flag for Move/AnimatedMove
+
+	* fvwm/fvwm2.1: Documented optional Warp flag for Move/AnimatedMove
+
 1998-11-10  Dominik Vogt  <[email-masked]>
 
 	* fvwm/builtins.c (SetMenuStyle): fixed memory leak.
Index: fvwm/fvwm2.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm2.1,v
retrieving revision 1.6
diff -u -r1.6 fvwm2.1
--- fvwm/fvwm2.1	1998/11/09 10:36:28	1.6
+++ fvwm/fvwm2.1	1998/11/10 14:50:36
@@ -610,11 +610,12 @@
 stripped of the substrings between the various delimiters.

+argument \fIWarp\fP is specified the pointer is warped with the window.

 .IP "Beep"
@@ -1266,7 +1267,7 @@

 .IP "HilightColor \fItextcolor backgroundcolor\fP"
-Specified the text and background colors for the decorations on the
+Specifies the text and background colors for the decorations on the
 window which currently has the keyboard focus.

@@ -1596,11 +1597,12 @@
 or keyboard keys.

-.IP "Move [ \fIx y\fP ]"
+.IP "Move [ \fIx y\fP [ \fIWarp\fP ] ]"
 Allows the user to move a window.  If called from somewhere in a
 window or its border, then that window will be moved.  If called from
 the root window then the user will be allowed to select the target
-window.
+window. If the optional argument \fIWarp\fP is specified the pointer is warped
+with the window.
 
 The operation can be aborted with Escape or by pressing any mouse button
 (except button 1 which confirms the move).
Index: fvwm/misc.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/misc.h,v
retrieving revision 1.9
diff -u -r1.9 misc.h
--- fvwm/misc.h	1998/11/09 10:36:29	1.9
+++ fvwm/misc.h	1998/11/10 14:50:51
@@ -410,7 +410,8 @@
 void changeWindowsDesk(XEvent *eventp,Window w,FvwmWindow *tmp_win,
 		       unsigned long context, char *action, int *Module);
 
-int GetPositionArguments(char *action, int x, int y, int w, int h, int *pfinalX, int *pfinalY);
+int GetMoveArguments(char *action, int x, int y, int w, int h,
+                     int *pfinalX, int *pfinalY, Bool *fWarp);
 char *GetMenuOptions(char *action, Window w, FvwmWindow *tmp_win,
 		     MenuItem *mi, MenuOptions *pops);
 int GetTwoArguments(char *action, int *val1, int *val2, int *val1_unit, int *val2_unit);
Index: fvwm/misc.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/misc.c,v
retrieving revision 1.8
diff -u -r1.8 misc.c
--- fvwm/misc.c	1998/11/07 15:10:55	1.8
+++ fvwm/misc.c	1998/11/10 14:51:08
@@ -457,35 +457,40 @@
   return 1;
 }
 
-/* GetPositionArguments is used for Move, AnimatedMove, maybe more
+/* GetMoveArguments is used for Move & AnimatedMove
  * It lets you specify in all the following ways
  *   20  30          Absolute percent position, from left edge and top
  *  -50  50          Absolute percent position, from right edge and top
  *   10p 5p          Absolute pixel position
  *   10p -0p         Absolute pixel position, from bottom
  *  w+5  w-10p       Relative position, right 5%, up ten pixels
+ * Returns 2 when x & y have parsed without error, 0 otherwise
  */
-int GetPositionArguments(char *action, int x, int y, int w, int h, int *pFinalX, int *pFinalY)
+int GetMoveArguments(char *action, int x, int y, int w, int h,
+                     int *pFinalX, int *pFinalY, Bool *fWarp)
 {
-  char *s1, *s2;
+  char *s1, *s2, *warp, *rest;
   int scrWidth = Scr.MyDisplayWidth;
   int scrHeight = Scr.MyDisplayHeight;
+  int retval = 0;
 
-  if( strlen(action) <= 0 )
-    return 0;
+  rest = GetNextToken(action, &s1);
+  rest = GetNextToken(rest, &s2);
+  rest = GetNextToken(rest, &warp);
+  *fWarp = StrEquals(warp, "Warp");
 
-  s1 = strtok(action," \t\n");
-  s2 = strtok(NULL," \t\n");
-  /* DEBUG_FPRINTF((stderr,"GPA: 1=\"%s\", 2=\"%s\"\n",s1,s2)); */
-
-  if (s1 == NULL || s2 == NULL)
-    return 0;
-
-  if (GetOnePositionArgument(s1,x,w,pFinalX,(float)scrWidth/100,scrWidth) &&
-      GetOnePositionArgument(s2,y,h,pFinalY,(float)scrHeight/100,scrHeight))
-    return 2;
-  else
-    return 0;
+  if (s1 != NULL && s2 != NULL)
+    if (GetOnePositionArgument(s1,x,w,pFinalX,(float)scrWidth/100,scrWidth) &&
+        GetOnePositionArgument(s2,y,h,pFinalY,(float)scrHeight/100,scrHeight))
+      retval = 2;
+    else
+      *fWarp = FALSE; /* make sure warping is off for interactive moves */
+  
+  if (s1) free(s1);
+  if (s2) free(s2);
+  if (warp) free(warp);
+  
+  return retval;
 }
 
 /*****************************************************************************
Index: fvwm/move.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/move.c,v
retrieving revision 1.12
diff -u -r1.12 move.c
--- fvwm/move.c	1998/11/09 14:10:19	1.12
+++ fvwm/move.c	1998/11/10 14:51:23
@@ -119,6 +119,7 @@
   int width, height;
   int page_x, page_y;
   int unit_x, unit_y;
+  Bool fWarp = FALSE;
 
   if (DeferExecution(eventp,&w,&tmp_win,&context, MOVE,ButtonPress))
     return;
@@ -165,8 +166,8 @@
     }
   else
     {
-      n = GetPositionArguments(action,x,y,width+tmp_win->bw,
-			       height+tmp_win->bw,&FinalX,&FinalY);
+      n = GetMoveArguments(action,x,y,width+tmp_win->bw,height+tmp_win->bw,
+                           &FinalX,&FinalY,&fWarp);
       if (n != 2)
 	InteractiveMove(&w,tmp_win,&FinalX,&FinalY,eventp);
     }
@@ -174,10 +175,12 @@
   if (w == tmp_win->frame)
   {
     if (fAnimated) {
-      AnimatedMoveOfWindow(w,-1,-1,FinalX,FinalY,TRUE,-1,NULL);
+      AnimatedMoveOfWindow(w,-1,-1,FinalX,FinalY,fWarp,-1,NULL);
     }
     SetupFrame (tmp_win, FinalX, FinalY,
 		tmp_win->frame_width, tmp_win->frame_height,FALSE);
+    if (fWarp & !fAnimated) XWarpPointer(dpy, None, None, 0, 0, 0, 0,
+                                         FinalX - x, FinalY - y);
   }
   else /* icon window */
     {
@@ -194,19 +197,23 @@
                       tmp_win->icon_w_height + tmp_win->icon_p_height);
       if (fAnimated) {
         AnimatedMoveOfWindow(tmp_win->icon_w,-1,-1,tmp_win->icon_xl_loc,FinalY+tmp_win->icon_p_height,
-			     TRUE,-1,NULL);
+			     fWarp,-1,NULL);
       } else {
         XMoveWindow(dpy,tmp_win->icon_w,
 		    tmp_win->icon_xl_loc, FinalY+tmp_win->icon_p_height);
+        if (fWarp) XWarpPointer(dpy, None, None, 0, 0, 0, 0,
+                                FinalX - x, FinalY - y);
       }
       if(tmp_win->icon_pixmap_w != None)
 	{
 	  XMapWindow(dpy,tmp_win->icon_w);
 	  if (fAnimated) {
    	    AnimatedMoveOfWindow(tmp_win->icon_pixmap_w, -1,-1,
-				 tmp_win->icon_x_loc,FinalY,TRUE,-1,NULL);
+				 tmp_win->icon_x_loc,FinalY,fWarp,-1,NULL);
 	  } else {
 	    XMoveWindow(dpy, tmp_win->icon_pixmap_w, tmp_win->icon_x_loc,FinalY);
+            if (fWarp) XWarpPointer(dpy, None, None, 0, 0, 0, 0,
+                                    FinalX - x, FinalY - y);
 	  }
 	  XMapWindow(dpy,w);
 	}

---

From: [email-masked]
Date: Tue, 10 Nov 1998 17:48:58 +0100

> bothered by its default warp setting being changed.

OK, I thought it was vice versa.

Bye

Dominik

---

From: [email-masked]
Date: Tue, 10 Nov 1998 12:11:19 +0100

Bye

Dominik

---

From: Steve Robbins <[email-masked]>
Date: Tue, 10 Nov 1998 05:50:01 -0500 (EST)

---

From: Dan Espen <[email-masked]>
Date: Tue, 10 Nov 1998 19:54:52 -0500

> there. I wrote a number of them (see Parse.c and XResources.c).

Of course by "paper" you mean some html docs.

Don't forget Modparse.c!  (parsing for modules)

(I can almost hear what our scwm friends are thinking.) 

--
Dan Espen                                Phone: (732) 699-5570
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854
--
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].

---

From: [email-masked]
Date: Wed, 11 Nov 1998 09:35:01 +0100

> Of course by "paper" you mean some html docs.
                                     ^^^^
Uh oh, how do you spell that? Could I do it as an ASCII
file?

> Don't forget Modparse.c!  (parsing for modules)
 
Thanks for the hint.

> (I can almost hear what our scwm friends are thinking.) 

Well, if anybody wants to tell me what he is thinking I can
tell him what I think about configuring anything in LISP ;-)

Bye

Dominik

---

From: Dan Espen <[email-masked]>
Date: Wed, 11 Nov 1998 08:07:45 -0500

Anyone notice we aren't doing the best job of watching our subject lines.
This thread's subject was:

Re: Trial patch for moving with/without warping the pointer 

> Uh oh, how do you spell that? Could I do it as an ASCII

You can  do anything you  want.  You can even  send me the ASCII and I
will format it for you.

I think you are  trying to say  you don't have much experience writing
html.  I think if you look at one of our  simpler html files, you will
see that you can copy   one, and the  only  thing you  have to add  is
ASCII.

You can even  start your text with "<pre>"  (preformatted) and end  it
with  "</pre>" (end preformatted),   and get the  exact equivalent  of
ASCII.

> tell him what I think about configuring anything in LISP ;-)

Well, being an avid XEmacs user,  I have no problem  at all with LISP,
but I'm well aware I have lots of users here that would scream.

I hope someday to make this a non-issue, if  we can remove the need to
edit the configuration  files.  (My guess, we are  years away from the
final goal.)