Thanks for the reply. I tried again and find the issue can be reproduced only if the main window is either hidden, minimized, or located on a different desktop than the detached window.
Here, I minimized the main window and you can observe the detached window didn’t change color scheme with the system until the main window was un-minimized.
I expect the color scheme of Obsidian to switch as soon as the system setting changes, no matter what desktop space I am on.
Actual result
The color scheme only changes as soon as I go to the space where the main vault window is open.
Environment
SYSTEM INFO:
Obsidian version: v1.4.16
Installer version: v1.4.16
Operating system: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 23.2.0
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on
RECOMMENDATIONS:
none
Additional information
This always reproduces, on multiple machines.
I encounter this problem every day, as I frequently work with a second window that’s in a different space than the main window. Then I need to switch to the space with the main window and back in order for the color scheme to become consistent with the rest of the system.
Just want to confirm this issue occurs on Windows 10 as well, w/1.5.8 (asar+installer). Ever since I switched to “adapt to system”, I arrive at my desk in the morning with detached windows having the wrong color scheme until I switch focus to the main window, then everything changes color.
It appears the cause of the issue is that the window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", o) setup is only done in the main window, not in other windows. So if the main window is hidden, it doesn’t receive the event and the light/dark mode switch doesn’t happen.
Based on the way this is coded, I would expect it to have the same problem on all platforms. It isn’t even necessary for the main window to be on a different virtual desktop (on Windows), just that it not be visible, as Electron/Chromium delays certain events for hidden windows/documents. So the main window simply being hidden behind other windows suffices to repro it on Windows for me at least.
I’ve released a workaround for this in Pane Relief 0.5.3, for anyone still having this issue.
That the specific workaround code I used works to fix the issue (at least for me on Win 10), seems to confirm the cause is indeed the lack of change listeners in windows other than the main one.
I would suggest wrapping app.adaptTotheme with a debounce so that if multiple windows receive the event it doesn’t set the theme multiple times, once for each visible window. (Or alternately, have app.setTheme() check whether a change is actually needed, so it doesn’t repeat the change.)