Re: FVWM: EdgeResistance and Focus

From: Henrique Martins <martins_at_martins.hpl.hp.com>
Date: Tue, 19 Mar 1996 23:16:06 -0800

kai> When the mouse pointer is warped to a window (with Focus, say), it
kai> is warped to the upper left hand corner. Is there a way to have
kai> it warpt to the center instead?

david> I made a suggestion here a while ago that X and Y percentages be
david> added to the warp function. So, "warp 0 0" gives the current
david> behaviour, "warp 0 100" puts the pointer in the lower left corner,
david> and "warp 50 50" gives the commonly desired behavior of centering
david> the pointer, all independent of the window size.


  Without going into the merits of warping to the middle vs the upper left
  corner, the patch below should accomplish what David describes.

  I made Focus == Focus 0 0, i.e. no parameters equals current behavior.
  Should this patch have no adverse side effects (aka bugs) and be
  integrated in the main version, Focus == Focus 50 50, could be an
  alternative.

  The patch below was minimally tested. It should apply cleanly against
  2.0.41.

  -- Henrique (martins_at_hpl.hp.com)


*** 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;
! }
!
!
  
  
  /****************************************************************************
--
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 majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Wed Mar 20 1996 - 01:16:17 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:58 BST