The "Next ... Focus" command is what I've been doing... and while I
agree that running an external command with every page switch is
excessive... well... let's just say there are few things more powerful
than my desire to procrastinate doing my philosophy assignment.

and so I give you: fvwm-track-focus     *trumpets: ta-da*

use at your own risk... it stores the Focused window id's in a tmp
file, and then sends commands back to fvwm via PipeRead. I think it
would be better implemented as a Module, but I'm lazy, and my
p3:450mhz has no noticible delay doing it, so I'm happy. it's way
better than having to alt-tab every time I switch pages to find the
window I want.

here's what I added to my .fvwm2rc:
PipeRead 'fvwm-track-focus /home/pmcalpin/tmp/fvwm.tf.dat init'

DestroyFunc GotoPageRaise
AddToFunc GotoPageRaise
     + "I" Current PipeRead 'fvwm-track-focus /home/pmcalpin/tmp/fvwm.tf.dat 
$[page.nx] $[page.ny] $w'
     + "I" GotoPage $0 $1
     + "I" PipeRead 'fvwm-track-focus /home/pmcalpin/tmp/fvwm.tf.dat $0 $1'

and then an example binding is:
Key KP_Home  A N  GotoPageRaise  0 0

don't forget to change what I've done for your own system... I assume
your paths are different than mine. You probably want to look at
fvwm-track-focus.c before you compile, too.

enjoy (or not),
peter =)

On Tue, Nov 05, 2002 at 09:35:33PM -0500, Ben Winslow wrote:
> I was trying to have together something to memorize the last focused 
> window on a page and switch back to it whenever that page is 
> reactivated, but I've given up for the moment--fvwm can't double-expand 
> $ variables and launching an external program for every page switch 
> seems to be a bit excessive to me.  There might be a way to do it all 
> internally, but I haven't figured out what that is yet.

-- 
Peter McAlpine
[EMAIL PROTECTED]
/*
 * fvwm-track-focus.c
 * Peter McAlpine, 2002
 * (hopefully) can be PipeRead from fvwm to raise windows with GotoPage
 */

#include <stdio.h>
#include <stdlib.h>

#define MAXX 5
#define MAXY 5
#define MAX_STR_LEN 64

int errno;

int main(int argc, char *argv[]) {
     FILE *fdat = NULL;
     char idara[MAXX][MAXY][MAX_STR_LEN];
     int j, k;
     int x, y;

     if (argc == 1) {
          fprintf(stderr, "fvwm-track-focus - by Peter McAlpine\n");
          fprintf(stderr, "Usage:\n");
          fprintf(stderr, "      fvwm-track-focus FILE init\n");
          fprintf(stderr, "      fvwm-track-focus FILE x y\n");
          fprintf(stderr, "      fvwm-track-focus FILE x y WINDOWID\n");
          return 1;
     }

     /* handle init c.l. opt */
     if (strcmp(argv[2], "init") == 0) {
          if ((fdat = fopen(argv[1], "w+")) == NULL) {
               fprintf(stderr, "rats, could not open file\n");
               return errno;
          }
          j = 0;
          while (j < MAXX) {
               k = 0;
               while (k < MAXY) {
                    fprintf(fdat, "NULL\n");
                    k++;
               }
               j++;
          }
          fclose(fdat);

          return 0;
     }

     /* init ara */
     fdat = fopen(argv[1], "r+");
     if (fdat == NULL) {
          fprintf(stderr, "rats, couldn't open file: %s\n", argv[1]);
          return errno;
     }
     x = atoi(argv[2]);
     y = atoi(argv[3]);

     /* read ara from dat file */
     j = 0;
     while (j < MAXX) {
          k = 0;
          while (k < MAXY) {
               fscanf(fdat, "%s\n", idara[j][k]);
               k++;
          }
          j++;
     }

     if (argc == 4) {     // read id request
          if (strcmp(idara[x][y], "NULL") == 0) {
               printf("Next [CurrentPage !iconic] Focus\n");
          } else {
               printf("WindowId %s Focus NoWarp\n", idara[x][y]);
          }
     } else {     // write id request
          strcpy(idara[x][y], argv[4]);
          fclose(fdat);
          fdat = fopen(argv[1], "w+");
          j = 0;
          while (j < MAXX) {
               k = 0;
               while (k < MAXY) {
                    fprintf(fdat, "%s\n", idara[j][k]);
                    k++;
               }
               j++;
          }
     }

     fclose(fdat);

     return 0;
}

Reply via email to