-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
Add method to get "base" system UI color and system theme change callback. #87384
Conversation
7feeff7
to
1139068
Compare
848adcf
to
6d86579
Compare
6d86579
to
a32fc66
Compare
Added theme change callback support for the rest of platforms (except web). |
a32fc66
to
41fe445
Compare
90704c7
to
86f3c9d
Compare
There's an |
This seems to be a new addition, so I'm not sure if any real DE support it, but since it's D-Bus we probably should try reading it anyway. |
1f69bae
to
4e65493
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor feedback to address and the Android logic should be good to go!
4e65493
to
9a9ebed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Android section looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
I wonder if the "theme_change" methods/signals should be "system_theme_change" to make it clear that it's about the OS theme settings and not the Godot editor/project theme?
9a9ebed
to
8367b8c
Compare
Renamed callback to |
16dd61d
to
31ae2ac
Compare
Needs a rebase. |
31ae2ac
to
27bf128
Compare
…heme change callback.
27bf128
to
ee53ae2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally on Fedora 39 KDE X11, this returns a fully transparent color for both base and accent color (so nothing is visible):
extends Node2D
func _theme_upd():
print("Updating theme")
$ColorRectBack.color = DisplayServer.get_base_color()
print($ColorRectBack.color)
$ColorRectFront.color = DisplayServer.get_accent_color()
print($ColorRectFront.color)
func _ready():
DisplayServer.set_system_theme_change_callback(Callable(self, "_theme_upd"))
_theme_upd()
I'm using the Breeze Dark theme. The theme switch callback works (it's called if I switch system themes), but colors are still fully transparent.
Colors are supported only on macOS and Windows, there's no standard Linux API for this. |
Thanks! |
Implements
DisplayServer.get_base_color
to get default control background color (on macOS and Windows).Implements
DisplayServer.set_system_theme_change_callback
to set theme change callback (all platforms, except web, tested on Windows 11, macOS 14.2.1, PopOS, Android 14 and iOS 17.2).Note:
theme_change
callback is triggered by any OS UI style related change, it's not necessarily mean that dark/light mode was switched or accent/base color changed.