How to rotate window in X11

windowwindow-managerx11xmonad

Is it possible to rotate a single window in X11? I tried to use Xephyr but I run into bug 100458.

I use XMonad as WM if that helps.

Best Answer

I've searched around a bit and I'm surprised not to find a ready solution for this. A possibility could be to use KWin and write a "Kwin effect" for it: https://blog.martin-graesslin.com/blog/2009/07/how-to-write-a-kwin-effect/ . Also, a gnome shell extension is imaginable, but does not exist yet.

A workaround solution: Weston is the reference implementation of Wayland. It allows rotating windows with super-key + middle mouse button. As this works for Wayland clients only, you can run Xwayland in weston, run your X application on Xwayland, and rotate the Xwayland display. If your application supports Wayland (based on GTK3, QT5 or SDL, for example), this works in weston without Xwayland.

For X applications on Xwayland

weston
WAYLAND_DISPLAY=wayland-0 Xwayland :5
DISPLAY=:5 yourXapplication
DISPLAY=:5 x-window-manager  # additionally run a window manager for comfort

(On Gnome-Wayland you can run Xwayland directly without using weston, but I'm not aware of a Gnome-Wayland option to rotate a window).

For QT5 applications without Xwayland:

weston
WAYLAND_DISPLAY=wayland-0  QT_QPA_PLATFORM=wayland  yourQT5application

For GTK3 and SDL applications without Xwayland:

weston
WAYLAND_DISPLAY=wayland-0 yourGTK3application

(Note: You can specify a wayland socket/WAYLAND_DISPLAY with weston --socket=mywaylandsocket instead of assuming it will be wayland-0. You need to do this on Gnome-Wayland as it uses wayland-0 itself)

Related Question