Closed Bug 1525775 Opened 5 years ago Closed 5 years ago

Implement LookAndFeel::eIntID_SystemUsesDarkTheme

Categories

(Core :: Widget: Gtk, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: MatsPalmgren_bugz, Assigned: MatsPalmgren_bugz)

References

Details

Attachments

(1 file)

Over in bug 1494034 we're adding support for the CSS 'prefers-color-scheme'
media query. The platform info to support that comes from
"LookAndFeel::GetInt(LookAndFeel::eIntID_SystemUsesDarkTheme, 0)"
which appears to be implemented for OSX and Windows, but not GTK:
https://searchfox.org/mozilla-central/search?q=eIntID_SystemUsesDarkTheme

Does GTK have an API to answer if the current theme is "light" or "dark"?
If not, can we synthesize an answer based on some fg/bg colors?

Keywords: helpwanted

(In reply to Mats Palmgren (:mats) from comment #0)

Does GTK have an API to answer if the current theme is "light" or "dark"?
If not, can we synthesize an answer based on some fg/bg colors?

This sounds like a reasonable thing to do if there's no reliable way to know if the theme is dark or light.

Bug #1461538 has some prior art on GTK dark themes, even if it’s not been going well.

Assignee: nobody → mats
Keywords: helpwanted
Attached patch fixSplinter Review
Attachment #9044464 - Flags: review?(cam)
Comment on attachment 9044464 [details] [diff] [review]
fix

Review of attachment 9044464 [details] [diff] [review]:
-----------------------------------------------------------------

This looks OK.  Since it's Gtk related I'd like to get Karl's sign off.
Attachment #9044464 - Flags: review?(karlt)
Attachment #9044464 - Flags: review?(cam)
Attachment #9044464 - Flags: review+
Comment on attachment 9044464 [details] [diff] [review]
fix

>+      // colors instead, by converting them to HSV and comparing the V part.

>+        uint16_t hue, sat, fg_v, bg_v;
>+        uint8_t alpha;
>+        NS_RGB2HSV(fg, hue, sat, fg_v, alpha);
>+        NS_RGB2HSV(bg, hue, sat, bg_v, alpha);
>+        aResult = bg_v < fg_v ? 1 : 0;

NS_GetLuminosity() provides a better indication of lightness or darkness than V = max(R,G,B) and is cheaper to compute, uses saner types, and involves fewer parameters than NS_RGB2HSV, so please use that, assuming there is not a compelling reason to use V.
Attachment #9044464 - Flags: review?(karlt) → review+

OK, thanks.

Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/133509097b7c
[css-mediaqueries] Synthesize a value for eIntID_SystemUsesDarkTheme to determine if GTK are using a light or dark theme.  r=heycam,karlt
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/738bb0805a9c
[css-mediaqueries] Synthesize a value for eIntID_SystemUsesDarkTheme to determine if GTK are using a light or dark theme.  r=heycam,karlt
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Depends on: 1529897
Blocks: 1494034
Flags: needinfo?(mats)
Depends on: 1529707
Regressions: 1559736
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: