Subject: FVWM enhancement ...

From: James Hu <[email-masked]>
Date: Mon, 24 Aug 1998 22:03:51 -0700 (PDT)

[ I originally sent this message to Chuck Hines, but he advised me
  that he was no longer actively maintaining FVWM, and that I should
  instead send my message to this list.  I am not subscribed to the
  list.  -- jxh ]

Hello,

I wanted the ability to be able to cycle through my desktops rather
than needing to change directions.  So I hacked one of the functions
in fvwm/virtual.c to allow me to do this.  It involves altering the
syntax of the "Desk" command slightly.  Currently --

     Desk arg1 arg2
        ...

          If arg1 is non zero then the next desktop  number  will
          be  the  current  desktop  number  plus  arg1.  Desktop
          numbers can be negative.

          If arg1 is zero then the new  desktop  number  will  be
          arg2.
        ...

This would now be changed to --

          If arg1 is zero then the new  desktop  number  will  be
          arg2.

          If arg1 is 1 then the next desktop number will  be  the
          current  desktop  number  plus  arg2.  Desktop  numbers
          can be negative.

          If arg1 is greater than 1 the next desktop  number will
          be the current  desktop number  plus arg2  modulo arg1.
          The next desktop number will not be negative.

          If arg1 is less than 0  the next desktop number will be
          the current desktop  number plus  arg2 modulo +/- arg1.
          That is  if the next desktop  number will be less  than
          or equal to arg1  the next desktop number  will  become
          -arg1-1.  If the  next  desktop  number will be greater
          than  or equal to  -arg1  the next  desktop number will
          become arg1+1.  Otherwise the next desktop number keeps
          its calculated value.

Here is the new code I wrote --

Version -- fvwm-2.0.46
File -- fvwm/virtual.c
Function -- changeDesks()
Line -- 441

void  changeDesks(int val1, int val2)
{
  int oldDesk;
  unsigned int modulus, newdesk;
  FvwmWindow *FocusWin = 0, *t;
  static FvwmWindow *StickyWin = 0;

  oldDesk = Scr.CurrentDesk;

#if 0
  if(val1 != 0)
    {
      Scr.CurrentDesk = Scr.CurrentDesk + val1;
    }
  else
    {
      Scr.CurrentDesk = val2;
      if(Scr.CurrentDesk == oldDesk)
        return;
    }
#else
  switch(val1)
    {
    case 0:
      Scr.CurrentDesk = val2;
      if(Scr.CurrentDesk == oldDesk)
        return;
      break;
    case 1:
      Scr.CurrentDesk = Scr.CurrentDesk + val2;
      break;
    default:
      Scr.CurrentDesk = Scr.CurrentDesk + val2;
      if (val1 > 0 && Scr.CurrentDesk > 0)
        Scr.CurrentDesk %= val1;
      else if (val1 > 0 && Scr.CurrentDesk < 0)
        Scr.CurrentDesk = val1-1;
      else if (val1 < 0 && Scr.CurrentDesk > 0)
        {
          Scr.CurrentDesk %= -val1;
          if (Scr.CurrentDesk == 0)
            Scr.CurrentDesk = val1+1;
        }
      else if (val1 < 0 && Scr.CurrentDesk < 0)
        {
          Scr.CurrentDesk = -(-Scr.CurrentDesk % -val1);
          if (Scr.CurrentDesk == 0)
            Scr.CurrentDesk = -(val1+1);
        }
    }
#endif

    /* ... rest of function remains unchanged ... */

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