Skip to content

Native Wayland overlays via wlr-layer-shell - #231

Open
sansmoraxz wants to merge 9 commits into
akshualy:mainfrom
sansmoraxz:nv-wlr-support
Open

sansmoraxz wants to merge 9 commits into
akshualy:mainfrom
sansmoraxz:nv-wlr-support

Conversation

@sansmoraxz

@sansmoraxz sansmoraxz commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Overlays on Wayland only worked when Merframe ran on XWayland, so they couldn't sit above a native Wayland game session (e.g. Proton with PROTON_ENABLE_WAYLAND=1). When the compositor offers zwlr_layer_shell_v1 and gtk-layer-shell is installed, overlays are now layer-shell surfaces on the overlay layer, above both native Wayland and XWayland games. Otherwise Merframe falls back to the existing XWayland path, then to the in-app tab.

Changes summary

  • Layer-shell overlays: gtk-layer-shell is loaded at runtime, so Merframe still starts without it. Before GTK starts, Merframe checks whether the compositor offers the protocol, connecting through WAYLAND_DISPLAY only. Overlays are click-through and take no keyboard input. They're placed on the monitor under the target position, with margins clamped to that screen. If a window can't become a layer surface after startup, it falls back to a plain overlay window.
  • Repaint after map: WebKit sometimes didn't draw onto a newly mapped layer surface until the next resize, so a one-pixel resize forces a frame. A real resize that happens in between is left alone.
  • Scaling: layer-surface sizes are set in the target monitor's logical pixels. When the game runs on XWayland, its window only decides which monitor to use, because X and GDK-Wayland coordinates differ on scaled outputs.
  • NVIDIA: WEBKIT_DISABLE_DMABUF_RENDERER=1 is set under X11/XWayland (GBM buffer allocation fails, leaving windows blank) and on the layer-shell path (blank windows / Error 71).
  • GDK_BACKEND=x11 on Wayland: overlay windows are now used in auto mode. Before, only Merframe switching itself onto XWayland counted, so auto mode fell back to the in-app tab.
  • GTK app id set so Wayland compositors match windows to the .desktop entry.

Set GDK_BACKEND=x11 to skip layer shell and use XWayland.

Testing

Tested with KDE Plasma (wayland session) and Hyprland on RTX 3000 h/w. Combinations of Wayland and Xwayland sessions. Xwayland Merframe + wayland Warframe is expected to fail anyway but all other combinations shows the overlay layer. Wouldn't work in Gnome with wayland as it lacks support for most wlr-* protocols.

Also some wierd edge case where occasionally you may need to switch window and back for the layer to be visible in KDE, didn't notice in Hyprland. This is not tackled yet in this PR as I am not entirely sure what caused it.

Multi monitor setup / wierd DPI settings aren't feasibly testable by my current hardware setups.

@akshualy akshualy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for your initiative and willingness to contribute! :)

I'm struggling to weigh the risk vs. fixes this brings. On one hand, I understand that supporting Wayland natively is a desired change. On the other hand, I have tested the current Overlay system to work on most distributions and desktop environments, while this PR is honest about not having done so.

I have tested it briefly on some of the configurations, and it seems the overlays are always blank on the first show (KDE and sway), and also don't properly respect scaling (iE putting it at 1.5x doesn't make the overlays bigger).

If you insist on the feature, I'd like these changes:

  • An opt-in for layer shell, preferably on the Overlays page, so that XWayland stays the default
  • Drop the FAILED fallback to plain windows, the current fallback to in-app is enough

If you want just the NVIDIA fixes, please extract those out to a separate PR. Here we could also either let the user decide whether they want this feature, or auto-detect via a startup probe whether the change is necessary. I'm fairly certain this issue doesn't affect every NVIDIA+WebKitGTK setup.

"frontendDist": "../dist"
},
"app": {
"enableGTKAppId": true,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change anything meaningful?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly that the app's icon doesn't come in taskbar (generic wayland icon) without it when loading in wayland.

@sansmoraxz

Copy link
Copy Markdown
Contributor Author

overlays are always blank on the first show

Switching window and back did paint the layers so not exactly sure what was causing it, might even be a dependency down the chain I am not skilled enough to debug on. Will give another pass over it and see.

Will drop the FAILED fallback to plain windows and add toggle button for layer shell support (experimental).

Regarding default composition for Merframe itself, IDK running it in XWayland feels quite stuttery (at least with webkit on my system, I don't have a bunch of distros lying around to test this as thoroughly though). Probably better to offer a toggle and persistent config too (but would need a full restart for changes on these to take effect).

@sansmoraxz
sansmoraxz marked this pull request as draft December 2, 2026 19:40
XWayland overlays can't sit above native Wayland games. Used when the
compositor offers wlr-layer-shell and gtk-layer-shell is installed,
otherwise falls back to XWayland.
WebKit sometimes didn't draw onto the new surface until the next resize.
Wayland matches windows to .desktop entries by app id, not window icons.
Only self-adoption counted, so auto mode fell back to the tab.
A window that can't become a layer surface is closed, the in-app tab still shows it.
Off by default, so existing XWayland setups don't change.
GDK rounds fractional scales up and Wayland has no primary monitor, so overlays were misplaced.
GTK never draws the first frame after a plain resize, so use a size request. Replaces the repaint after map.
@sansmoraxz
sansmoraxz marked this pull request as ready for review December 5, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants