MSzturc / ThinkpadAssistant

An Assistant Application that allows you to use all your Function Keys on a T-Series Thinkpad Laptop
122 stars 13 forks source link

Dark mode doesn't always sync with system settings #24

Closed simprecicchiani closed 4 years ago

simprecicchiani commented 4 years ago

When system is shut down with dark mode, ThinkpadAssistant hud keep this settings even if the system boots up in light mode (normal behaviour caused by automatic appearance setting).

Schermata 2020-06-02 alle 10 12 34
MSzturc commented 4 years ago

Im not able to reproduce this error on my system. I remind a bug like this in an older version of Thinkpad Assistant. Please try to reproduce it with 1.7.2

darkmode

simprecicchiani commented 4 years ago

It behaves correctly when switching between modes. The issue is presented when shutted down and then started with different appearance mode. (I'm on 1.7.1, I'll try the latest release and report back)

MSzturc commented 4 years ago

I've created a possible fix. Please check if this error still occurs. This fix is a bit hacky. It checks inside the rendering thread if darkmode is enabled. Normally you dont do it because it could cause shuttering in the rendering of the hud.

ThinkpadAssistant.app.zip

simprecicchiani commented 4 years ago

I don't really know how to test it because it happens when I shut down the computer in the evening and start it the next morning. I can provide a feedback not earlier than tomorrow.

hexart commented 4 years ago

I don't really know how to test it because it happens when I shut down the computer in the evening and start it the next morning. I can provide a feedback not earlier than tomorrow.

I've just experienced the same issue this morning as @simprecicchiani described. It reproduces only in the morning when you are using automantic system appearance.

hexart commented 4 years ago

I've created a possible fix. Please check if this error still occurs. This fix is a bit hacky. It checks inside the rendering thread if darkmode is enabled. Normally you dont do it because it could cause shuttering in the rendering of the hud.

ThinkpadAssistant.app.zip

It looks like that it doesn't solve this issue. I quit the official release and replaced this one and run, the hud is still in dark mode. I assume that TA needs to find out what the current system mode is when it starts or every time before HUD shows. It got to be a user level variable to save the system mode status.

Sniki commented 4 years ago

i agree as well, the problem is present, last time i used it was night time and dark mode was on automatically and the HUD was dark as well which is fine, today (daytime) system was set to white/light theme automatically because it was daytime and when i pressed the backlight key, i noticed the HUD was still dark instead of white as the theme is.

joshuaseltzer commented 4 years ago

Would you be able to implement a method (maybe in your App Delegate or something) that checks for sleep/wake to check the status of dark mode? I'm thinking you could watch for this notification: https://developer.apple.com/documentation/appkit/nsworkspacedidwakenotification

And then you can determine dark mode using a method described in one of the answers here, using NSAppearance: https://stackoverflow.com/questions/51672124/how-can-dark-mode-be-detected-on-macos-10-14

(I'm an iOS developer with strong Objective-C knowledge -- very little Swift experience -- so disregard this comment if I'm completely off base.)

MSzturc commented 4 years ago

Thx for the hint! As recommended by @joshuaseltzer I enhanced the code that detects which theme is currently active. This bug is fixed with v1.7.3

joshuaseltzer commented 4 years ago

Glad I was able to provide some useful hints! If I knew Swift I would have tried it myself and submitted a PR.

MSzturc commented 4 years ago

Tested today in the morning & it worked for me as intended!

Sniki commented 4 years ago

Tested today in the morning & it worked for me as intended!

Tested today as well, just a few minutes before Dark mode will turn on automatically, as soon as it turned on while using the laptop, i tested and it's working perfect.

Thank you @joshuaseltzer @MSzturc