Is there a windowstyle-like command that works for buttons?

I currently use WindowStyle to change the title bar colors of windows that have a specific state. What I would like to do is have a titlebar button whose vector graphic changes to reflect the state of the window. I had naively thought that something like “WindowStyle ButtonStyle …” would work, but it doesn’t seem to. Is there a command that will accomplish this?

My next thought was to switch the decor of the window, but if I’ve got 5 boolean states that I want to assign to buttons, then I would have to define 32 decors to have every possible combination. If I wanted a button that displayed the layer that a window was on, I’d require even more decors and would probably be forced to abandon this idea.

Please move this to the correct forum is I’ve chosen the wrong forum for this question.

–Flatline

That’s because “ButtonStyle” is not a style command that can be conditionally applied to windows. Nice idea though, even though it is wrong. :slight_smile:

Then I suppose you’re after something along the lines of the following:

edulinux.homeunix.org/fvwm/fvwmc … q.html#WC3

adapted to suit your needs. Note that fvwm-themes also has something similar, when it switches didderent theme components. Of course, yours requires something a little more complex. I haven’t really thought about it, but you might find the following a start:

DestroyFunc FuncBaseDecor
AddToFunc   FuncBaseDecor
+ I DestroyDecor BaseDecor$0$1
+ I AddToDecor   BaseDecor$0$1
+ I + BorderStyle Simple
+ I + TitleStyle -- Raised
+ I + TitleStyle Height 18
+ I + ButtonStyle Reset
+ I + ButtonStyle All -- Raised
+ I + $2

DestroyModuleConfig FvwmEvent-ChangeDecor: *
*FvwmEvent-ChangeDecor: Cmd Function
#*FvwmEvent-ChangeDecor: configure_window Funcsf
*FvwmEvent-ChangeDecor: focus_change Funcsf
*FvwmEvent-ChangeDecor: add_window Funcsf

DestroyFunc Funcsf
AddToFunc   Funcsf
+ I ThisWindow (State 1) FuncConstructDecor State 1 "ButtonStyle 1         Vector 4 50x25@1 75x75@0 25x75@0 50x25@1"

DestroyFunc FuncConstructDecor
AddToFunc   FuncConstructDecor
+ I FuncBaseDecor $0 $1 $2
+ I ChangeDecor BaseDecor$0$1

KillModule FvwmEvent FvwmEvent-ChangeDecor
Module FvwmEvent FvwmEvent-ChangeDecor

I certainly haven’t tested it – I apologise for not doing so, but it’s almost 2am, and I need some sleep. :slight_smile: Not my usual answer to you, flatline, alas.

And you may find the scripting/automation idea too complex, in which case, define your decors manually. :slight_smile:

– Thomas Adam

Nice enough that it might be considered in a future release? I haven’t looked at that part of the code yet, but I can imagine that buttonstyles are stored at the decor level and so some struct changes would be required to get window specific buttonstyles.

It’s now officially on my list of things to look for in the code.

Valuable nonetheless. It hadn’t occured to me that I could dynamically define decors (don’t know why…it should have been obvious to me).

Now that I know it can be done, I’ll figure something out. If I can’t get it to work in the config file, I can always PipeRead to a bash or python script (I’m always looking for good excuses to use python).

The tricky part will be knowing when a dynamic decor is no longer used and can be safely destroyed. It would probably be sufficient to use the Schedule command (when I create the decor, schedule a test for the winow ID foo seconds in the future. If the window no longer exists, destroy the decor, otherwise schedule another test…).

Thanks again for you help.

–Flatline

I wouldn’t bother. The whole decor code routine is going to be scrapped at some point.

Umm, I’d just do it based on a window’s state, personally. You’re introducing several issues in trying to do it that way – especially if a decor is assigned to that window in the interim.

– Thomas Adam