Hide/view any window in a "kuaky" way

I’ve written a quite simple and smart function that converts any window you’re working on into a “kuaky” window (I mean, as “kuake style” terminals) so you can hide and unhide it in a pretty way with just a keystroke.

W.T.F.??? :-S

Well, I’ll explain why I needed this and what it exactly does:

I use to work with LaTeX, so I usually need two windows opened, the editor and the previewer. I want both of them maximized. While I have the previewer opened, I hit F10 and Fvwm hides it. Now I start working on my document and when I compile and want to see the results I hit again F10 so the previewer unhides. Once I’ve seen what I wanted, I hit F10, so the previewer hides and I can continue writing on the editor.

This can be usefull in many other cases like with a text editor and a drawing program or a web browser and an IM client… or just for hiding Pornotube and showing emacs when your boss looks!!! (maybe setting resolution to page in iconman should help) XD

Hope you understood and find this usefull.

Here’s the code, based on a kuake style terminal found somewhere (not sure, but think it was from 6thPink):

#  -1 means hidden
SetEnv kuaky_pos        1

DestroyFunc toggle_kuaky
AddToFunc toggle_kuaky
+ I Test (EnvMatch kuaky_pos 1) SetEnv WINDOW_X $[w.x]
+ I Test (EnvMatch kuaky_pos 1) SetEnv WINDOW_Y $[w.y]
+ I Test (EnvMatch kuaky_pos 1) SetEnv KUAKY_WINDOW $[w.name]
+ I Test (EnvMatch kuaky_pos -1) All ("$[KUAKY_WINDOW]") Raise
+ I Test (EnvMatch kuaky_pos -1) All ("$[KUAKY_WINDOW]") AnimatedMove $[WINDOW_X]p $[WINDOW_Y]p
+ I Test (EnvMatch kuaky_pos -1) All ("$[KUAKY_WINDOW]") Focus
# Maybe need more than 850 for users with a big resolution. You can play with this values for hiding it to another direction than up.
+ I Test (EnvMatch kuaky_pos 1) All ("$[KUAKY_WINDOW]") AnimatedMove $[CURSOR_X]p -850p
+ I Test (EnvMatch kuaky_pos 1) Prev Focus
+ I Piperead 'echo SetEnv kuaky_pos $((${kuaky_pos} * -1))'

Key     F10      A   A   toggle_kuaky

Ugh! Again, so much unnecessary tainting via useless environment variables (see:
viewtopic.php?p=10122#p10122)

You can factor this down to a few lines, and you certainly don’t need to use “KUAKY_WINDOW”.

– Thomas Adam

Moving windows is always a slow thing.

Now what I use for my kuake is just this:

DestroyFunc toggle_kuake
AddToFunc toggle_kuake
+ I All (!Overlapped, FvwmKuakeTerm) WindowShade W
+ I All (FvwmKuakeTerm) Raise
+ I All (FvwmKuakeTerm) Focus

You can shade to N is you like the usual kuake position in the top of the screen. Then just open that window on the required location and start using it. If the window is borderless and tittleless, you will not see the shaded window.

It’s enought fast in my home laptop (P-III, 600MHz) and for my older laptop at work (P-MMX, 200MHz) I just remove the animation for moving. Probably shading them should be faster, but this is fast enought for my needs.

But I don’t want All my windows tittleless and borderless… And want to be able to hide anyone each time.

I see from that topic how to use the tests so I don’t need kuaky_pos:

+ I TestRc (Match) Next (some_window) Raise
+ I TestRc (Match) Break
+ I TestRc (NoMatch) Next (some_window) AnimatedMove -5000 -5000

About KUAKY_WINDOW…
How? I need to say who is “some_window” and it can be now XPDF but next time I’ll want it to be Emacs, for example…
I’m sure it’s possible not to use that variable if you say it, but I can’t guess how should the function know which window is the one I have hidden and want to unhide later, after working with some other ones for a while.
I could probably look for a window “!CurrentPage, !Visible”, but in fact, now I have defined three functions with three keystrokes for hiding/unhiding three different windows Left, Up and Right, so I need a way for remembering which window was associated with wich keystroke.
I do that with three variables KUAKY_LEFT_WINDOW, KUAKY_UP_WINDOW and KUAKY_RIGHT_WINDOW.

[color=#40FF00]Thank you both for the tips[/color], if there’s something I love from using FVWM is that I’m learning day by day and many of this things are usefull not only for FVWM but for programming in general…
And that’s because all of you in this forums with a special mention to Thomasadam and his neverending patience and dedication.

It all depends, of course, each one’s hardware and needs are different. Applications also matter.

On a sempron +3000 y can clearly see the whole wm lag when you move a kuake and there is a seamonkey, firefox or sylpheed session opened in the same page, just to name a few. The cpu wasted is horrendous. And yes, I know that it is not the wm, but tookits of the applications. Still, if I don’t move the windows there is no problem. Well, AnimatedMove is not too fast, and that is a fvwm thing indeed. Regular Move is ok.

I am not feeling smart today, so I will only comment one thing. I refactored a similar function time ago using States instead of the kuaky_pos thing. Window states are meaningless to fvwm, but they can be used as flags to indicate whether a window has a given characteristic or not. You can set “State 0 True” on the kuake window to indicate it is hidden, or do “State 0 False” to show it is not hidden. The you can Test for that condition on your function. I can search for the “improved” kuake thing. I suppose you could use additional states to know if a window is kuaked to N, W, E or S. I will try to search for the example function that I wrote some time ago later in case you want to take a look, right now I can’t.

Regards :slight_smile:

But it is the WM since it has to filter out ConfigureNotify requests for FVWM.

This is how you should have done it from the start, and is the “correct” way.

Eh? They certainly are meaningful to FVWM since it’s FVWM which defines the concept in the first place. What the man page says (which is where I assume you’re getting the confusion from) is that they’re limited only to conditional states. The wording is completely misleading.

– Thomas Adam

Thanks for the clarifications. That was just another of my linguistic inaccuracies.

I meant that, let’s say, State 0 has no concrete meaning for fvwm. It is just like a label that you use to -abstractly- define a given quality for a window, but that is just an abstraction you make, and not something that has a meaning for fvwm. I meant that. I did not remember the words on the man page, but looking at them it seems funny to me how similar those words are to these I used here :stuck_out_tongue:

:slight_smile: