pop-os / gtk-theme

System76 Pop GTK+ Theme
GNU General Public License v3.0
787 stars 83 forks source link

Dark theme causes black-on-gray text in wxWidgets apps #600

Open dkonigsberg opened 1 year ago

dkonigsberg commented 1 year ago

Distribution: Pop!_OS 22.04 LTS

Related Application and/or Package Version: libwxgtk3.0-gtk3-0v5: Installed: 3.0.5.1+dfsg-4 kicad: Installed: 6.0.10-0-202212181939+86aedd382b~118~ubuntu22.04.1

Issue/Bug Description: On wxWidgets applications using certain controls, any text that's selected-but-unfocused gets rendered as black-on-gray: image

I did some investigation, and only two wxWidgets color keys get set to black with the Pop-dark theme: wxSYS_COLOUR_HIGHLIGHTTEXT and wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT

I'm pretty sure its the latter, as the comments in the wxWidgets code explicitly say: "This is for the text in a list control (or tree) when the item is selected, but not focused.”

Steps to reproduce (if you know):

  1. Run KiCad
  2. Open any dialog with a key/value grid (quickest is Preferences -> Configure Paths)
  3. Click on any value text field to make it editable (e.g. "Path")
  4. Notice that the corresponding key field (e.g. "Name") becomes black-on-gray text

Expected behavior: The text should remain readable.

Other Notes:

I've checked a few other dark themes, notably Adwaita-Dark and Ubuntu's built-in Yaru-dark, and neither have this problem.

I also did a bit more digging into wxWidgets, and noticed that it seems to get this color value by creating a "gtk_tree_view_new_with_model()", then calling "gtk_widget_get_style()" on that, then finally checking the "text[GTK_STATE_ACTIVE]" property of that. However, feel free to dig through wxWidgets' "src/gtk/settings.cpp" code to confirm.

I'd attempt to suggest a direct fix, but I can't make heads or tails of the CSS mess of modern Gtk theme configurations, so I don't know where to start.

isantop commented 1 year ago

I believe the problem is that they're grabbing the text color from a selected GTK TreeView cell, but not the background color. The color should be a light blue, which would still be visible.

This issue doesn't happen in Adwaita or Yaru because those themes use white text for selected columns. Pop (since the selected background color is lighter than the other themes) requires using black to ensure proper contrast. Really, Adwaita and Yaru should as well as their contrast for those widgets is not very high, but that's not an issue for here. Also, I believe those themes will experience the opposite issue in the light theme (selected rows using white text on a white/light background).

dkonigsberg commented 1 year ago

In the Adwaita light theme, it is indeed white text on a light gray background. But its still a lot more contrast, and thus a lot more readable, than black text on an a dark gray background.

I know its easy to blame wxWidgets, or whatever app is trusting its color query API, but that doesn't really help here. Often wxWidgets gets treated like this evergreen library where the distro packages aren't even kept up to date, and projects that use it will happily just blame my theme if I try to complain to them about the issue.

Frankly, I'd probably be happy with some sort of suggestion on how to locally patch my own theme to deal with this, because as long as Pop_OS! is considered a niche distro nobody upstream is going to pay attention to a bug report of this nature.

isantop commented 1 year ago

I know its easy to blame wxWidgets, or whatever app is trusting its color query API, but that doesn't really help here.

Unfortunately, it's not really possible to fix this without breaking the design/colors/contrast of the Pop theme in places where it already works. The problem is that when an application/toolkit queries GTK themes for color information, they need to do so correctly without making assumptions about what colors are going to be present, or avoid doing so entirely and use their own theming/colors for widgets. The recommendation thus remains filing the bug upstream.