tao icon indicating copy to clipboard operation
tao copied to clipboard

`ThemeChanged` event is emitted only once on macOS

Open rhysd opened this issue 1 year ago • 2 comments

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

  1. Run the following example
  2. A window starts
  3. Go to the menu bar → 'System Settings' → 'Appearance'
  4. Choose the different theme in 'Appearance Mode' pane. For example, when the current theme is 'Light', then choose 'Dark'
  5. Check ThemeChanged event was emited correctly in terminal output
  6. Choose the different theme in 'Appearance Mode' pane again. This restores the original appearance mode
  7. ThemeChanged event 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.

  • effectiveAppearanceDidChangedOnMainThread notification was sent correctly on each theme change repeatedly
  • bestMatchFromAppearancesWithNames method 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 ThemeChanged event 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.

rhysd avatar Nov 05 '23 15:11 rhysd

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.

wusyong avatar Nov 12 '23 08:11 wusyong

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.

rhysd avatar Nov 12 '23 09:11 rhysd