Skip to content

xwm: support _NET_WM_OPAQUE_REGION#2016

Open
kelnos wants to merge 1 commit intoSmithay:masterfrom
kelnos:x11-support-opaque-region
Open

xwm: support _NET_WM_OPAQUE_REGION#2016
kelnos wants to merge 1 commit intoSmithay:masterfrom
kelnos:x11-support-opaque-region

Conversation

@kelnos
Copy link
Copy Markdown
Contributor

@kelnos kelnos commented Apr 29, 2026

Description

X11 clients can set this property on their window to indicate a single fully-opaque region for the window.

I'm not sure if this is actually the right way to propagate the opaque region through; would appreciate some guidance if not.

Checklist

Copy link
Copy Markdown
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

Looks mostly good, definitely a render optimization, that we want to have.

Just a few questions on the specifics of the spec on this property.

Also: Any particular clients, that use this feature and you tested with?

Comment thread src/xwayland/xwm/mod.rs Outdated
let mut guard = states.cached_state.get::<SurfaceAttributes>();
let attrs = guard.pending();
attrs.opaque_region = opaque_region;
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, while it would be nice to lock any opaque-region updates to commits, I am not sure those are meant to be applied atomically.

Does the spec say anything about new contents and when to apply changes to __NET_WM_OPAQUE_REGION? Did you see any updates to this without content changes in your testing?

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.

Here is the spec: https://specifications.freedesktop.org/wm/1.5/ar01s05.html#id-1.6.19

... which I appear to have misread; looks like it's a list of rectangles, not just a single one, so I'll update to fix that.

I guess in general on X11 we don't have the same sort of synchronization between window properties and painting as we do on Wayland, so the compositing manager presumably should apply it as soon as it "sees" the property. That means the client has to have already painted the window in a way that matches the values it sets in this property.

Comment thread src/xwayland/xwm/mod.rs Outdated
@kelnos kelnos force-pushed the x11-support-opaque-region branch 2 times, most recently from e796b0e to 9ce90ef Compare April 29, 2026 20:47
@kelnos
Copy link
Copy Markdown
Contributor Author

kelnos commented Apr 29, 2026

Ok, pushed a fix so it will collect as many rectangles as are in the property. I also refactored it a bit: noticed that there was already a path in X11Surface that I missed yesterday for fetching initial properties and handling updates, so now it uses the same pattern.

For testing, I wrote a quick x11rb program that paints to a window, uniformly with 50% transparency, and sets two opaque regions in the property. It sets them "incorrectly": I was hoping that I'd see smithay fail to blend properly under the "incorrectly opaque" rects.

That didn't work (that is, it blended properly underneath the entire window), so I added debugging prints in update_opaque_regions() to ensue that the rects were being picked up, which worked.

Just now I added a few more debugging prints, and I've discovered that the pre-commit hook I added isn't getting called at all... realized I should have that in X11Surface::set_wl_surface(), as the surface can get set in multiple ways. That fixed things up.

So back to the test program: now it works as expected: smithay doesn't blend below the opaque regions in the window, so even though they're painted as partially transparent, I can't see other window content beneath the area where those rects are set as the opaque region. The test program also updates _NET_WM_OPAQUE_REGION on window resize, and that appears to work properly as well.

@kelnos kelnos force-pushed the x11-support-opaque-region branch from 9ce90ef to 6e9bb83 Compare April 29, 2026 20:53
X11 clients can set this property on their window to indicate a single
fully-opaque region for the window.
@kelnos kelnos force-pushed the x11-support-opaque-region branch from 6e9bb83 to 42f0943 Compare April 29, 2026 21:00
@kelnos
Copy link
Copy Markdown
Contributor Author

kelnos commented Apr 29, 2026

Screenshot of it working for posterity. The two orange-bordered rectangles are painted exactly as the rest of the window is painted, partially transparent, but we can't see the text in the terminal below those areas, as they're in the regions specified in _NET_WM_OPAQUE_REGION.

Screenshot_2026-04-29_14-06-26

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