Subject: FVWM: WarpToWindow question

From: Ken Marx <[email-masked]>
Date: Wed, 11 Dec 2002 11:37:05 -0800

Hi,

I've been beating my head on this one for over
a day. I'm hoping I'm just clueless and that
there's a simple way:

I have an already created window named "window 2"
(in this case it's an xterm, but also want this
for my mozilla browser, mail windows, etc.)

I'd like to map a function key, say F2, to
raise/focus/warpto said "window 2".

I've been trying things like:

AddToFunc   FuncWindowTest
        + I WindowId window2 Focus
        + I WindowId window2 Raise
        + I WindowId window2 WarpToWindow 50 50

Key F2 A N FuncWindowTest

But no dice. Is there a way?

Thanks for your help.

(p.s. Please email direct to me, since
I'm not subscribed to any fvwm lists.)

-- 
Ken Marx, [email-masked]
In order to make real progress we must sharpen our pencils and objectify the 
critical resources.
		- http://www.bigshed.com/cgi-bin/speak.cgi

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
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: Mikhael Goikhman <[email-masked]>
Date: Wed, 11 Dec 2002 22:43:52 +0000

> I'm not subscribed to any fvwm lists.)

WindowId operates on ids that X gives to windows, these are very big
random numbers that you don't usually know. You only want to execute
WindowId on constructed ids, like $0, $w or $[my_previously_stored_id]
and not on some known in advance value.

So WindowId will not do you good here. What you need is the Next command.

  DestroyFunc FuncWindowTest
  AddToFunc   FuncWindowTest
  + I Focus
  + I Raise
  + I WarpToWindow 50 50

  Next ("Mozila*") FuncWindowTest

You may want to specify some options for Next, like:

  Next (Mozilla, !Iconic) FuncWindowTest
  Next (AllowFocus) Focus
  Next (XTerm, !Shaded) WindowShade

If you really want to see how WindowId may be useful here is an obfuscated
and redundant way of doing the same as the above:

  DestroyFunc FuncWindowTest
  AddToFunc   FuncWindowTest
  + I WindowId $0 Focus
  + I WindowId $0 Raise
  + I WindowId $0 WarpToWindow 50 50

  Next ("Mozila*") FuncWindowTest $w     # it should be $$w to be sure

In your specific case you may reuse one existing function, but I don't
want to suggest this (since this function may be changed), write your own.

Regards,
Mikhael.

---

From: Christian MICHON <[email-masked]>
Date: Thu, 12 Dec 2002 05:28:59 +0100 (CET)

For what it's worth, here's what I did 2 weeks ago...

AddToFunc       MyWarp I Raise
                + I WarpToWindow 50 50

Key     Tab     A       M       Next (AcceptsFocus !Iconic) MyWarp

Explaination: instead of the windowlist, I can now navigate through all
non iconified apps on the current desk with Alt-Tab (I'm in follow focus).
The neat part is the warptowindow to be at the center of the window.

Now the cool part: when I'm prompted for a passwd in mozilla for example,
a simple Alt-Tab immediately warps to the latest created window. No mouse
needed ;)

Christian

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
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: Ken Marx <[email-masked]>
Date: Fri, 13 Dec 2002 17:00:33 -0800

Hi,

Mikhael Goikhman already graciously addressed my
question, but I was wondering if the below
hack would be of interest to you:

I thought it might be nice to add regex type
name matching to conditions. So I hacked in
some support for things like:

DestroyFunc RaiseWarptoWin
AddToFunc   RaiseWarptoWin
    + I Focus
    + I Iconify -1
    + I Raise
    + I WarpToWindow 50 50

Key F2 A N Next (RegexMatch "[Ss]omename.*[0-9]") RaiseWarptoWin

I'm not sure exactly what !RegexMatch should mean, since
that's (I believe?) kind of handled by '!' in front of
the name itself. Suggestions welcome on this.

Also - PCRE (perl regex) functionality can easily be had
by simply doing #include <pcreposix.h>. This wraps the
posix regcomp/exec calls nicely (see man pcreposix).

I'll include the -c diffs below in case anyone remotely
cares... If not, sorry for the bandwidth, and thanks
again for the help.

k.

-- 
Ken Marx, [email-masked]
Examine where the rubber meets the road on the bandwith issues!!
		- http://www.bigshed.com/cgi-bin/speak.cgi

================================================================
Of course, a number of more/less elegant ways of 
incorporating this. Flame away...
--------------------------------------
*** fvwm.h.bak0 Fri Dec 13 12:12:00 2002
--- fvwm.h      Fri Dec 13 12:55:11 2002
***************
*** 49,54 ****
--- 49,56 ----
  
  /* ---------------------------- included header files ----------------------- */
  
+ #include <sys/types.h>
+ #include <regex.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
  #include <X11/cursorfont.h>
***************
*** 435,444 ****
--- 437,448 ----
                unsigned use_circulate_hit_icon : 1;
                unsigned use_circulate_hit_shaded : 1;
                unsigned use_do_accept_focus : 1;
+               unsigned use_regex_matching : 1;
        } my_flags;
        window_flags flags;
        window_flags flag_mask;
        char *name;
+       regex_t *regexp;
        int layer;
  } WindowConditionMask;
  
[sploot.vicor-nb.com] -/work/fvwm-2.5.4/fvwm <64> !!:gs/fvwm.h/conditional.c
diff -c conditional.c.bak0 conditional.c
*** conditional.c.bak0  Fri Dec 13 12:11:53 2002
--- conditional.c       Fri Dec 13 13:30:53 2002
***************
*** 327,332 ****
--- 327,340 ----
                free(mask->name - 1);
        }
  
+       if (mask->regexp)
+       {
+           regfree( mask->regexp );
+           free( mask->regexp );
+           mask->regexp = NULL;
+           mask->my_flags.use_regex_matching = 0;
+       }
+ 
        return;
  }
  
***************
*** 469,474 ****
--- 477,487 ----
                {
                        mask->my_flags.use_circulate_hit_shaded = on;
                }
+               else if (StrEquals(cond,"RegexMatch"))
+               {
+                       mask->regexp = (regex_t *)malloc( sizeof( regex_t ) );
+                       mask->my_flags.use_regex_matching = on;
+               }
                else if (StrEquals(cond,"State"))
                {
                        if (sscanf(tmp, "%d", &state) &&
***************
*** 538,543 ****
--- 551,565 ----
                free(prev_condition);
        }
  
+       if ( mask->regexp && mask->name )
+       {
+           int ret;
+           ret = regcomp( mask->regexp, mask->name, REG_EXTENDED );
+           if (ret)
+           {
+               fprintf( stderr, "Bad regcomp(%s): %d\n", mask->name, ret );
+           }
+       }
        return;
  }
  
***************
*** 611,622 ****
  
        /* Yes, I know this could be shorter, but it's hard to understand then
         */
!       fMatchesName = matchWildcards(mask->name, fw->name.name);
!       fMatchesIconName = matchWildcards(mask->name, fw->icon_name.name);
!       fMatchesClass = (fw->class.res_class &&
!                        matchWildcards(mask->name,fw->class.res_class));
!       fMatchesResource = (fw->class.res_name &&
!                           matchWildcards(mask->name, fw->class.res_name));
        fMatches = (fMatchesName || fMatchesIconName || fMatchesClass ||
                    fMatchesResource);
  
--- 633,659 ----
  
        /* Yes, I know this could be shorter, but it's hard to understand then
         */
!       if (mask->regexp)
!       {
!           fMatchesName = ! regexec(mask->regexp, fw->name.name, 0, 0, 0);
!           fMatchesIconName = ! regexec(mask->regexp,
!                                       fw->icon_name.name, 0, 0, 0);
!           fMatchesClass = (fw->class.res_class &&
!                        ! regexec(mask->regexp,fw->class.res_class, 0, 0, 0));
!           fMatchesResource = (fw->class.res_name &&
!                       ! regexec(mask->regexp, fw->class.res_name, 0, 0, 0));
!       }
!       else
!       {
!           /* Old style wildcard matching
!           */
!           fMatchesName = matchWildcards(mask->name, fw->name.name);
!           fMatchesIconName = matchWildcards(mask->name, fw->icon_name.name);
!           fMatchesClass = (fw->class.res_class &&
!                            matchWildcards(mask->name,fw->class.res_class));
!           fMatchesResource = (fw->class.res_name &&
!                               matchWildcards(mask->name, fw->class.res_name));
!       }
        fMatches = (fMatchesName || fMatchesIconName || fMatchesClass ||
                    fMatchesResource);