Bug 202276 - [GTK] Fix logic of dark theme detection
Summary: [GTK] Fix logic of dark theme detection
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Patrick Griffis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-26 10:13 PDT by Patrick Griffis
Modified: 2020-03-31 08:58 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.74 KB, patch)
2019-09-26 10:15 PDT, Patrick Griffis
no flags Details | Formatted Diff | Diff
Patch (2.14 KB, patch)
2020-03-30 15:53 PDT, Michael Catanzaro
pgriffis: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Griffis 2019-09-26 10:13:28 PDT
[GTK] Fix logic of dark theme detection
Comment 1 Patrick Griffis 2019-09-26 10:15:00 PDT
Created attachment 379656 [details]
Patch
Comment 2 EWS Watchlist 2019-09-26 10:15:34 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Michael Catanzaro 2019-09-26 10:18:29 PDT
Comment on attachment 379656 [details]
Patch

Now that you are a committer, you should have a trac account and can add this to https://trac.webkit.org/wiki/WebKitGTK/2.26.x. Otherwise your change might not reach users until 2.28.
Comment 4 WebKit Commit Bot 2019-09-26 11:04:38 PDT
Comment on attachment 379656 [details]
Patch

Clearing flags on attachment: 379656

Committed r250388: <https://trac.webkit.org/changeset/250388>
Comment 5 WebKit Commit Bot 2019-09-26 11:04:40 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Michael Catanzaro 2020-03-30 15:50:03 PDT
Comment on attachment 379656 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379656&action=review

> Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp:569
>      if (g_str_has_suffix(themeName.get(), "-dark"))

Um, well ":dark" isn't handled here. Surely this is a mistake? Looks like a mistake to me.

Nowadays we also have PageClientImpl::themeName that would need to be fixed as well.
Comment 7 Michael Catanzaro 2020-03-30 15:51:04 PDT
(Assuming this is a mistake....)
Comment 8 Michael Catanzaro 2020-03-30 15:53:51 PDT
Created attachment 394977 [details]
Patch
Comment 9 Michael Catanzaro 2020-03-30 15:54:27 PDT
Comment on attachment 394977 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394977&action=review

> Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp:574
>      GUniqueOutPtr<char> themeName;
>      g_object_get(settings, "gtk-theme-name", &themeName.outPtr(), nullptr);
> -    if (g_str_has_suffix(themeName.get(), "-dark"))
> +    if (g_str_has_suffix(themeName.get(), "-dark") || g_str_has_suffix(themeName.get(), ":dark"))
>          return true;

Patrick, is this OK?
Comment 10 Carlos Garcia Campos 2020-03-31 01:39:55 PDT
(In reply to Michael Catanzaro from comment #9)
> Comment on attachment 394977 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394977&action=review
> 
> > Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp:574
> >      GUniqueOutPtr<char> themeName;
> >      g_object_get(settings, "gtk-theme-name", &themeName.outPtr(), nullptr);
> > -    if (g_str_has_suffix(themeName.get(), "-dark"))
> > +    if (g_str_has_suffix(themeName.get(), "-dark") || g_str_has_suffix(themeName.get(), ":dark"))
> >          return true;
> 
> Patrick, is this OK?

I don't think it is. Just check GTK code instead of guessing:

https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtksettings.c#L3255

':' is only used to check the theme variant for the GTK_THEME env variable.
Comment 11 Patrick Griffis 2020-03-31 06:14:08 PDT
Comment on attachment 394977 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394977&action=review

>>> Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp:574
>>>          return true;
>> 
>> Patrick, is this OK?
> 
> I don't think it is. Just check GTK code instead of guessing:
> 
> https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtksettings.c#L3255
> 
> ':' is only used to check the theme variant for the GTK_THEME env variable.

As carlos said :dark is a variant and not part of the theme name.
Comment 12 Michael Catanzaro 2020-03-31 08:58:18 PDT
OK!