Skip to content

Commit

Permalink
[powerkey] Do not differentiate long/short presses in display off. JB…
Browse files Browse the repository at this point in the history
…#39431

Whether a long press can even be detected in display off state varies from
one device to another and depending on whether the device is suspended or
not. This means behavior on power key press is not deterministic and
uniform across all devices as in some scenarios display power up begins
already on power key press and in others the power key has to be also
released before actions are taken.

Unless an attempt as been made to bind actions to long power key press
from display is off state, synthesize power key release immediately
after power key press event to terminate timer used to differentiate
between long and short presses.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Sep 21, 2017
1 parent 2416ce0 commit 208e530
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions powerkey.c
Expand Up @@ -2913,6 +2913,24 @@ pwrkey_datapipes_keypress_cb(gconstpointer const data)

/* Power key pressed */
pwrkey_stm_powerkey_pressed();

/* Some devices report both power key press and release
* already when the physical button is pressed down.
* Other devices wait for physical release before
* reporting key release. And in some devices it depends
* on whether the device is suspended or not.
*
* To normalize behavior in default configuration (i.e.
* begin display power up already on power key press
* without waiting for user to lift finger off the button):
* Synthetize key release, if no actions are bound to long
* power key press from display off state. */
if( pwrkey_stm_display_state == MCE_DISPLAY_OFF ) {
if( !pwrkey_actions_from_display_off.mask_long ) {
mce_log(LL_DEBUG, "powerkey release simulated");
pwrkey_stm_powerkey_released();
}
}
}
}
else if( ev->value == 0 ) {
Expand Down

0 comments on commit 208e530

Please sign in to comment.