After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774270 - [x11] Nested Frames with semi-transparent backgrounds - child widgets draw wrong bg colours
[x11] Nested Frames with semi-transparent backgrounds - child widgets draw wr...
Status: RESOLVED NOTGNOME
Product: gtk+
Classification: Platform
Component: Widget: Other
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
https://bugs.freedesktop.org/show_bug...
Depends on:
Blocks:
 
 
Reported: 2016-11-11 14:25 UTC by Daniel Boles
Modified: 2016-12-31 01:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (1.59 KB, text/plain)
2016-11-11 14:25 UTC, Daniel Boles
Details
screencast of test case (535.54 KB, video/webm)
2016-11-11 14:32 UTC, Daniel Boles
Details
example of problem NOT occurring if bg colors do not match precisely (2.94 KB, text/plain)
2016-12-30 20:18 UTC, Daniel Boles
Details

Description Daniel Boles 2016-11-11 14:25:11 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.
Comment 1 Daniel Boles 2016-11-11 14:32:52 UTC
Created attachment 339626 [details]
screencast of test case
Comment 2 Matthias Clasen 2016-11-14 19:42:41 UTC
In a quick test, your testcase works correctly with both GTK+ master and 3.22 here.
Comment 3 Daniel Boles 2016-11-14 21:01:54 UTC
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?
Comment 4 Daniel Boles 2016-12-30 20:16:48 UTC
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
Comment 5 Daniel Boles 2016-12-30 20:18:59 UTC
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?
Comment 6 Daniel Boles 2016-12-30 21:08:40 UTC
> 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)
Comment 7 Daniel Boles 2016-12-31 01:25:15 UTC
moved to Cairo: https://bugs.freedesktop.org/show_bug.cgi?id=99233