Discussion:
FVWM: ToggleTitle and Maximize
Nikos Leonardos
2014-09-05 09:37:41 UTC
Permalink
Dear all--

I'm trying to define a function (to be triggered by a
window-menu) that (1) toggles the Title style and (2)
maximizes the window vertically (restoring the total height
of the window would be even better). Here is my attempt.

DestroyFunc FuncToggleTitle
AddToFunc FuncToggleTitle
+ I PipeRead \
'if xprop -id $[w.id]|grep WM_FRAME|grep -q 19; \
then echo "WindowStyle !Title"; \
else echo "WindowStyle Title"; fi'
+ I Maximize True 0 100

The 19 is because I have borderwidth 3 and title-height 16. Is
there a better way to determine if the window is titled or
not?

My main problem however is that the "Maximize True 0 100"
command does not work as I want. In particular, it feels like
it uses the height before the "WindowStyle (!)Title" affects
it.

Furthermore, FuncToggleTitle seems to interfere with the
Move command, in case I also want to move the window
afterwards.

If needed, I can provide more details. Your help would
appreciated. Thank you.
--Nikos

PS Using fvwm 2.6.5
Thomas Adam
2014-09-05 10:53:32 UTC
Permalink
Post by Nikos Leonardos
Dear all--
I'm trying to define a function (to be triggered by a
window-menu) that (1) toggles the Title style and (2)
maximizes the window vertically (restoring the total height
of the window would be even better). Here is my attempt.
DestroyFunc FuncToggleTitle
AddToFunc FuncToggleTitle
+ I PipeRead \
'if xprop -id $[w.id]|grep WM_FRAME|grep -q 19; \
then echo "WindowStyle !Title"; \
else echo "WindowStyle Title"; fi'
+ I Maximize True 0 100
The 19 is because I have borderwidth 3 and title-height 16. Is
there a better way to determine if the window is titled or
not?
There is no condition for HasTitle, although it looks like I had a patch for
this:

http://xteddy.org/fvwm/patches/hastitle_hasborders.patch
Post by Nikos Leonardos
My main problem however is that the "Maximize True 0 100"
command does not work as I want. In particular, it feels like
it uses the height before the "WindowStyle (!)Title" affects
it.
It will do, because those won't be applied necessarily in the order you
think they will. What I would do is to use State instead to achieve this.

DestroyFunc ToggleTitleMaximize
AddToFunc ToggleTitleMaximize
+ I ThisWindow (State 0) RestoreWindow
+ I TestRc (NoMatch) ThisWindow (!State 0) ApplyWindow

DestroyFunc RestoreWindow
AddToFunc RestoreWindow
+ I DestroyWindowStyle
+ I Maximize

DestroyFunc ApplyWindow
AddToFunc ApplyWindow
+ I WindowStyle State 0, !Title
+ I Maximize 0 100

So you can then bind "ToggleTitleMaximize" to something.

-- Thomas Adam
Nikos Leonardos
2014-09-05 11:03:16 UTC
Permalink
Thank you Thomas for the quick response.
Post by Thomas Adam
Post by Nikos Leonardos
Dear all--
I'm trying to define a function (to be triggered by a
window-menu) that (1) toggles the Title style and (2)
maximizes the window vertically (restoring the total height
of the window would be even better). Here is my attempt.
DestroyFunc FuncToggleTitle
AddToFunc FuncToggleTitle
+ I PipeRead \
'if xprop -id $[w.id]|grep WM_FRAME|grep -q 19; \
then echo "WindowStyle !Title"; \
else echo "WindowStyle Title"; fi'
+ I Maximize True 0 100
The 19 is because I have borderwidth 3 and title-height 16. Is
there a better way to determine if the window is titled or
not?
There is no condition for HasTitle, although it looks like I had a patch for
http://xteddy.org/fvwm/patches/hastitle_hasborders.patch
Post by Nikos Leonardos
My main problem however is that the "Maximize True 0 100"
command does not work as I want. In particular, it feels like
it uses the height before the "WindowStyle (!)Title" affects
it.
It will do, because those won't be applied necessarily in the order you
think they will. What I would do is to use State instead to achieve this.
Could you explain why they are not applied in this order? In
particular, why should they be applied in order for your
ApplyWindow function below, but not for my FuncToggleTitle
function above?

Thank you,
--Nikos
Post by Thomas Adam
DestroyFunc ToggleTitleMaximize
AddToFunc ToggleTitleMaximize
+ I ThisWindow (State 0) RestoreWindow
+ I TestRc (NoMatch) ThisWindow (!State 0) ApplyWindow
DestroyFunc RestoreWindow
AddToFunc RestoreWindow
+ I DestroyWindowStyle
+ I Maximize
DestroyFunc ApplyWindow
AddToFunc ApplyWindow
+ I WindowStyle State 0, !Title
+ I Maximize 0 100
So you can then bind "ToggleTitleMaximize" to something.
-- Thomas Adam
Dominik Vogt
2014-09-05 17:28:56 UTC
Permalink
Post by Nikos Leonardos
Thank you Thomas for the quick response.
Post by Thomas Adam
It will do, because those won't be applied necessarily in the order you
think they will. What I would do is to use State instead to achieve this.
Could you explain why they are not applied in this order? In
particular, why should they be applied in order for your
ApplyWindow function below, but not for my FuncToggleTitle
function above?
Fvwm is lazy about applying styles to windows to reduce the number
of useless updates. For example, if you read in a file that
defines twenty new styles, you wouldn't want the windows to be
updated twenty times. So, fvwm waits until no more commands are
coming in and then updates all windows that need updates at the
same time.

The one situation where this is confusing is in complex functions.
Styles will only be applied when the outermost function has
completed. In your case, use the UpdateStyles command to apply
Post by Nikos Leonardos
To force that all pending changes are applied immediately, use
the UpdateStyles, Refresh or RefreshWindow commands.
(I'm not sure that the refresh commands would really do that.)

Ciao

Dominik ^_^ ^_^
--
Dominik Vogt
Nikos Leonardos
2014-09-05 17:18:08 UTC
Permalink
Post by Dominik Vogt
Post by Nikos Leonardos
Thank you Thomas for the quick response.
Post by Thomas Adam
It will do, because those won't be applied necessarily in the order you
think they will. What I would do is to use State instead to achieve this.
Could you explain why they are not applied in this order? In
particular, why should they be applied in order for your
ApplyWindow function below, but not for my FuncToggleTitle
function above?
Fvwm is lazy about applying styles to windows to reduce the number
of useless updates. For example, if you read in a file that
defines twenty new styles, you wouldn't want the windows to be
updated twenty times. So, fvwm waits until no more commands are
coming in and then updates all windows that need updates at the
same time.
Thank you Diminik for the explanation. I understand now.
Post by Dominik Vogt
The one situation where this is confusing is in complex functions.
Styles will only be applied when the outermost function has
completed. In your case, use the UpdateStyles command to apply
Post by Nikos Leonardos
To force that all pending changes are applied immediately, use
the UpdateStyles, Refresh or RefreshWindow commands.
DestroyWindowStyle in the beginning and UpdateStyles before
maximizing did the trick for me! I ended up with the
following:


DestroyFunc ToggleTitleMaximize
AddToFunc ToggleTitleMaximize
+ I DestroyWindowStyle
+ I PipeRead \
'if xprop -id $[w.id]|grep WM_FRAME|grep -q 19; \
then echo "WindowStyle !Title"; \
else echo "WindowStyle Title"; fi'
+ I UpdateStyles
+ I Maximize True 0 100


Thomas and Dominik, thank you.
--Nikos
Post by Dominik Vogt
(I'm not sure that the refresh commands would really do that.)
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
Loading...