GNOME Bugzilla – Bug 774270
[x11] Nested Frames with semi-transparent backgrounds - child widgets draw wrong bg colours
Last modified: 2016-12-31 01:25:33 UTC
Created attachment 339625 [details] test case I'm trying to apply some simple CSS styling to my application. The crux is that I want any GtkFrame to get a slightly darker background than its parent widget - which might be another Frame. FWIW: I only actually nest Frames at 2 levels. Using Frames is justified as I must group large numbers of widgets. I want to visually differentiate Frames so that users can immediately see the sections/boundaries in the UI. Border lines alone aren't as clear as I'd like for this purpose. So, I'm trying to do this by applying 'shading' to each Frame, through applying a black background-colour with transparency. So, I load a CSS provider including this selector: frame > border { background-color: rgba(0, 0, 0, N); } where N is the desired level of alpha/amount of shading, of course < 1.0. First: Is this pattern supposed to work? I hope so. And it certainly looks like GTK+ _tries_ to do it - by giving the Frames' backgrounds the successively darker colours I want - but then it fails. Descendant widgets, with transparent backgrounds, don't reliably get the correct background colour for their 'level' (parent Frame). Sometimes they get the colour of the uppermost window or Frame. Actions like hovering over the child or resizing the window can temporarily apply the background colour they should have, but it seems completely intermittent and arbitrary, and doing something else will glitch them out again. The end result is that the background-colour property is unusable with transparency in nested GtkFrames. The alternative of faking an equivalent semi-transparent background using box-shadow with a huge spread and inset seems to be broken in the same way. Please see the attached, contrived test case. Try mousing over the widgets and resizing the window. It's likely other widgets are affected, but the Scale and CheckButton shown in this example are the ones I noticed first off. Let me know if I can provide anything else to help.
Created attachment 339626 [details] screencast of test case
In a quick test, your testcase works correctly with both GTK+ master and 3.22 here.
Hi Matthias, thanks for trying it out. How quick was your test, perhaps so quick that you only tried Wayland? :) Because I thought I'd better try that now, and this is OK on Wayland, but not X. Does that help diagnose it?
The problem seems to hinge around the presence of successively nested frames (and maybe other widgets) that have exactly the same background colour. In quick tests I'm doing right now, even changing 1 value by 1 point is enough to mask the issue examples to follow
Created attachment 342644 [details] example of problem NOT occurring if bg colors do not match precisely As long as all nested frames' background colours are at least minimally different from their parent, then the problem seems to go away. May point to an issue with 'merging' background colours of nested widgets, maybe?
> Company you could try running with GDK_RENDERING=image to see if it goes away > dboles ooh! > yes, it works as expected with that env var set > Company then you have an X driver bug (or cairo's X backend is broken)
moved to Cairo: https://bugs.freedesktop.org/show_bug.cgi?id=99233