Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow a specific region of an X server #1009

Closed
totaam opened this issue Oct 22, 2015 · 3 comments
Closed

Shadow a specific region of an X server #1009

totaam opened this issue Oct 22, 2015 · 3 comments
Labels
Milestone

Comments

@totaam
Copy link
Collaborator

totaam commented Oct 22, 2015

Issue migrated from trac ticket # 1009

component: server | priority: minor | keywords: shadow window

2015-10-22 10:16:29: mad_ady created the issue


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:

  1. 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).

  2. 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.
  1. 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
@totaam
Copy link
Collaborator Author

totaam commented Oct 22, 2015

This should not be too hard, we just need to override:

  • get_dimensions in [/browser/xpra/trunk/src/xpra/server/shadow/root_window_model.py]
  • and apply the same offset in get_image, also tweak the size hints value
  • [/browser/xpra/trunk/src/xpra/server/shadow/shadow_server_base.py]:
    • refresh and _process_map_window / _process_configure_window need to get the area to refresh (the offset) from the window model instead of just using the window size (relatively easy)
    • get_root_window_size needs to be overriden... (maybe belongs in the model..)
  • maybe expose this option using the [/browser/xpra/trunk/src/xpra/server/shadow/shadow_dbus_server.py] (and just trigger a window resize when the region changes)

Misc:

  • this would go in the server
  • will try for the next release

@totaam
Copy link
Collaborator Author

totaam commented Oct 28, 2018

2018-10-28 09:02:07: mad_ady commented


I have another use case that could benefit from shadowing with custom offsets. Assume a x11 server running with a virtual display set with twice the X resolution than the screen (half the screen is visible). You could shadow only the remaining half to have it displayed on the other screen to gain a "virtual" dual screen display over network instead of locally (could help 2 systems with only one video output).
A huge benefit would be performance-wise. For example, if the left side runs natively, while the right side shadows half the screen over network, you could play videos on the left without having to encode/transmit anything on the xpra connection, giving the impression of a dual-screen setup.
Needs testing/tweaking, of course, even if shadowing offset would work.

@totaam totaam added the shadow label Jan 23, 2021
@totaam totaam added this to the 4.2 milestone Jan 23, 2021
@totaam
Copy link
Collaborator Author

totaam commented Nov 30, 2021

Done: #3320

@totaam totaam closed this as completed Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant