Skip to content
← Back to blog

November 6, 2026 · 4 min read

Drawing above every window without blocking the mouse: an overlay on Linux (Wayland)

The desktop app of my music visualizer draws above every window without blocking the mouse. Layer-shell, empty input regions, a window that "fixed" itself back, and audio that arrived but was garbage.

In this post
  1. Three things a page can’t do
  2. Layer-shell and an empty input region
  3. The window that “fixed” itself back
  4. Audio that arrived but was useless
  5. More WebKitGTK traps
  6. Testing in the real app
  7. What I learned

Visualizer is my music visualizer: animations that move with whatever is playing and take the colors of the album art. Its web version lives in a browser tab. I wanted something else: to see the music while I work, along the edge of the screen or in a bubble, above every window and out of the way. That’s an overlay, and a web page can’t do it.

That’s how the Linux desktop app started, with Tauri v2: the same web engine in a native window, with Rust behind it for what the browser can’t do.

Three things a page can’t do

  1. Hear everything the computer plays, with no source to pick. Rust runs PipeWire’s pw-record on the monitor of the audio output and hands the samples to the page as binary messages. The page runs the same FFT an AnalyserNode would, so the beat detector is the same as on the web.
  2. Know which song is playing without signing in to anything. playerctl follows every MPRIS player (Spotify, the browser…) and picks the one that’s playing. The artwork is fetched from Rust, with no CORS problems.
  3. Draw above everything without stealing clicks. This was the hard part.

Layer-shell and an empty input region

On Wayland, a normal window can’t decide to stay above the others. But compositors like niri, Hyprland, Sway and KDE implement layer-shell, a protocol for bars, wallpapers and notifications. A surface on the overlay layer sits above everything, even the desktop bar.

The overlay recipe:

  • overlay layer, anchored to all four edges;
  • no exclusive zone, so it doesn’t push other windows around;
  • no keyboard focus;
  • and an empty input region: the window exists, but the compositor sends it no mouse events, so clicks reach whatever is underneath.

In a pure GTK test it worked the first time. In Tauri, the overlay looked perfect but blocked the mouse.

The window that “fixed” itself back

The cause was the order of things. In Tauri, showing a window is asynchronous: I emptied the input region and, a moment later, the window finished showing and the region went back to normal. My change was lost without any error.

The fix was to reapply the empty region every time the window is mapped, every time it’s resized and once more when the main loop goes idle. I didn’t trust my own hand to check it: I ran the app with WAYLAND_DEBUG and looked for two things in the log. The input region had to arrive with no rectangles at all, and in 45 seconds of moving the mouse over it, not a single pointer event should arrive. That’s what happened.

Audio that arrived but was useless

With the overlay working, the scenes appeared, the song title showed up… and nothing moved.

I had checked that the audio was arriving: about 184 KB per second, the right throughput. The problem is that I measured how much arrived, not what arrived. pw-record without --raw doesn’t write raw samples: it writes an AU file, with a header and big-endian numbers. The page read that as normal samples and got garbage and NaN.

With --raw, the level became something real. Since then the app has a debug mode that prints the audio’s RMS level, and the rule is to look at that number, not the throughput.

More WebKitGTK traps

On Linux, Tauri uses WebKitGTK instead of Chromium, and there are differences:

  • requestFullscreen() doesn’t work: you have to ask the native window for full screen.
  • It does run WebGL2 with floating-point textures, but it caps animation at 60 frames per second, even on a 165 Hz screen.
  • GTK3 doesn’t do fractional scaling: at 1.25 it draws at 2× and scales down. On the overlay it pays to cap the canvas resolution.

Testing in the real app

One day the overlay “still” wasn’t saving the height I picked. The bug was already fixed: the old binary was running, because installing didn’t restart the open app.

Two things came out of that. The installer now restarts the running copy. And there’s an end-to-end test: it builds the app with a different identifier (so it doesn’t touch mine or its settings), clicks through the overlay settings, and the overlay logs what it draws with which options. The rule is written down: I don’t say “fixed” without running that test.

What I learned

  • On Wayland, “above everything” isn’t a window property: it’s a protocol (layer-shell) the compositor has to offer.
  • If a change “does nothing”, suspect the order: something asynchronous may be undoing it.
  • Measuring throughput isn’t measuring content. Look at the signal, not just at bytes arriving.
  • In apps with windows and processes, an end-to-end test in the real app finds what unit tests can’t see.

Rossmel Abasto — Frontend → Fullstack Developer. LinkedIn · GitHub

Leer este artículo en español →See the case studyVisualizer →A real-time music visualizer: the colors come from the album art and the motion from the sound. On the web, Linux and Android.

Keep reading

Write to me: I read everything and reply by email.

Questions or comments about this post?

send-mail.sh