Subject: FVWM: Fvwm 2 FvwmPager "Click-to-Focus"

From: John Morrow <[email-masked]>
Date: Mon, 3 Mar 1997 13:02:52 -0500 (EST)

I've been putting off going from 1.24r to 2.0.X for a while now
because quite a few things I'd been using didn't seem to be
implemented yet but now that most of them have appeared, I've decided
to give it a go.  Other than the fact that I liked being able to make
sticky windows a different color (too minor to get annoyed over), the
main difference that has been bothering me is the pager behavior.  I
had generally been using the built-in pager in 1.24r and it allows you
to bring windows into focus by clicking on them inside of the pager.
This is something that I use a heck of alot (I use click-to-focus for
my windows) and the module pager just doesn't seem to do it though you
can *move* a window inside of it and raise and focus it that way.
Since I didn't expect this to be addressed quickly (I'm sure people
have better things to work on right now) but since I consider it a
"must have" feature if I'm going to work with 2.0.X, I took a look at
the code and came up with some changes that seems to add this feature
so long as you stay within the same desktop (I generally use a single
desktop pager like the old built-in, anyway) and don't iconify the
pager (it won't crash the pager in those instances -- it just won't
work to focus the window).  I don't have any X programming experience
and I've only read through some of the pager code (the changes are
taken from the move code) so I'm essentially looking for someone to
comment, help, or adopt this change and incorporate it into 2.0.X.
I'm sure it could be made to work across desktops since moving does
and it might be possible to make it work for the icon and the changes
don't look that complex but since I don't know very much about X
programming, I can only guess at what needs to be done and I'm
reluctant to make more major changes blind.  The patch for my changes
appears below:

John Morrow

========================= x_pager.c.patch =============================
--- x_pager.c.orig	Mon Mar  3 10:26:32 1997
+++ x_pager.c	Mon Mar  3 12:28:09 1997
@@ -55,7 +55,6 @@
 int Wait = 0;
 XErrorHandler FvwmErrorHandler(Display *, XErrorEvent *);
 
-
 /* assorted gray bitmaps for decorative borders */
 #define g_width 2
 #define g_height 2
@@ -861,6 +860,8 @@
 void SwitchToDeskAndPage(int Desk, XEvent *Event)
 {
   char command[256];
+  PagerWindow *t;
+  int NewDesk;
 
   if (Scr.CurrentDesk != (Desk+desk1))
     {
@@ -889,6 +890,73 @@
       SendInfo(fd,command,0);  
     }
 #endif
+
+#ifndef NON_VIRTUAL
+/****************************************************************************/
+/* The following modification allows you to "click to focus" inside of the  */
+/* pager window like you could in the 1.24r built-in pager.  This is mostly */
+/* just code ripped out of the MoveWindow(Event) function and added here.   */
+/* There are a couple of things that this code won't do.  It won't work in  */
+/* an iconified pager and it won't work when selecting windows or pages in  */
+/* different desktops.  It is possible that both of these could be made to  */
+/* work but since I've never really programmed in X before and have only a  */
+/* basic idea about how this code works, fixing this further is beyond my   */
+/* abilities at this time. -- John Morrow ([email-masked])                 */
+/****************************************************************************/
+  /* THE FOLLOWING "if" LINE IS A HOOK FOR ADDING IN A CONFIG FILE OPTION 
+     TO MAKE THIS SELECTABLE FROM WITHIN AN "fvwm2rc" FILE */ 
+  if (0 == 0)
+    {
+      t = Start;
+
+      while ((t != NULL) && (t->PagerView != Event->xbutton.subwindow))
+	t = t->next;
+      
+      if (t == NULL)
+	return;
+      
+      NewDesk = t->desk - desk1;
+      
+      if ((NewDesk < 0) || (NewDesk >= ndesks))
+	return;
+      
+      XRaiseWindow(dpy, t->PagerView);
+      
+      if ((NewDesk + desk1) != t->desk)
+	{
+	  if (((t->flags & ICONIFIED) && (t->flags & StickyIcon)) || 
+	      (t->flags & STICKY))
+	    {
+	      NewDesk = Scr.CurrentDesk - desk1;
+	      if (t->desk != Scr.CurrentDesk)
+		ChangeDeskForWindow(t, Scr.CurrentDesk);
+	    }
+	  else
+	    {
+	      sprintf(command, "WindowsDesk %d", NewDesk + desk1);
+	      SendInfo(fd, command, t->w);
+	      t->desk = NewDesk + desk1;
+	    };
+	};
+      
+      if ((NewDesk >= 0) && (NewDesk < ndesks))
+	SendInfo(fd, "Raise", t->w);
+      
+      if (Scr.CurrentDesk == t->desk)
+	{
+	  XSync(dpy, 0);
+	  sleep_a_little(5000);
+	  XSync(dpy, 0);
+	  XSetInputFocus(dpy, t->w, RevertToParent, Event->xbutton.time);
+	}
+      else
+	{
+	  /* CODE SHOULD PROBABLY BE PUT *HERE* TO MAKE THIS WORK ACROSS 
+	     MULTIPLE DESKTOPS */
+	};
+    };
+#endif
+
   Wait = 1;
 }
 
@@ -904,6 +972,7 @@
 	  (icon_h*Scr.MyDisplayHeight));
   SendInfo(fd,command,0);  
 #endif
+
   Wait = 1;
 }

--
--
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].

---

From: Jim Patterson <[email-masked]>
Date: Mon, 03 Mar 1997 12:04:03 -0700

> reluctant to make more major changes blind.  The patch for my changes

For me, clicking with MB2 in the pager already does just this.

Jim P

---

From: Albrecht Kadlec <[email-masked]>
Date: Thu, 6 Mar 97 18:36:31 +0100

[about changing the mouse1 ( mouse2 ? ) action in FvwmPager]

pleas make it

*FvwwmPagerMouse1Click	any_function

and use SendInfo()

SendInfo(fd,fn,win);

fd is the pipe back to fvwm2,
fn is any fvwm2 command (read from .fvwm2rc)
win is the selected window.

If you want to make it really clean, you can make all the following
possibilities:

*FvwmPagerMouse[123](click|move|doubleclick) anyfunction

albrecht
--
Home is where the heart lies, but if the heart lies ? -- Marillion