October 7 2009
Probably the most lacking feature in most multi-screen setups is the ability to move a window from one screen to another with a keyboard shortcut. I do this to bring the window I'm currently working on into my centre monitor so its directly in front of me. There are 2 ways to go about this. The first is moving a window to a specific display and the second is to move (shift) the window to the left or right display (which would just be back and forth in a dual monitor setup).
For the first case you could define the following function:
# This function will move a window to the X screen provided in the # first argument. If the window is in the maximized it will be taken # out of the maximized state before moving. If we don't do this it # will be moved back to the original screen when the maximized state # is toggled. # # If you do not want the pointer to be moved to the windows new # location then comment out the line containing WarpToWindow. DestroyFunc MoveWindowToScreen AddToFunc MoveWindowToScreen \+ I Current (Maximized) Maximize \+ I SetEnv PWX $[pointer.wx] \+ I Setenv PWY $[pointer.wy] \+ I MoveToScreen $ \+ I WindowId $[w.id] WarpToWindow $[PWX]p $[PWY]p
And then add the following to your window operations menu:
\+ "&1 Move to Screen 1" MoveWindowToScreen 2 \+ "&2 Move to Screen 2" MoveWindowToScreen 0 \+ "&3 Move to Screen 3" MoveWindowToScreen 1
Note that the argument you provide to the MoveWindowToScreen function takes the X display number which may not directly map to the order of the screens on your desk.
The second method is to move the screen to the left or the right. Or in the case of a dual monitor setup you could just continually move right to have the window flip/flop between your 2 screens.
First download the following file and save it to ~/.fvwm/ShiftToScreen.py: ShiftToScreen.py
You will also need to update variables screenWidth and screens in ShiftToScreen.py as they are currently setup for my configuration of 3 screens with a width of 1920 pixels each.
Then define the following function:
# This function will move a window to the left or right screen # depending on the first argument which should be on of "left" or # "right". It depends on the auxiliary python script # ShiftToScreen.py. DestroyFunc ShiftToScreen AddToFunc ShiftToScreen \+ I Current (Maximized) Maximize \+ I SetEnv PWX $[pointer.wx] \+ I Setenv PWY $[pointer.wy] \+ I PipeRead "python $./ShiftToScreen.py $ $[w.x]" \+ I WindowId $[w.id] WarpToWindow $[PWX]p $[PWY]p
You could then add the following to your windows operations menu:
\+ "&Left Screen" ShiftToScreen left \+ "&Right Screen" ShiftToScreen right
or define some keyboard shortcuts. For example I have bound Shift-Alt-Left and Shift-Alt-Right to shift the window to the left or right screen:
Key Left WTSF12468 SM ShiftToScreen left Key Right WTSF12468 SM ShiftToScreen right
If you are only working with 2 screens you will only need to define one shortcut to get flip/flop like behaviour as shifting left beyond the leftmost screen will wrap the window around to the right most screen.