yshui / picom-xrdesktop-companion

picom's companion program to bring your desktop to XR
21 stars 4 forks source link

picom-xrdesktop-companion

What is this

picom-xrdesktop-companion is a program that runs alongside picom, that mirrors your desktop windows to the VR/XR space.

To see what it would look like, you can watch this video by the developers of xrdesktop:

xrdesktop

There are also a bunch of example videos in this article.

How to use

First, you need to build this program

To use this program, you must have picom installed on your system.

First, make sure picom is running with dbus support enabled:

picom --dbus

Then, make sure SteamVR is running. And after that, start this program. You should see your windows mirrored.

Installation

Dependencies

(xrdesktop comes included in this repository, no need to install it).

Building

Simply run

cargo build --release

The resulting binary will be at ./target/release/app

Limitations

Bugs

Both this program and xrdesktop are in their early stages, so bugs and crashes can often happen. Feel free to open an issue here for problems you have encountered.

Window stacking

When you move your pointer over a window in VR, the corresponding window must to raised to the top of the window stack to make sure it is not obscured and is able to receive input. This program makes best effort attempt to do that, but it might not work well with all window managers or programs.

It also changes how your windows are stacked and doesn't attempt to restore it after you stop window mirroring.

Scene mode

Scene mode has not been tested. Please change default mode to "overlay" in xrdesktop settings.

Questions

Why picom?

Believe it or not, this has nothing to do with picom being a compositor. Let me explain.

X has a very low level concept of "windows" and is not at all what we users would consider "windows". A set of conventions have developed over the decades to establish what we would consider as a window. These conventions are used by window managers to establish their internal knowledge of windows. Unfortunately this knowledge is only internal to the window manager, and if you want to, say, know what windows are open at the moment, you need to replicate at least part of what the window manager is doing.

And believe me, what it does is arcane. Besides that, your program also has to interact with the window manager and interpret its manipulations of windows correctly. The whole thing is really complex and complicated and you really don't want to do it. That's why xrdesktop developers chose to only integrate xrdesktop as part of the window manager (i.e. as a plugin, or by patching the window manager), instead of making it standalone. (BTW, please stop using X and switch to a wayland compositor if you can).

OTOH, picom, as a compositor, has already implemented the arcane window managing functionality just to function as a compositor. And fortunately, it also has a dbus interface that exposes its knowledge regarding windows. And that's what this program uses to mirror your windows. That's the only part of picom this program needs, so you don't even have to run picom as your compositor. If you want, you can run:

picom --dbus --backend dummy

this way picom will provide the window information but not run as a compositor.

Acknowledgements

Thanks to the good people at Collabora that made xrdesktop. They also make a ton of interesting stuff and you have probably already heard of them if you are into Linux gaming, so check them out.