Subject: FVWM: FlipFocus

From: Dan Niles <[email-masked]>
Date: Wed, 1 May 1996 16:47:49 -0500

After using FlipFocus for a while, I discovered that it didn't work exactly
as I would like.  So I modified it, and I like the new behavior much
better.

Apply the new patch below, and tell me if you like the new version better
too.

The first patch will convert directly from fvwm 2.0.42, the second one will
convert the old FlipFocus to the new one.

I hope that makes sense.

------------------------- fvwm-2.0.42-FlipFocus.patch2 ----------------------
--- parse.h.orig	Thu Mar 28 09:24:48 1996
+++ parse.h	Mon Apr 29 17:03:13 1996
@@ -85,6 +85,7 @@
 #define F_RAISELOWER            108
 #define F_MAXIMIZE              109
 #define F_FOCUS                 110
+#define F_FLIP_FOCUS            111
 
 /* Functions for use by modules only! */
 #define F_SEND_WINDOW_LIST     1000
--- misc.h.orig	Thu Apr  4 17:47:30 1996
+++ misc.h	Mon Apr 29 17:03:46 1996
@@ -381,6 +381,8 @@
 	       unsigned long context,char *action, int *Module);
 void raise_it_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
 		   unsigned long context, char *action, int *Module);
+void flip_focus_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
+		unsigned long context, char *action, int *Module);
 void focus_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
 		unsigned long context, char *action, int *Module);
 void SendDataToModule(XEvent *eventp,Window w,FvwmWindow *tmp_win,
--- functions.c.orig	Thu Mar 28 09:24:23 1996
+++ functions.c	Mon Apr 29 17:03:22 1996
@@ -53,6 +53,7 @@
   {"EdgeResistance",SetEdgeResistance,F_EDGE_RES,           FUNC_NO_WINDOW},
   {"Exec",         exec_function,    F_EXEC,                FUNC_NO_WINDOW},
   {"ExecUseSHELL", exec_setup,       F_EXEC_SETUP,          FUNC_NO_WINDOW},
+  {"FlipFocus",    flip_focus_func,  F_FLIP_FOCUS,          FUNC_NEEDS_WINDOW},
   {"Focus",        focus_func,       F_FOCUS,               FUNC_NEEDS_WINDOW},
   {"Function",     ComplexFunction,  F_FUNCTION,            FUNC_NO_WINDOW},
   {"GotoPage",     goto_page_func,   F_GOTO_PAGE,           FUNC_NO_WINDOW},
--- builtins.c.orig	Wed Apr 10 12:38:25 1996
+++ builtins.c	Wed May  1 16:37:07 1996
@@ -757,6 +757,38 @@
 }

+void flip_focus_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
+		unsigned long context, char *action, int *Module)
+{
+
+  FvwmWindow *scratch;
+
+  if (DeferExecution(eventp,&w,&tmp_win,&context,SELECT,ButtonRelease))
+    return;
+
+  /* Reorder the window list */
+  if( Scr.Focus ){
+    if( Scr.Focus->next ) Scr.Focus->next->prev = Scr.Focus->prev;
+    if( Scr.Focus->prev ) Scr.Focus->prev->next = Scr.Focus->next;
+    Scr.Focus->next = Scr.FvwmRoot.next;
+    Scr.Focus->prev = &Scr.FvwmRoot;
+    if(Scr.FvwmRoot.next)Scr.FvwmRoot.next->prev = Scr.Focus;
+    Scr.FvwmRoot.next = Scr.Focus;
+  }
+  if( tmp_win != Scr.Focus ){
+    if( tmp_win->next ) tmp_win->next->prev = tmp_win->prev;
+    if( tmp_win->prev ) tmp_win->prev->next = tmp_win->next;
+    tmp_win->next = Scr.FvwmRoot.next;
+    tmp_win->prev = &Scr.FvwmRoot;
+    if(Scr.FvwmRoot.next)Scr.FvwmRoot.next->prev = tmp_win;
+    Scr.FvwmRoot.next = tmp_win;
+  }
+
+  FocusOn(tmp_win,0);
+
+}
+
+
 void focus_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
 		unsigned long context, char *action, int *Module)
 {
---------------------- END ----------------------

------------------------- fvwm-2.0.42-FlipFocus.p1to2 ----------------------
--- builtins.c.first	Wed May  1 16:21:15 1996
+++ builtins.c	Wed May  1 16:37:07 1996
@@ -766,18 +766,23 @@
   if (DeferExecution(eventp,&w,&tmp_win,&context,SELECT,ButtonRelease))
     return;
 
-  if( Scr.Focus == NULL || tmp_win == Scr.Focus ){
-    /* There is no window with focus */
-    FocusOn(tmp_win,0);
-    return;
+  /* Reorder the window list */
+  if( Scr.Focus ){
+    if( Scr.Focus->next ) Scr.Focus->next->prev = Scr.Focus->prev;
+    if( Scr.Focus->prev ) Scr.Focus->prev->next = Scr.Focus->next;
+    Scr.Focus->next = Scr.FvwmRoot.next;
+    Scr.Focus->prev = &Scr.FvwmRoot;
+    if(Scr.FvwmRoot.next)Scr.FvwmRoot.next->prev = Scr.Focus;
+    Scr.FvwmRoot.next = Scr.Focus;
+  }
+  if( tmp_win != Scr.Focus ){
+    if( tmp_win->next ) tmp_win->next->prev = tmp_win->prev;
+    if( tmp_win->prev ) tmp_win->prev->next = tmp_win->next;
+    tmp_win->next = Scr.FvwmRoot.next;
+    tmp_win->prev = &Scr.FvwmRoot;
+    if(Scr.FvwmRoot.next)Scr.FvwmRoot.next->prev = tmp_win;
+    Scr.FvwmRoot.next = tmp_win;
   }
-
-  scratch=Scr.Focus->next;
-  if( (Scr.Focus->next=tmp_win->next) ) Scr.Focus->next->prev=Scr.Focus;
-  if( (tmp_win->next=scratch) ) tmp_win->next->prev=tmp_win;
-  scratch=Scr.Focus->prev;
-  if( (Scr.Focus->prev=tmp_win->prev) ) Scr.Focus->prev->next=Scr.Focus;
-  if( (tmp_win->prev=scratch) ) tmp_win->prev->next=tmp_win;
 
   FocusOn(tmp_win,0);
 
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].