Bug 213465 - [GTK] Dark mode for GTK themes that end with -Dark
Summary: [GTK] Dark mode for GTK themes that end with -Dark
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-22 09:03 PDT by Elliot
Modified: 2020-06-29 03:19 PDT (History)
7 users (show)

See Also:


Attachments
A patch for this issue modifying "Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp" (1.73 KB, patch)
2020-06-22 09:03 PDT, Elliot
no flags Details | Formatted Diff | Diff
Updated patch (1.66 KB, patch)
2020-06-22 18:50 PDT, Elliot
no flags Details | Formatted Diff | Diff
Fixed typo (1.66 KB, patch)
2020-06-22 19:58 PDT, Elliot
no flags Details | Formatted Diff | Diff
Fixed typo + obsolete old patch (1.66 KB, patch)
2020-06-22 20:00 PDT, Elliot
no flags Details | Formatted Diff | Diff
Patch for landing (2.76 KB, patch)
2020-06-29 02:44 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliot 2020-06-22 09:03:19 PDT
Created attachment 402481 [details]
A patch for this issue modifying "Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp"

WebKitGtk has support for automatic detection of dark mode when it comes to GTK themes with the "-dark" and ":dark" suffixes. However, when using GTK themes that end with "-Dark" or ":Dark", this is not the case. This affects many themes like "Arc" and "Flat-Remix", so adding this funcitonality would be very helpful. 

I have attached to this bug report a possible patch for this, however I am not sure if any other parts of the library need to be modified other than "Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp". If that is the case, then my patch should be a good example of what needs to be done.
Comment 1 Patrick Griffis 2020-06-22 16:34:31 PDT
:Dark doesn't make any sense as that refers to GTK variants and AFAIK nothing has used a variant by that name.

-Dark seems like a harmless change although Arc-Dark is a light theme.
Comment 2 Elliot 2020-06-22 18:50:58 PDT
Created attachment 402525 [details]
Updated patch
Comment 3 Elliot 2020-06-22 18:51:41 PDT
(In reply to Patrick Griffis from comment #1)
> :Dark doesn't make any sense as that refers to GTK variants and AFAIK
> nothing has used a variant by that name.
> 
> -Dark seems like a harmless change although Arc-Dark is a light theme.

Ah, sorry for the mix up. Here's a better patch with that information in mind... Hope it can be easily applied!
Comment 4 Patrick Griffis 2020-06-22 19:49:18 PDT
Comment on attachment 402525 [details]
Updated patch

>Index: Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
>===================================================================
>@@ -625,7 +625,7 @@
>     GUniqueOutPtr<char> themeNameSetting;
>     g_object_get(gtk_widget_get_settings(m_viewWidget), "gtk-theme-name", &themeNameSetting.outPtr(), nullptr);
>     String name = String::fromUTF8(themeNameSetting.get());
>-    if (name.endsWith("-dark"))
>+    if (name.endsWith("-dark") || name.endsWith("-dark"))

Typo.
Comment 5 Elliot 2020-06-22 19:58:48 PDT
Created attachment 402527 [details]
Fixed typo

Fixed typo
Comment 6 Elliot 2020-06-22 20:00:44 PDT
Created attachment 402528 [details]
Fixed typo + obsolete old patch
Comment 7 Carlos Garcia Campos 2020-06-29 02:44:29 PDT
Created attachment 403042 [details]
Patch for landing
Comment 8 EWS Watchlist 2020-06-29 02:45:07 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 9 EWS 2020-06-29 03:19:15 PDT
Committed r263652: <https://trac.webkit.org/changeset/263652>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403042 [details].