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.
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 Thanks!
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.) :P
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.
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: