-
Notifications
You must be signed in to change notification settings - Fork 772
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
Fix various Dark/Light Theme inconsistencies #5583
Conversation
This looks like a great attempt to get dark/light theme working. Unfortunately even on a widely popular distro like Ubuntu it doesn't work (with the theme variant). In my case I get: I'm wondering if we could use the |
Or maybe consider the system preference as "dark" when the theme name contains the substring "dark" or the theme variant is dark. |
Yeah, I don't quite understand why it works with the Adwaita theme and not with others. |
Does it work for you if your session-wide theme is set to yaru-purple (and not yaru-purple-dark)? |
Now it should be working for themes like yaru (who have a -dark variant). |
Testing on MacOS I found that with the default theme (Adwaita) it works fine with "Force dark"/"Force light". The "Follow system theme" doesn't work (and I get "Adwaita", "light" all the time). Also when running with "GTK_THEME=Adwaita:dark" there is an inconsistency between icons and (dark) background when "Force dark theme" is set. Still it's a nice improvement over master. By the way the gsettings osascript -l JavaScript -e "Application('System Events').appearancePreferences.darkMode()" on MacOS. |
I think the Adwaita:dark can be fixed easily. The follow system theme issue, I have no idea. What's the terminal output is this case? |
I always get Theme name: Adwaita, Theme Variant: light when following the system theme, regardless of whether I use |
One question: Is it possible (in Linux) to react to theme (and dark-preference) changes, so that when a user changes the theme the appearence of Xournal++ changes automatically (without opening the preferences)? |
Hmm... So we probably can't get the dark/light information from the GtkSettings content on MacOS. Don't know where else to look. Do you know of a way to get access to the color-scheme? |
Probably, lemme try. |
This is now done. I also added a bit more terminal output to see if something can be done on MacOS. |
That's fantastic. Our users will love it! It works great on Ubuntu 24.04.
I will test it when I'm back home (on Saturday or Sunday). |
From https://gitlab.gnome.org/GNOME/gtk/blob/90d84a2af8b367bd5a5312b3fa3b67563462c0ef/gtk/gtksettings.c#L1567-L1622 So when we want to handle the case where the user (or e.g. a script in the AppImage) sets |
Nice find!! |
It works nicely on Linux. I will test on MacOS and Windows as well when I'm home. |
For Windows there are docs here how to determine the system dark mode preference: https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes#know-when-dark-mode-is-enabled |
I don't quite feel confident I can cook up something without being able to test it directly. Maybe you could write a commit for MacOS and one fo Windows and either append them to this PR or to a follow-up? |
I have added a commit for MacOS. It works for me (on MacOS Catalina). Turns out the Windows counterpart is more troublesome. The #include <winrt/Windows.UI.ViewManagement.h> must be included, which is not available by default. After installing mingw-w64-x86_64-cppwinrt the compiler complains that C++/WinRT requires coroutine support, which is currently missing and recommends to enable C++20 in the compiler. I don't think we want to do that at this moment. So Windows users will have to use "Force dark" or "Force light" in the settings and can't just follow the system theme. |
Thanks for the MacOS commit! As far as Windows is concerned, that fine by me. |
I think so, yes. |
Thanks a lot @rolandlo! |
Fixes #4336 Fixes #5422 Fixes #5445
This PR changes the "Dark theme" setting to become a combo box with 3 options: USE_SYSTEM, FORCE_LIGHT or FORCE_DARK.
With this, the gtk theme is always consistent with the icon set.
There are themes out there for which this does not work: e.g. breeze-gtk does not seem to allow the app to control its variant (dark/light) via gtk_settings::gtk-application-prefer-dark-theme.
For those users, the bug should be reported to the theme's maintainer or packager maybe.