1

I'm currently writing a window manager, and I was wondering if it were possible to create a window that is overlaid on top of all the other windows, but does not take input focus at all. In other words, I'd ideally like to be able to draw on this window without taking any input.

One approach would be to have the window manager call XQueryTree and then pass input (mouse clicks, keyboard input, etc) to the corresponding window. However, I wonder if there's a way to just prevent this overlay window from ever getting input events at all.

Also, I'd prefer not to draw directly on the root window, as that would break the compositing manager.

AnimatedRNG
  • 1,859
  • 3
  • 26
  • 39

1 Answers1

1

Composite extension provides exactly what you want:

https://www.x.org/releases/X11R7.7/doc/compositeproto/compositeproto.txt

3.2 Composite Overlay Window

Version 0.3 of the protocol adds the Composite Overlay Window, which provides compositing managers with a surface on which to draw without interference. This window is always above normal windows and is always below the screen saver window. It is an InputOutput window whose width and height are the screen dimensions. Its visual is the root visual and its border width is zero. Attempts to redirect it using the composite extension are ignored. This window does not appear in the reply of the QueryTree request. It is also an override redirect window. These last two features make it invisible to window managers and other X11 clients. The only way to access the XID of this window is via the CompositeGetOverlayWindow request. Initially, the Composite Overlay Window is unmapped.

CompositeGetOverlayWindow returns the XID of the Composite Overlay Window. If the window has not yet been mapped, it is mapped by this request. When all clients who have called this request have terminated their X11 connections the window is unmapped.

Composite managers may render directly to the Composite Overlay Window, or they may reparent other windows to be children of this window and render to these. Multiple clients may render to the Composite Overlay Window, create child windows of it, reshape it, and redefine its input region, but the specific arbitration rules followed by these clients is not defined by this specification; these policies should be defined by the clients themselves.

see C api here: https://linux.die.net/man/3/xcompositegetoverlaywindow

Andrey Sidorov
  • 24,905
  • 4
  • 62
  • 75
  • This is an interesting solution and I tried to use it together with cairo, the problem is that if we draw something on top of this composite overlay window, the drawing will disappear in a several miliseconds (tried in Ubuntu with Unity and Arch with Cinnamon). That means that if we want to draw on it, we have to constantly (or almost constantly, with some sleep time) trigger the draw operation again and again, but in this case not only it will affect the performance, but also there will be a visible flickering / blinking of the drawing... I was not able to find a workaround so far. – Daniel Feb 20 '18 at 15:53
  • this is probably because another compositor is running ( for Ubuntu it's Compiz ). Try starting simple x session with non-compositing wm or standalone compositor program – Andrey Sidorov Feb 20 '18 at 22:17
  • Yeah, I suspect that something draws on top of this overlay window, that's why I observe the flickering. Probably the "portable" solution in this case would be to create a child window of composite overlay window, fill it with transparent color and then draw on top of it. – Daniel Feb 21 '18 at 08:00
  • The only problem is that the overlay window seems to have only 24 bits of depth, i.e. does not support alpha. – Daniel Feb 21 '18 at 08:29
  • **UPD.** Yes, the approach with child window of overlay kinda works, but the problem is that neither overlay, nor its children can be made transparent. Even if the child window created with 32 bit depth. So the only reliable approach to draw "on top of everything" is to capture the overlay/root window, draw whatever the user needs on top of it and display the result in the child window of composite overlay window. – Daniel Feb 21 '18 at 15:57