-- Ken Marx, kmarx_at_vicor-nb.com 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); Mikhael Goikhman wrote: > On 11 Dec 2002 11:37:05 -0800, Ken Marx wrote: > >>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.) > > > 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. > > -- 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 majordomo_at_fvwm.org. To report problems, send mail to fvwm-owner_at_fvwm.org.Received on Fri Dec 13 2002 - 19:11:15 GMT
This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:54 BST