Subject: FVWM: Focus problems

From: "eli (e.) burke" <[email-masked]>
Date: Mon, 15 Apr 1996 08:42:00 -0400

I'm not sure whether this is a problem with my .fvwm2rc file, or with
fvwm2 (.0.41), and I don't remember seeing it mentioned on the list.
Anyhow, upon startup I have an xterm open, and it comes up underneath
the mouse. However, it doesn't get Focus until I move the mouse out of
the window and back in. Focus follows the mouse, SloppyFocus is on.

I was able to work around this by putting a Next[!iconic xterm] Focus
line in the init and restart functions, but then the cursor is in the
corner of the screen. So then I added a CursorMove to get it in the
middle of the xterm. 

The problem with these workarounds is that they are slow. Everything comes
up, I'll start to move the mouse around, and then Focus/CursorMove hits.

This brings me to a couple of questions: 
1) Why does Focus move the mouse to the top-left corner of the window? It
   looks like it is finding the window and then generating a fake mouse
   click to Raise the window. Could Focus be made to ignore the mouse?
2) If not, how about new command pair: SaveMousePosition and
   RestoreMousePosition. I agree that it seems silly to add those for a
   single problem, but I could see it being used in other places. Like 
   buttons that warp you to other desktops, and a "Back" button that 
   returns you to where you were, ala pushdir/popdir.
3) Or, as an alternative, how about saving the cursor position with the
   window history. That way Next[] and Prev[] will have access to it, and
   users can choose to restore the cursor position.
4) While I'm thinking about it, when we get more Style flags, how about a
   StaysOnBottom? My xsession always starts last, so I have to explicitly
   lower it. I'd rather not add a Next[xsession] Lower that will slow down
   the startup even further.

-Eli
--
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: Kai Grossjohann <[email-masked]>
Date: 15 Apr 1996 15:45:22 +0200

>>>>> On Mon, 15 Apr 1996 08:42:00 -0400 , "eli (e.) burke"
>>>>> <[email-masked]> said:

  Eli> 1) Why does Focus move the mouse to the top-left corner of the
  Eli>    window? It looks like it is finding the window and then
  Eli>    generating a fake mouse click to Raise the window. Could
  Eli>    Focus be made to ignore the mouse?

There's a patch (by Henrique Martins <[email-masked]>)
that allows additional arguments to the Focus command:

    Focus   0   0 == old behavior (default if no numbers given)
    Focus  50  50 == middle of window
    Focus 100 100 == lower right hand corner
    Focus   0 100 == lower left hand corner (I think)

I don't know if Chuck has/will put it in 2.0.42.

kai
--
There ain't no cure for the summertime blues.

----------focus-patch------------------------------
*** misc.h.orig	Tue Mar 19 21:44:59 1996
--- misc.h	Tue Mar 19 21:45:05 1996
***************
*** 274,280 ****
  void KeepOnTop(void);
  void show_panner(void);
  void WaitForButtonsUp(void);
! void FocusOn(FvwmWindow *t,int DeIconifyOnly);
  Bool PlaceWindow(FvwmWindow *tmp_win, unsigned long flags,int Desk);
  void free_window_names (FvwmWindow *tmp, Bool nukename, Bool nukeicon);
  
--- 274,280 ----
  void KeepOnTop(void);
  void show_panner(void);
  void WaitForButtonsUp(void);
! void FocusOn(FvwmWindow *t,int DeIconifyOnly,int percentX,int percentY);
  Bool PlaceWindow(FvwmWindow *tmp_win, unsigned long flags,int Desk);
  void free_window_names (FvwmWindow *tmp, Bool nukename, Bool nukeicon);
  
*** builtins.c.orig	Tue Mar 19 21:23:28 1996
--- builtins.c	Tue Mar 19 23:12:58 1996
***************
*** 150,156 ****
   * Moves focus to specified window 
   *
   *************************************************************************/
! void FocusOn(FvwmWindow *t,int DeIconifyOnly)
  {
  #ifndef NON_VIRTUAL
    int dx,dy;
--- 150,156 ----
   * Moves focus to specified window 
   *
   *************************************************************************/
! void FocusOn(FvwmWindow *t,int DeIconifyOnly,int percentX, int percentY)
  {
  #ifndef NON_VIRTUAL
    int dx,dy;
***************
*** 191,198 ****
    }
    else
    {
!     x = t->frame_x;
!     y = t->frame_y;
    }
    if(!(t->flags & ClickToFocus))
      XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, x+2,y+2);
--- 191,200 ----
    }
    else
    {
!     x = t->frame_x + (t->frame_width * percentX) / 100;
!     y = t->frame_y + (t->frame_height * percentY) / 100;
!     if (x == t->frame_x + t->frame_width) x--;
!     if (y == t->frame_y + t->frame_height) y--;
    }
    if(!(t->flags & ClickToFocus))
      XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, x+2,y+2);
***************
*** 705,715 ****
  
    if(val1 != 0)
    {
!     FocusOn((FvwmWindow *)val1,0);
      if (((FvwmWindow *)(val1))->flags & ICONIFIED)
      {
        DeIconify((FvwmWindow *)val1);
!       FocusOn((FvwmWindow *)val1,0);
      }
    }
  }
--- 707,717 ----
  
    if(val1 != 0)
    {
!     FocusOn((FvwmWindow *)val1,0,0,0);
      if (((FvwmWindow *)(val1))->flags & ICONIFIED)
      {
        DeIconify((FvwmWindow *)val1);
!       FocusOn((FvwmWindow *)val1,0,0,0);
      }
    }
  }
***************
*** 718,727 ****
  void focus_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
  		unsigned long context, char *action, int *Module)
  {
    if (DeferExecution(eventp,&w,&tmp_win,&context,SELECT,ButtonRelease))
      return;
  
!   FocusOn(tmp_win,0);
  }

--- 720,738 ----
  void focus_func(XEvent *eventp,Window w,FvwmWindow *tmp_win,
  		unsigned long context, char *action, int *Module)
  {
+   int val1, val2, val1_unit, val2_unit, n;
+   
+   n = GetTwoArguments(action, &val1, &val2, &val1_unit, &val2_unit);
+ 
+   if (n != 2 || val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100) {
+     val1 = 0;
+     val2 = 0;
+   }
+ 
    if (DeferExecution(eventp,&w,&tmp_win,&context,SELECT,ButtonRelease))
      return;
  
!   FocusOn(tmp_win,0,val1,val2);
  }

*** icons.c.orig	Tue Mar 19 21:43:11 1996
--- icons.c	Tue Mar 19 21:43:13 1996
***************
*** 730,741 ****
      }
  
    if(tmp_win->flags & ClickToFocus)
!     FocusOn(tmp_win,1);
  
    KeepOnTop();
  
    return;
! }

  /****************************************************************************
--- 730,743 ----
      }
  
    if(tmp_win->flags & ClickToFocus)
!     FocusOn(tmp_win,1,0,0);
  
    KeepOnTop();
  
    return;
! } 
!  
!  

  /****************************************************************************