Skip to content

gsd: Fix keyboard backlight toggle state machines

Jian-Hong Pan requested to merge starnight/gnome-settings-daemon:I41 into master

Some laptops like ASUS UX550GE has a hotkey (Fn+F7) for keyboard backlight toggle. In this UX550GE, the hotkey not only switches on/off the keyboard backlight, but also increments the level of brightness from 1 to max 3. In this case, it will trigger the keyboard backlight StepUp and Toggle events and execute the handle_method_call_keyboard function of gsd_power_manager.c in GNOME settings daemon when the hotkey is pressed.

The ideal scenario of pressing hotkey should trigger the events like:

.. StepUp -> Toggle -> StepUp -> StepUp -> StepUp -> Toggle -> StepUp ..

However, we noticed the actual processes are:

.. StepUp -> Toggle -> Toggle -> StepUp -> StepUp -> StepUp -> Toggle ..

It triggers Toggle event two times between StepUp events.

We check the upower_kbd_toggle function called in handle_method_call_keyboard when the event is Toggle, and find out it checks only the state of old brightness without current brightness. That misses some other states changing.

So, here is the list of the Toggle Method's state machines:

  1. brightness_now: 0, brightness_old: 1 ~ max level of brightness -> toggle to old brightness
  2. brightness_now: 0, brightness_old: -1 or 0 -> toggle to max brightness
  3. brightness_now: 1 ~ max level of brightness, brightness_old: all -> toggle to 0 brightness

This commit fixes and implements the state machines. Closes #41 (closed)

Signed-off-by: Jian-Hong Pan jian-hong@endlessm.com

Edited by Jian-Hong Pan

Merge request reports