Implement LookAndFeel::eIntID_SystemUsesDarkTheme

RESOLVED FIXED in Firefox 67

Status

()

P3
normal
RESOLVED FIXED
a month ago
17 days ago

People

(Reporter: mats, Assigned: mats)

Tracking

Trunk
mozilla67
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox67 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

a month ago

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?

(Assignee)

Updated

a month ago
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.

Comment 2

a month ago

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

(Assignee)

Comment 3

a month ago
Assignee: nobody → mats
Keywords: helpwanted
(Assignee)

Comment 4

a month ago
Posted 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+
(Assignee)

Comment 7

28 days ago

OK, thanks.

Comment 8

28 days ago
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

Comment 10

25 days ago
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

Comment 11

25 days ago
bugherder
Status: NEW → RESOLVED
Last Resolved: 25 days ago
status-firefox67: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla67

Updated

24 days ago
Depends on: 1529897
Blocks: 1494034
(Assignee)

Updated

21 days ago
Flags: needinfo?(mats)
Depends on: 1529707
You need to log in before you can comment on or make changes to this bug.