Subject: Patch to allow keypad keys in resize

From: Tim Phipps <[email-masked]>
Date: Mon, 21 Sep 1998 16:10:03 +0100

Hi all,
	Here's a patch to fvwm/move.c that will allow the keypad number keys to
be used in a resize.  The resize amount is computed from the resize
hints of the window so resizing xterms will change in size by one column
and/or row per key press.  This also affects moving but diagonal moves
may not be at 45 degrees with unequal resize increments.  The arrow keys
still work as well as Control and Shift arrows.  I use the following to
get a nice intuitive resize from keypad behaviour:

Key KP_5 WTSF M popup ResizeMenu
AddToMenu ResizeMenu
+ "Which way Jim?"              Title
+ "&7 %xtrek_fed_e.xbm%"        my_resize_dir   0   0
+ "&8 %xtrek_fed_0.xbm%"        my_resize_dir  50   0
+ "&9 %xtrek_fed_2.xbm%"        my_resize_dir 100   0
+ "&6 %xtrek_fed_4.xbm%"        my_resize_dir 100  50
+ "&3 %xtrek_fed_6.xbm%"        my_resize_dir 100 100
+ "&2 %xtrek_fed_8.xbm%"        my_resize_dir  50 100
+ "&1 %xtrek_fed_a.xbm%"        my_resize_dir   0 100
+ "&4 %xtrek_fed_c.xbm%"        my_resize_dir   0  50
AddToFunc my_resize_dir "I" Raise
+ "I" WarpToWindow $0 $1
+ "I" Resize

You need the keypad keys in menus patch I posted earlier for this to be
really funky and it would help if resize started immediately as someone
was talking about doing (it takes an extra key press to get it going but
that's what auto-repeat is for)

Cheers,
Tim.

*** move.c.orig	Mon Sep 21 15:01:43 1998
--- move.c	Mon Sep 21 15:35:22 1998
***************
*** 430,444 ****
  void Keyboard_shortcuts(XEvent *Event, int ReturnEvent)  
  {
    int x,y,x_root,y_root;
!   int move_size,x_move,y_move;
    KeySym keysym;
  
!   /* Pick the size of the cursor movement */
!   move_size = Scr.EntryHeight;
    if(Event->xkey.state & ControlMask)
!     move_size = 1;
    if(Event->xkey.state & ShiftMask)
!     move_size = 100;
  
    keysym = XLookupKeysym(&Event->xkey,0);
  
--- 430,448 ----
  void Keyboard_shortcuts(XEvent *Event, int ReturnEvent)  
  {
    int x,y,x_root,y_root;
!   int x_move_size,y_move_size,x_move,y_move;
    KeySym keysym;
  
!   /* Pick the size of the cursor movement, window resize increments are first
!      choice followed by height of a menu item */
!   x_move_size = Scr.Hilite->hints.width_inc;
!   y_move_size = Scr.Hilite->hints.height_inc;
!   if (y_move_size < 5) y_move_size = Scr.EntryHeight;
!   if (x_move_size < 5) x_move_size = y_move_size;
    if(Event->xkey.state & ControlMask)
!     x_move_size = y_move_size = 1;
    if(Event->xkey.state & ShiftMask)
!     x_move_size = y_move_size = 100;
  
    keysym = XLookupKeysym(&Event->xkey,0);
  
***************
*** 447,472 ****
    switch(keysym)
      {
      case XK_Up:
      case XK_k:
      case XK_p:
!       y_move = -move_size;
        break;
      case XK_Down:
      case XK_n:
      case XK_j:
!       y_move = move_size;
        break;
      case XK_Left:
      case XK_b:
      case XK_h:
!       x_move = -move_size;
        break;
      case XK_Right:
      case XK_f:
      case XK_l:
!       x_move = move_size;
        break;
      case XK_Return:
      case XK_space:
        /* beat up the event */
        Event->type = ReturnEvent;
--- 451,497 ----
    switch(keysym)
      {
      case XK_Up:
+     case XK_KP_8:
      case XK_k:
      case XK_p:
!       y_move = -y_move_size;
        break;
      case XK_Down:
+     case XK_KP_2:
      case XK_n:
      case XK_j:
!       y_move = y_move_size;
        break;
      case XK_Left:
+     case XK_KP_4:
      case XK_b:
      case XK_h:
!       x_move = -x_move_size;
        break;
      case XK_Right:
+     case XK_KP_6:
      case XK_f:
      case XK_l:
!       x_move = x_move_size;
        break;
+     case XK_KP_1:
+       x_move = -x_move_size;
+       y_move = y_move_size;
+       break;
+     case XK_KP_3:
+       x_move = x_move_size;
+       y_move = y_move_size;
+       break;
+     case XK_KP_7:
+       x_move = -x_move_size;
+       y_move = -y_move_size;
+       break;
+     case XK_KP_9:
+       x_move = x_move_size;
+       y_move = -y_move_size;
+       break;
      case XK_Return:
+     case XK_KP_Enter:
      case XK_space:
        /* beat up the event */
        Event->type = ReturnEvent;

---

From: Austin Donnelly <[email-masked]>
Date: Mon, 21 Sep 1998 16:39:49 +0100

On Mon, 21 Sep 1998, Tim Phipps wrote:

> be used in a resize.

Does this stop me binding the keypad keys with Key ... ?  I'd quite
like to make them jump to different pages of the current desk.

Austin
--
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: Tim Phipps <[email-masked]>
Date: Mon, 21 Sep 1998 16:44:49 +0100

> like to make them jump to different pages of the current desk.

No, not at all, they only affect behaviour while a resize/move is
happening.

Cheers,
Tim.