Shadow a specific region of an X server
|Reported by:||mad_ady||Owned by:||Antoine Martin|
I would like to be able to use xpra to access windows which have been already opened inside a X11 session. I know this is not possible, but Xpra can use the shadow feature to "copy" the whole X11 session. I would like to propose adding a feature to copy just a specific region of the X11 session (that presumably contains the window you want). Here's how I envision it to work:
- Start/use a bunch of windows inside a regular X11 session (e.g. at work). For now let's assume I am interested in shadowing Thunderbird and a terminal that has a specific string in the title bar (adrianp@procyon).
- Prepare to start xpra shadowing client on a different system (e.g. at home). However, I don't want to shadow the complete X11 session, because my work PC has two monitors with about 3000x1200 resolution that won't fit on a small laptop display. At this step we need to use wmctrl to extract the list of windows and their current geometry from the main X11 session:
adrianp@frost:~$ wmctrl -l -G | egrep "Thunder|procyon" 0x050000a0 0 0 48 1680 1026 frost To ME - Local Folders - Mozilla Thunderbird on frost 0x04e0af60 0 993 589 657 410 frost adrianp@procyon (192.168.1.12) - byobu
The first hex string is a window id, next is a weight (which can be negative for panels or the desktop), next is the x coordinate of the left-most pixel, next is the y coordinate of the top-most pixel (of the window, it doesn't include the window manager's titlebar), next comes the x length followed by the y length and the window title.
Xpra should add a new "geometry" option to its shadow feature that should be compatible in format with wmctrl - something like:
0,0,48,1680,1026 or just 0,48,1680,1026 if you chose to ignore the weight.
- Start xpra with something like this:
xpra shadow :0 --geometry 0,48,1680,1026
Ideally, if it's possible, it should allow the user to specify multiple geometry parameters to "extract" multiple independent screen regions. Otherwise the user could call xpra shadow multiple times.
Possible usage problems and solutions:
Q: What if the window changes position/size serverside while shadowing?
A: It's not xpra's job to track window changes
Q: What if the window is partially obscured by other windows?
A: wmctrl can take care of that and bring the window in the foreground
wmctrl -a <name>
Q: What if the window is still too large to fit comfortably the destination screen?
A: wmctrl can resize (and reposition) a window:
wmctrl -r <name> -e 0,0,48,1600,600
Q: Too bad I can't see the title bar/window controls
A: You can instruct xpra to copy a bunch of pixels more on the y axis (in my example the Thunderbird window is maximized on my desktop and has x,y coordinates 0,48. The 48 means that the titlebar takes up 48 pixels, so you can instruct xpra to copy from 0,0 instead and add 48 to your y measurement so that the window isn't cut off).
Q: Wait! wmctrl complains it can't connect to the X server when run from ssh!
A: You can always tell it which X server to interrogate:
DISPLAY=:0 wmctrl -l -G DISPLAY=192.168.12.22:3 wmctrl -l -G