tao
tao copied to clipboard
`ThemeChanged` event is emitted only once on macOS
Describe the bug
After launching a window, the first ThemeChanged event is emitted as expected. But the event will not be emitted after that.
Steps To Reproduce
- Run the following example
- A window starts
- Go to the menu bar → 'System Settings' → 'Appearance'
- Choose the different theme in 'Appearance Mode' pane. For example, when the current theme is 'Light', then choose 'Dark'
- Check
ThemeChangedevent was emited correctly in terminal output - Choose the different theme in 'Appearance Mode' pane again. This restores the original appearance mode
ThemeChangedevent is not emitted in terminal output
Expected behavior
ThemeChanged event should be emitted in terminal output
Screenshots
N/A
Platform and Versions (please complete the following information):
OS: macOS 13
Rustc: rustc 1.73.0 (cc66ad468 2023-10-03)
Would you want to assign yourself to resolve this bug?
- [ ] Yes
- [x] No
Additional context
I did some quick triage on this issue and confirmed the followings.
effectiveAppearanceDidChangedOnMainThreadnotification was sent correctly on each theme change repeatedlybestMatchFromAppearancesWithNamesmethod always returns the same appearance name after the first theme change. For example, when the first theme is 'Light', it returns"NSAppearanceNameAqua". After first theme change to 'Dark', it returns"NSAppearanceNameDarkAqua"correctly. However, after the second theme change to 'Light', it still returns the same value"NSAppearanceNameDarkAqua"- winit does not have this issue. It notifies
ThemeChangedevent repeatedly on each theme change. I tried to understand the difference between winit and tao regarding to this feature, but as far as I checked, the implementation was almost the same. They used the same macOS APIs. I could not locate the cause of this bug.
Sorry but I couldn't reproduce this issue. I've tried the example from tao's window example and wry's simple example.
Both will get the event if I tried to change the appearance between light and dark.
Though my macOS version is 14.
Thank you for your try. Hmm, the difference is that my macOS version is 13 and yours is 14. It may be an OS version-specific problem.