Bug 496513

Summary: After login, automatic dimming does not work until the dim time is changed in the KCM once
Product: [Plasma] plasmashell Reporter: reg.mail.clash869
Component: Power management & brightnessAssignee: Plasma Bugs List <plasma-bugs>
Status: REPORTED ---    
Severity: normal CC: jpetso, natalie_clarius, nate
Priority: NOR Keywords: regression
Version: 6.2.3   
Target Milestone: 1.0   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description reg.mail.clash869 2024-11-20 21:05:23 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY


STEPS TO REPRODUCE
1. Screen does not dim after the time determined in the power settings, after a system start or a reboot.
2. If you change the time for dimming the screen automatically to one of the other options, the automatic dimming works correctly again, for example, if you change from (standart option) two minutes to one minute, after one minute the screen dims automatically, and if you change it back to two minutes, it continues to work as expected (dims after two minutes). 
3. When you boot up the system or restart it, the automatic dim won't work again until you change to another time option in the power settings.

OBSERVED RESULT
Screen brightness does not dim

EXPECTED RESULT
Screen brightness should dim

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: openSUSE Tumbleweed
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.11.8-1-default (64 bits)

ADDITIONAL INFORMATION
In previous versions of KDE Plasma 6, automatic dim worked correctly.
Comment 1 Nate Graham 2024-11-21 17:31:25 UTC
Can reproduce exactly as described. Updating the title slightly.
Comment 2 Jakob Petsovits 2024-12-15 21:53:29 UTC
Git commit b6b563f732056b59d9ae83e5327039db22cad806 by Jakob Petsovits.
Committed on 15/12/2024 at 19:28.
Pushed by jpetso into branch 'master'.

daemon: Introduce proper dimming API for ScreenBrightnessController

This allows us to correctly restore brightness for displays that
were disconnected when they were dimmed, and are reconnected later.
It doesn't quite fix restoring dimmed displays across reboots yet,
this will be an extension requiring Wayland protocol updates.

`ScreenBrightnessController` now keeps track of more data for each
connected display, enough to recognize the display after it appears
again later (possibly with a different display ID) and restore some
runtime state.

This allows us to store and restore values for a display's
nominal brightness, minimum brightness, and dimming ratio.

The dimming ratio is multiplied with the nominal brightness and
capped by the minimum brightness to produce a display's desired
actual brightness. Several callers can set a dimming ratio,
the lowest one will be used. For now, the DimDisplay action is
the only user; however, other dimming methods are anticipated
in the future.

Importantly, by being able to restore these values separately
from just a single hardware brightness value, we can tell if the
display is still in the expected state from before the disconnect.
If it is, we can continue using the earlier nominal brightness but
update the dimming ratio to the current runtime setting.
Unrecognized or changed displays can remain untouched, they can be
assumed with a 1.0 dimming ratio from their current brightness level.

Note that this API is meant only for temporary dimming from the
baseline of the current nominal brightness. It isn't meant for
profile-dependent brightness changes or for ambient light sensors
driving gradual, automatic brightness adjustments. We can have
dedicated APIs later for these use cases.
Related: bug 452492

M  +20   -77   daemon/actions/bundled/dimdisplay.cpp
M  +1    -2    daemon/actions/bundled/dimdisplay.h
A  +38   -0    daemon/controllers/displaymatch.h     [License: LGPL(v2.0+)]
M  +90   -7    daemon/controllers/screenbrightnesscontroller.cpp
M  +40   -0    daemon/controllers/screenbrightnesscontroller.h

https://invent.kde.org/plasma/powerdevil/-/commit/b6b563f732056b59d9ae83e5327039db22cad806