-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prefers_color_scheme_dark false does not imply light anymore #6097
Comments
This is most certainly [QTBUG-89753] prefers-color-scheme does not seem to work - Qt Bug Tracker, fixed by Add back prefers-color-scheme support (I89552671) · Gerrit Code Review. I didn't really understand what this was about (as my test for it still seems to pass) - but now that I have a reproducer, I'll take a look if there's some kind of workaround I could add. From a quick test, this seems to work: diff --git i/qutebrowser/browser/webengine/darkmode.py w/qutebrowser/browser/webengine/darkmode.py
index ffc14c7e3..7f4d31c0b 100644
--- i/qutebrowser/browser/webengine/darkmode.py
+++ w/qutebrowser/browser/webengine/darkmode.py
@@ -273,6 +273,8 @@ def settings() -> Iterator[Tuple[str, str]]:
# will need to be set to '0' instead:
# https://chromium-review.googlesource.com/c/chromium/src/+/2232922
yield "preferredColorScheme", "1"
+ else:
+ yield "preferredColorScheme", "2"
if not config.val.colors.webpage.darkmode.enabled:
return
which can be replicated by setting |
Uhm, it doesn't seem to work with 1.14.1. I'll try later with 2.0. |
My bad - that should be |
Yes, that works, thanks.
I also tested `colors.webpage.darkmode` and indeed it interferes with
prefers-color-scheme: if true it reverts to the "no preference" behavior.
|
I tried with this patch on 1.14.1 diff --git a/qutebrowser/config/qtargs.py b/qutebrowser/config/qtargs.py
index 06df54a2f..89f01da49 100644
--- a/qutebrowser/config/qtargs.py
+++ b/qutebrowser/config/qtargs.py
@@ -79,15 +79,17 @@ def _darkmode_prefix() -> str:
def _darkmode_settings() -> typing.Iterator[typing.Tuple[str, str]]:
"""Get necessary blink settings to configure dark mode for QtWebEngine."""
- if (qtutils.version_check('5.15.2', compiled=False) and
- config.val.colors.webpage.prefers_color_scheme_dark):
+ if qtutils.version_check('5.15.2', compiled=False):
# With older Qt versions, this is passed in qtargs.py as --force-dark-mode
# instead.
#
# With Chromium 85 (> Qt 5.15.2), the enumeration has changed in Blink and this
# will need to be set to '0' instead:
# https://chromium-review.googlesource.com/c/chromium/src/+/2232922
- yield "preferredColorScheme", "1"
+ if config.val.colors.webpage.prefers_color_scheme_dark:
+ yield "preferredColorScheme", "1"
+ else:
+ yield "preferredColorScheme", "2"
if not config.val.colors.webpage.darkmode.enabled:
return It works but |
I'll need to check if there's something I can do about that. Either way, this will be fixed properly with the next QtWebEngine release. Removing this from v2.0.2 for now as it's not a regression in qutebrowser. |
Uhm, it will probably take a long while since 5.15.3 is unsuable due to the (stupid) licensing and 6.0 is not stable yet. |
Like mentioned in Qt's announcement, Qt WebEngine 5.15.3 will be a normal open source release. |
After thinking about it a bit more, I don't think the fix above is correct. The default by QtWebEngine/Chromium isn't "light" - it's auto-detection based on the OS' colorscheme. I don't think we can easily replicate that in qutebrowser, but I suppose we could replace the |
Makes sense to me, given in CSS |
Note that the
However, Chromium reads a system-wide setting, so I'd like to keep the "auto" value as well, rather than hardcoding "light" as default. |
Due to https://bugreports.qt.io/browse/QTBUG-89753, Qt 5.15.2 matches no-preference instead of doing auto-detection. However, no-preference was removed from the CSSWG spec: w3c/csswg-drafts#3857 (comment) Thus, if we are on a buggy Qt version with no auto-detection possible, always assume "light". Quoting the spec (emphasis mine): light: Indicates that user has expressed the preference for a page that has a light theme (dark text on light background), *or has not expressed an active preference* (and thus should receive the "web default" of a light theme). Fixes #6097 See #6147 (comment)
Could you try the |
Sure, I'll give it a try tomorrow. thank you.
|
I just tested the dev branch with Qt 5.15.2 (chromium 83):
Note that this works:
|
Works fine for me. Make sure you do something like If it still doesn't work after that, can you please show your |
Sorry, I figured I accidentally used an old nixpkgs checkout with pyqtwebengine at 5.15.0. Yes, I can confirm it works. |
No worries, thanks for the update! I've pushed everything to master now. I took another look at getting the workaround to work with darkmode, but no luck. No idea what causes it to break exactly, but it doesn't look like something qutebrowser could influence, unfortunately. I've also tested QtWebEngine 5.15.3 (or rather, the current 5.15 branch). There, they work well together again, but the behavior changed compared to Qt 5.14 and 5.15.0: The This looks like a Chromium bug, which I've reported here: 1177973 - "Force Dark Mode for Web Contents" breaks "prefers-color-scheme: dark" - chromium |
Thank you for opening the upstream bug. |
It looks like that behavior is intended, unfortunately: https://bugs.chromium.org/p/chromium/issues/detail?id=1177973#c4 On the positive side, that gave me a possible hint for #5542 🙂 |
I just came across this change. |
I'm not sure https://bugs.chromium.org/p/chromium/issues/detail?id=1177973 was really fixed. |
I've been testing with prefers-color-scheme.html and something like:
|
It seem there is some recoloring going on, the preference are working corretly, though.
|
Description
I think the meaning of the option
colors.webpage.prefers_color_scheme_dark
has changed in a recent qute/Qt update.On Qt 5.15.0, setting
prefers_color_scheme_dark
to false results in the "light" scheme being the preferred one. The same is not true on Qt 5.15.2: noprefers-color-scheme
media query matches anymore.Reproducing
You can test by running
with the following html page:
Version information
good version:
bad version:
The text was updated successfully, but these errors were encountered: