6

I have multiple displays open on a central server. Is it possible to "move" a X-window application that is running on a particular DISPLAY to a different DISPLAY? How can this be done?

I'm using xpra with multiple remote displays.

stdcerr
  • 2,079

1 Answers1

1

It isn’t possible to move a running X window application to a different display, as determined by the DISPLAY variable, for two reasons.

The first is that it’s difficult to change a running process’ environment, and impossible to do it reliably and in such a way that the change is taken into account.

The second is that the DISPLAY variable is only an input, and typically it’s only considered at application startup. An X application calls XOpenDisplay early in its startup, directly or indirectly, and that (or rather, XTOpenDisplay) is what takes DISPLAY into account (if necessary — the X server to use can be specified in other ways). XOpenDisplay returns a pointer to an opaque Display structure which represents the connection to the X server, and that’s all that’s used to talk to the X server thereafter. Changing the value of DISPLAY after this won’t have any effect; the application would somehow have to realise that the value has changed, close its connection to the X server, and open a new one.

Both points taken together means that it’s very difficult even to write an application which can change its display (because it’s designed to do so), let alone change the display when an application doesn’t expect it to.

Stephen Kitt
  • 434,908
  • what a pity. it would be a splendid feature ! – U.V. Nov 09 '20 at 17:37
  • Does it mean that the Xserver has to have the ability to transfer his control structures to another Xserver? API redirection is daily business these days I think. probably just lacking the drive. – U.V. Jul 06 '21 at 20:30
  • @U.V. API redirection would be the least of your problems here ;-). But that’s the magic of free software, if you have the drive you can give it a shot! – Stephen Kitt Jul 06 '21 at 20:41
  • With old applications, it should be possible with a proxy, as the protocol is hardware agnostic, parameters including screen modes can change during runtime, and applications are expected to handle this when notified. With modern applications that use X mostly to negotiate a bunch of shared memory buffers to talk to the GPU directly, not so much. – Simon Richter Sep 25 '21 at 03:04