Bug 417493 - Explicitly set gtk-application-prefer-dark-theme to true or false (as appropriate) when using a GTK theme that doesn't follow the color scheme
Summary: Explicitly set gtk-application-prefer-dark-theme to true or false (as appropr...
Status: CONFIRMED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_style (show other bugs)
Version: 5.18.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-12 14:02 UTC by Frederick Zhang
Modified: 2020-04-27 15:46 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederick Zhang 2020-02-12 14:02:07 UTC
SUMMARY
It seems since 5.18.0 release, Plasma updates gtk-application-prefer-dark-theme in $HOME/.config/gtk-3.0/settings.ini every time after logon. However its value is decided by the global theme rather than the GTK theme.

STEPS TO REPRODUCE
1. In System Settings -> Global Theme, apply Breeze Dark
2. In System Settings -> Application Style -> Configure GNOME/GTK Application Style, apply Breeze to both GTK 2/3 (I also tested Materia-light [1])
3. Re-log in

OBSERVED RESULT
gtk-application-prefer-dark-theme is reset to 1. GTK applications have dark backgrounds.

EXPECTED RESULT
GTK application should use light themes as per GNOME/GTK Application Style.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.18.0
KDE Frameworks Version: 5.67.0
Qt Version: 5.14.1
Kernel Version: 5.5.3-zen1-1-zen
OS Type: 64-bit


[1] https://github.com/PapirusDevelopmentTeam/materia-kde
Comment 1 Mikhail Zolotukhin 2020-02-12 21:37:41 UTC
The value is decided by selected color scheme in Colors KCM. If the color scheme is light - it is zero, if not - it is one.
Comment 2 Frederick Zhang 2020-02-13 11:30:35 UTC
But the GTK style should have taken precedence, right?
Comment 3 Mikhail Zolotukhin 2020-02-13 19:52:49 UTC
(In reply to Frederick Zhang from comment #2)
> But the GTK style should have taken precedence, right?

No, it should not. The GTK theme should either: 
1. Grab it's colors from color definitions, that were generated, when you selected color scheme it Colors KCM.
2. Make itself dark, if your select dark color scheme in Colors KCM or if you select dark theme inside the GTK application.

You SHOULD NOT select dark GTK theme for GTK applications and light color scheme for Plasma and Kde/Qt apps. Dark/Light theme should not be based on framework, that is used by programmers to write application, but rather on a particular application itself or the whole look (Global Dark/Light mode).

But it's actually my fault. We shouldn't give an ability to set dark/light themes in GTK page. For example "Breeze" and "Breeze-dark" should be collapsed into just "Breeze" and "Adwaita" and "Adwaita-dark" to just "Adwaita". Those will set their colors dynamically.
Comment 4 Frederick Zhang 2020-02-13 21:14:05 UTC
Well, I'm actually using a dark global theme and a light GTK application style since some GTK applications have got their own theme engines, which look great btw, but with a dark background they become straight appalling, e.g. Firefox and (especially) Thunderbird.

IMHO we should leave this choice to users and provide as much flexibility as possible simply because a lot of GTK applications cannot fit well in the Qt ecosystem and there's no way for us to force this down their throats. And merging the options sounds like an even worse idea to me as I guess it'd probably be tricky to handle third-party themes and what to do with themes that haven't got an dark/light variant is also a problem.
Comment 5 Mikhail Zolotukhin 2020-02-13 21:39:21 UTC
(In reply to Frederick Zhang from comment #4)
> some GTK applications become straight appalling,
> e.g. Firefox and (especially) Thunderbird.

It's a problem of those applications, that they fail to correctly use dark theme from GTK. It should be reported to them (if not already) and fixed. Alternatively a workaround with setting `GTK_THEME=theme_name` variable can be applied. 

> IMHO we should leave this choice to users and provide as much flexibility as
> possible simply because a lot of GTK applications cannot fit well in the Qt
> ecosystem and there's no way for us to force this down their throats.

KDE current goal is consistency and reasonable amount of customization, not just simply "more features for features". Selecting different colors for applications based on what framework it's based is an unreasonable feature. (In perfect world of course, where there are no buggy applications, that fail to apply GTK theme colors)

> merging the options sounds like an even worse idea to me as I guess it'd
> probably be tricky to handle third-party themes and what to do with themes
> that haven't got an dark/light variant is also a problem.

I mean, that themes with "-dark" suffix could be hidden within the combobox of possible GTK themes selections. They will be still present as the themes. The themes, that has no dark/light variants will not be touched.

Nevertheless, if people do not agree with this change, I will not make it. I just do not know what else can be done on our side. Perhaps only removing syncing the `gtk-application-prefer-dark-theme` parameter in the configs for GTK applications depending on color scheme you selected.
Comment 6 Nate Graham 2020-02-13 22:40:31 UTC
(In reply to Mikhail Zolotukhin from comment #3)
> You SHOULD NOT select dark GTK theme for GTK applications and light color
> scheme for Plasma and Kde/Qt apps. Dark/Light theme should not be based on
> framework, that is used by programmers to write application, but rather on a
> particular application itself or the whole look (Global Dark/Light mode).
> 
> But it's actually my fault. We shouldn't give an ability to set dark/light
> themes in GTK page. For example "Breeze" and "Breeze-dark" should be
> collapsed into just "Breeze" and "Adwaita" and "Adwaita-dark" to just
> "Adwaita". Those will set their colors dynamically.
I agree. It's not your fault though, it's always been that way. :)

If a user wants to have a different style for GTK apps, they're still welcome to do that; just select a GTK theme that isn't Breeze-GTK. Someone using Breeze-GTK, is signaling that they want for GTK apps to look as similar to Qt apps as possible, so we should honor that request.

So I think it's perfectly reasonable to just show "Breeze-GTK" and not its light or dark variants.
Comment 7 Frederick Zhang 2020-02-14 01:44:21 UTC
I'm actually *not* using Breeze but Materia-light-compact instead. As it's a third-party theme I tested the case with Breeze hence it in this filed issue.

While I agree that users who choose Breeze *usually* are expected to 'want for GTK apps to look as similar to Qt apps as possible', only hiding suffixes of official themes would though create a special case, of which I'm not the hugest fan. Personally I'd appreciate some consistency here and tbh I don't understand why we have to create more work here just to forbid users from choosing another variant of a theme which they currently can.

The workflow I would expect is:
1. When a user applies a Global Theme, simply change the GTK one as well (if it's got a corresponding one), and also choose the same dark/light variant here (even for third-party ones if feasible). It's called 'Global Theme' and this is what one should expect.
2. Users can then optionally go to Configure GNOME/GTK Application Style and choose whichever theme/variant they want. If someone happens to select Breeze light here while using Breeze Dark as the Global Theme, simply let it be then cos they manually go through the extra steps to intentionally change it so it must be what they want.
3. gtk-application-prefer-dark-theme is synchronised to GNOME/GTK Application Style.
Comment 8 Nate Graham 2020-02-14 05:05:28 UTC
That makes sense to me. So basically:

1. When using the Breeze GTK theme, set gtk-application-prefer-dark-theme based on the colors of the color scheme, since it's a color-scheme-aware theme.
2. When using the Breeze-Dark GTK theme, set gtk-application-prefer-dark-theme to true.
3. If a Breeze-Light GTK theme is ever added, set gtk-application-prefer-dark-theme to false when using it.

Do I have that right?
Comment 9 Frederick Zhang 2020-02-14 06:40:11 UTC
> since it's a color-scheme-aware theme
Ah, my bad. I thought the current Breeze was simply a light variant of the theme. Guess it has caused some misunderstandings, sorry!

And yes, I reckon we are on the same page now. Btw out of curiosity, is Plasma currently able to determine whether a third-party theme is dark or light? For instance using 'Materia-light-compact' mentioned above, will gtk-application-prefer-dark-theme be set to true regardless of what colour scheme is chosen?
Comment 10 Frederick Zhang 2020-02-14 06:41:15 UTC
...will gtk-application-prefer-dark-theme be set to *false*...

Typo, sorry
Comment 11 Nate Graham 2020-02-14 14:10:51 UTC
(In reply to Frederick Zhang from comment #9)
> And yes, I reckon we are on the same page now. Btw out of curiosity, is
> Plasma currently able to determine whether a third-party theme is dark or
> light? For instance using 'Materia-light-compact' mentioned above, will
> gtk-application-prefer-dark-theme be set to true regardless of what colour
> scheme is chosen?
It's probably possible. We could re-use the same heuristic we're using to determine whether a color scheme is light or dark.

Sounds like a plan.
Comment 12 Mikhail Zolotukhin 2020-04-25 16:24:01 UTC
How about that solution: set "gtk-application-prefer-dark-theme" only when using Breeze GTK theme? So that:
1. When the user selects non Breeze GTK theme the setting got deleted and the light/dark is decided by GTK theme that was selected.
2. When the user selects Breeze GTK the "gtk-application-prefer-dark-theme" setting is applied.
3. When the user selects color scheme the GTK setting "gtk-application-prefer-dark-theme" is only applied, if the current GTK theme is Breeze GTK
Comment 13 Nate Graham 2020-04-27 15:46:58 UTC
(In reply to Mikhail Zolotukhin from comment #12)
> How about that solution: set "gtk-application-prefer-dark-theme" only when
> using Breeze GTK theme? So that:
> 1. When the user selects non Breeze GTK theme the setting got deleted and
> the light/dark is decided by GTK theme that was selected.
> 2. When the user selects Breeze GTK the "gtk-application-prefer-dark-theme"
> setting is applied.
> 3. When the user selects color scheme the GTK setting
> "gtk-application-prefer-dark-theme" is only applied, if the current GTK
> theme is Breeze GTK
...And also only when the color scheme itself is a dark color scheme.