Created attachment 4400 fix dim on inactivity The property for brightness level on ac|battery is defined as g(u)int. But in xfpm-backlight.c the value is read to an uninitialized glong. On amd64 these type have different sizes (32bit vs. 64bit). Under certain conditions the high bits aren't zero and so the brightness level is read wrong. Attached is a patch that fixes this by initializing the variable dim_level to zero.
Hmhm, I'm a bit puzzled about this, in modern compilers, shouldn't variable be initialized at 0 anyway?
According to the C standard only static variables are initialized to zero. All normal variables have an undefined value. If in both usages of the value the same type was used then an initialisation wouldn't be necessary. But writing an gint to the memory of glong variable only overwrites the lower 32bits in this case and the high 32bit remain unchanged. So eihter the types have to be the same or the varibale needs to be initialized.
(In reply to comment #2) > So eihter the types have to be the same or the varibale needs to be > initialized. I think the former is more consistent (and consistent with other fixes of the same issues in other properties).
I can confirm that this patch fixes this bug for me on xfce 4.10 (xubuntu 12.10). This bug was causing the power manager to never dim my screen on battery, after applying the patch everything works as expected. When will this be fixed upstream?
Will this be fixed in the next version of XFCE? as it is currently xfce power manager is rather useless on 64-bit because of this problem, the screen dimming stuff just doesn't work at all.
Created attachment 4920 unify level brightness to gint This patch unify level's brightness to gint. With this previous patch that set dim_level = 0 is not more useful.
*** Bug 9629 has been marked as a duplicate of this bug. ***
(In reply to Klaus Flittner from comment #0) > Created attachment 4400 > fix dim on inactivity > > The property for brightness level on ac|battery is defined as g(u)int. But > in xfpm-backlight.c the value is read to an uninitialized glong. > > On amd64 these type have different sizes (32bit vs. 64bit). Under certain > conditions the high bits aren't zero and so the brightness level is read > wrong. > > Attached is a patch that fixes this by initializing the variable dim_level > to zero. Why is this patch not applied? It's obviously correct.
(In reply to Felipe Contreras from comment #8) > (In reply to Klaus Flittner from comment #0) > > Created attachment 4400 > > fix dim on inactivity > > > > The property for brightness level on ac|battery is defined as g(u)int. But > > in xfpm-backlight.c the value is read to an uninitialized glong. > > > > On amd64 these type have different sizes (32bit vs. 64bit). Under certain > > conditions the high bits aren't zero and so the brightness level is read > > wrong. > > > > Attached is a patch that fixes this by initializing the variable dim_level > > to zero. > > Why is this patch not applied? It's obviously correct. Because nobody takes care of xfpm currently?
Created attachment 5098 Change brightness level from glong to gint32 The "Backlight" RandR property is a 32-bit integer. This means that the int32 (gint32) type should be used to represent brightness levels. The attached patch does nothing else than changing the brightness level representation from glong to gint32. This fixes the screen auto-dimming issue and brightness panel plugin issue.
Pushed patch