Possible to move a window from one X screen to another on same host

x11xorg

I'm running XFCE 4.12 with 3 monitors setup into two X screens and two video cards on the same computer. Two of the monitors form a single X screen using nvidia twinview functionality, which is Screen0 on Device0 in the Xorg config. The 3rd monitor is for the second screen which is Screen1 on Device1 in the Xorg config. I can drag windows fine between the monitors on Screen0. I can also move my mouse freely between Screen0 and Screen1 and even the clipboard data is carried between the two X screens ok.

Both of these X screens act as independent desktops which have their own set of viewports. I like it this way and its useful for making one side "stick" automatically. However if I start a program on one X screen, I can't move it to the other X screen by simply dragging it. If I want to run that program on the other screen I have to restart it on that screen.

My question is if there is way to move the program while its running to the other screen using some command or other function of X windows. Thanks.

Update: I'm going to start a bounty on this question but I've been wondering about this for a while. To earn the bounty, you have to provide some citation for proof.

Best Answer

You cannot move an X application started directly with the X server the application is ultimately displayed on, this is due to an X client being "tied to the X server (X display) it was started on for its lifetime"[1] This is most likely to do with metadata that the X server holds about a client's windows that cannot be easily transferred between X servers.

The same is true of separately configured screens (when not using extensions such as Xinerama or Twinview) for programs that don't have multi-screen support explicitly written in - "With this configuration it is not possible to move windows between screens, apart from a few special programs like GIMP and Emacs which have multi-screen support."[2]

In theory if an application was designed to cope with an X server context switch, it could be provided with the new display/screen number, save the state of it's windows, connect to the new X server/screen and resurrect it's windows, but few applications would be designed in this way and would necessarily involve either a lot of boilerplate or the inclusion of a library that would facilitate this somehow.

The best option for you is probably to use other applications that can act as a proxy between an X client and the displaying X server in a similar way that GNU screen can be used for console applications and the terminal. Xmove and Xpra [3&4] seem to be the most widely used implementations for doing this. The caveat of using those is that the applications that you start have to register with Xmove or Xpra as their X server in order to be able to context switch between different display servers.

Finally there is another question, on SuperUser, that is asking a similar question for a slightly different purpose (reconnect to X after X crash, rather than deliberate disconnect/reconnect of client)[5]

Related Question