Trying to make a Exposé F11 function

Well, I think this one could prove to be a little tricky one.
So here’s the idea:
Function would be a replica of OSX’s press of F11, which moves all the windows away from covering up the desktop. Sounds simple?
It isn’t.
The way it moves the windows, is based on where the window is located; if the window is mostly (as in the majority of the windows size is located) in the lower right hand screen area, it is moved to the southeast corner so that a small amount of the window remains visible. I’m not actually even sure how complicated it is on OSX, but it would be enough if the windows would be moved on a Virtual Plane (err… “screen”) divided to an 2x2 area, to the nearest corner (this isn’t the case on the original OSX window move logic, as windows move to every direction)

Any ideas, suggestions, code, etc. greatly appreciated. :slight_smile:

You need to elaborate further on this — I don’t quite see what you mean.

– Thomas Adam

OK, sorry for being too vague.
So, basically, I’d need to split the visual screen (the screen I see before me) into 4 parts (2x2), like this:

.--------------------------------------.
|                  |                   |
|                  |                   |
|                  |                   |
|                  |                   |
|------------------|-------------------|
|                  |                   |
|                  |                   |
|                  |                   |
|                  |                   |
`--------------------------------------'

Then, there are windows on that screen. Here, there is one window:

.--------------------------------------.
|                  |                   |
|                  |                   |
|                  |                   |
|                .---------------.     |
|----------------|               |-----|
|                |               |     |
|                |               |     |
|                `---------------'     |
|                  |                   |
`--------------------------------------'

This function would affect all the windows on the visible screen.
Now, on the above example, the majority of the one window on screen is located mostly on the bottom right part of the screen, and hence it would need to be moved to the bottom right corner when pressing F11, so that a small amount of the window remains visible after the move operation.
If the majority of the window would have been in the top left, then it would need to be moved to the top left corner, etc.

I’m a little clueless about what needs to be done, so I would greatly appreciate any help :slight_smile: Thanks!

PipeRead with $[w.width]/2 $[w.height]/2 calculations in some external script?

No – not quite. The problem here is that the calculations will have to be done before the window(s) are moved. During a move operation pretty much everything bar the XServer is grabbed. This makes calculations on-the-fly impossible.

If you all you want to do is to quartile the screen such that windows are supposed to gravitate to a particular area then you want (in part FvwmRearrange). If you want to determine in which area the most windows are given a starting position, then…

thinks.

One of the lesser (and ultimately more powerful) commands FVWM has is ScanForWindow – you could use this given a starting point to hit all windows in a given direction and count them…

(I’m not doing this for you — the theory is left as an exercise to the reader to work out how to do that.) :stuck_out_tongue:

– Thomas Adam

Thanks for the tip Thomas, I’ll try that next. In the meantime, I managed to pull together something with PipeRead, but it’s a little bogus.

DestroyFunc FvwmExposeFunc
AddToFunc FvwmExposeFunc
+ I PipeRead '[ $((($[w.y]+$[w.height])/2)) -ge $(($[vp.height]/2)) ] && DIR=S || DIR=N; \
    [ $((($[w.x]+$[w.width])/2)) -ge $(($[vp.width]/2)) ] && DIR=${DIR}E || DIR=${DIR}W; \
    case $DIR in \
    SE) echo AnimatedMove $(($[vp.width]-10))p $(($[vp.height]-10))p ;; \
    NE) echo AnimatedMove $(($[vp.width]-10))p $((0-$[w.height]+10))p ;; \
    SW) echo AnimatedMove $((0-$[w.width]+10))p $(($[vp.height]-10))p ;; \
    NW) echo AnimatedMove $((0-$[w.width]+10))p $((0-$[w.height]+10))p ;; \
    esac'

Well I have implement an own version for that,look:
Before :

After pressing expose key:

And this is the code for it:

SetEnv fvwm_scripts_path $[HOME]/theme-fvwm/scripts
Key E A 	M   All (AcceptsFocus,CurrentPage,!Iconic,!Shaded) Expose

DestroyFunc Expose
AddToFunc Expose 
+ I PipeRead 'echo "`$[fvwm_scripts_path]/expose.pl $[w.x] $[w.y] $[w.height] $[w.width]`"';

and this is expose.pl:

#! /usr/bin/perl
## Expose script 
## Usage: expose $[w.x] $[w.y] $[w.height] $[w.width]
## Description: Implementation of the expose for fvwm 
##PLEASE ADJUST THIS TO YOUR SCREENSIZE
$screeny=768;
$screenx=1024;
###
$x=$ARGV[0];
$y=$ARGV[1];
$height=$ARGV[2];
$width=$ARGV[3];
##Total size of the window 
$tot=$width*$height;
## Calculate area in the Top left
if ((($screeny/2)-$y) >0 && (($screenx/2)-$x)>0) 
	{
 	$topleft=((($screeny/2)-$y)*(($screenx/2)-$x))/$tot;
	}
else 
	{
 	$topleft=0;
	}

## Top right
if ((($screeny/2)-$y) >0 && (($x+$width)-$screenx/2)>0) 
	{
 	$topright=(($screeny/2)-$y)*(($x+$width)-$screenx/2)/$tot;
	}
else 
	{
 	$topright =0;
	}
## Bottom left
if ((($y+$height)-($screeny/2))>0 &&(($screenx/2)-$x) > 0)
	{
 	$botleft=((($y+$height)-($screeny/2))*(($screenx/2)-$x))/$tot;
 	}
else 
	{
	$botleft=0;
	}
## Bottom Right
if ((($y+$height)-($screeny/2))>0 && (($x+$width)-$screenx/2)>0)
	{
	$botright=((($y+$height)-($screeny/2))*(($x+$width)-$screenx/2))/$tot;
	}
else 
	{
	$botright=0;
	}
##After calculating now start positioning
# Case 1: Window mostly in the topleft
# Case 2: Window mostly in the topright
# ...
if ($topleft>0.8)
	{
	$y=-($screeny-150);
	$x=-($screenx-150);
	}
elsif ($topright>0.8)
	{
	$y=-($screeny-150);
	$x=$screenx-150;
	}
elsif ($botleft>0.8)
	{
	$y=$screeny-150;
	$x=-($screenx-150);
	}
elsif ($botright>0.8)
	{
	$y=$screeny-150;
	$x=$screenx-150;
	}
elsif (($topleft+$topright)>0.8)
	{
	$y=-($screeny-100);
	$x=($screenx-$width)/2;
	}

elsif (($botleft+$botright)>0.8)
	{
	$y=$screeny-100;
	$x=($screenx-$width)/2;
	}
elsif (($topleft+$botleft)>0.8)
	{
	$x=-($screenx-100);
	$y=($screeny-$height)/2;
	}
elsif (($topright+$botright)>0.8)
	{
	$x=$screenx-100;
	$y=($screeny-$height)/2;
	}
else 
	{
	$y=$screeny-100;
	$x=($screenx-$width)/2;
	}
printf "AnimatedMove %sp %sp",$x,$y;  

Well that code works for me besides it’s not really good and not really fvwm like =)
Known problems:

  • sometimes windows positioned in the middle area by the first press of the expose key, will be repositioned to a corner if you press expose a second time

Not bad – but you ought to look at FvwmPerl (if you really think going down this route is the “best” way – it would reduce your code by about a third, and certainly reduce a lot of the variable inferences you’re making.

– Thomas Adam

Yes i know …
That’s why i wrote it’s not very fvwm like …
I might give it a try =)

Taviso was working on something similar iirc using shellscript as is his wont :wink: Might be worth checking out if it’s still in his config.

hi i have worked a bit on this …
i have just one question:
i have written an functions which moves the windows like expose does
and another one which moves the windows back. Now i want that

DestroyFunc ExposeFunc
AddToFunc ExposeFunc
+I All (AcceptsFocus,CurrentPage,!Iconic,!Shaded) Expose
## Here something is missing ...
+I All (AcceptsFocus,CurrentPage,!Iconic,!Shaded) DeExpose	 

to move first all windows then wait for the user to choose an window (which will be focused ) and afterwards move all windows back.
How can i do this ??

Do you mean the window that is already focused? I have no idea what it is you’re asking for, but I suspect based on a guess as to your meaning, you might want:

NoWindow Pick some_command

– Thomas Adam

Thanks this works :smiley:

And where to use this command?
Sorry, i’m a newbie

greetings scientific

That depends. When would you like it to happen?

– Thomas Adam