app: enable transparent CSD windows on Wayland#170
Conversation
| if !w.config.Decorated { | ||
| // Don't mark CSD windows as opaque so the compositor can apply | ||
| // rounded corners and transparency effects. | ||
| C.wl_surface_set_opaque_region(w.surf, nil) | ||
| return | ||
| } |
There was a problem hiding this comment.
I don't understand why Decorated should controls opqueness. On the one hand, it seems to me a Decorated = true window may be transparent as well. On the other hand, what about Decorated = false windows that are opaque? Will your change incur a cost because the system compositor is forced to blend window content instead of merely copying it?
There was a problem hiding this comment.
Fair point. Decorated and transparency are orthogonal concepts — a decorated window might want a transparent background, and an undecorated one might be intentionally opaque (for performance).
A cleaner solution: add a Transparent bool field to Config with a corresponding Transparent(bool) Option, and use that instead of Decorated to control the opaque region. This way apps explicitly opt in, paying the compositor blending cost only when needed, while the default stays opaque (fast path).
Happy to revise the patch with this approach if that direction is acceptable.
There was a problem hiding this comment.
A Transparent(bool) sounds good to me.
| // Use transparent clear color to support window transparency and | ||
| // compositor-drawn rounded corners on Wayland/macOS. | ||
| w.gpu.Clear(color.NRGBA{A: 0x00, R: 0x00, G: 0x00, B: 0x00}) |
There was a problem hiding this comment.
Echoing my comment above, how do you know this is the correct change across all platforms?
There was a problem hiding this comment.
You're right — making the clear color transparent globally is incorrect and could break other platforms.
With the proposed Transparent option approach, the clear color would only be transparent when w.config.Transparent is true, keeping the existing opaque white behavior everywhere else. The window.go change would become:
if w.config.Transparent {
w.gpu.Clear(color.NRGBA{A: 0x00})
} else {
w.gpu.Clear(color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
}
This patch enables window transparency and compositor-drawn rounded corners
for undecorated (CSD) windows on Wayland.
Changes:
rounded corners and transparency
Without this, undecorated Gio windows on GNOME/KDE cannot have transparent
backgrounds or compositor-rounded corners because the surface is always
marked fully opaque.
Tested on GNOME 50 (Wayland). Apps can now use Decorated(false) with a
semi-transparent background and get proper rounded corners from the compositor,
matching the behavior of GTK/Qt CSD apps.