function woes

I’ve got a fvwmiconman that I would like to behave like this: when I click the left mouse button on an icon, I want the window to (1) raise if it’s not raised and not iconified, (2) iconify if it’s raised (3) deiconify if iconified. I know it must be pretty simple, but I just can’t get it… here’s what I have so far…

*FvwmIconMan: Action Mouse 1 N sendcommand FuncFvwmIconClick

and

DestroyFunc FuncFvwmDeiconifyRaiseFocus
AddToFunc   FuncFvwmDeiconifyRaiseFocus
+ I Iconify false
+ I FlipFocus
+ I Raise

DestroyFunc FuncFvwmFocusRaise
AddToFunc   FuncFvwmFocusRaise
+ I FlipFocus
+ I Raise

DestroyFunc FuncFvwmIconClick
AddToFunc FuncFvwmIconClick
+ I ThisWindow (Raised) Iconify true
+ I ThisWindow (Iconic) FuncFvwmDeiconifyRaiseFocus
+ I ThisWindow (!Raised) FuncFvwmFocusRaise

Depending what order I put the lines in that last function, the window either iconifies then deiconifies, or the other way around… How can I make it do the right one, then stop?

Thanks, Jay K

It doesn’t make sense to FlipFocus before you raise. I’d swap those last two definitions over.

Well, it looks OK to me. If it’s giving you problems, I suppose you could add:

+ I TestRc (Match) Break

… between each of the statements, to see if that helps.

– Thomas Adam

That does seem to help, though I can’t find anything about it in the man pages… what exactly does that do? This works:

DestroyFunc FuncFvwmDeiconifyRaiseFocus
AddToFunc   FuncFvwmDeiconifyRaiseFocus
+ I Iconify false
+ I Raise
+ I FlipFocus

DestroyFunc FuncFvwmFocusRaise
AddToFunc   FuncFvwmFocusRaise
+ I Raise
+ I FlipFocus

DestroyFunc FuncFvwmIconClick
AddToFunc FuncFvwmIconClick
+ I ThisWindow (Iconic) FuncFvwmDeiconifyRaiseFocus
+ I TestRc (Match) Break
+ I ThisWindow (Raised) Iconify true
+ I TestRc (Match) Break
+ I ThisWindow (!Raised) FuncFvwmFocusRaise

Also, for some reason the (Iconic) line has to be before the (Raised) line… oh well, it works :slight_smile:

What’s happening is that you only want the action to happen once, depending on the state of the window. Now by-and-large that ought to be fine. The only reason I can think of that would lead to the problems you’re having, is if you’re using FvwmEvent, that’s listening for a specific action…

As to what:

+ I TestRc (Match) Break

… does, well… TestRc looks at the return code from the previous command run, and then if it was successul, then it will run whatever you tell it. In this case, we want to exit the function, so “Break”.

– Thomas Adam