Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rewrite powerkey handler to allow more flexible configuration
Taking double powerkey presses in use caused unconditional delay for
single press handling. The actions that could be configured to be taken
were not be differentiated based on display state, which made it
impossible do one thing from display off and another one from display on.
And since static configuration was used, changes did not take effect
without restarting mce.

Make possible actions as small and simple as possible. Allow combining
them freely to choose actions taken. Use separate action combinations
depending on whether display is on or off. Execute common parts of
single and double press actions immediately when 1st powerkey press
is released.

Allow more flexibility for using custom dbus actions by allowing user
configured method call to be made instead of signal broadcast.

Use dynamic runtime changeable settings instead of static configuration
from ini-files and add options to mcetool for changing all of them.

Use the new functionality to:
- apply device lock when double press is made from display on
- unblank and hide lockscreen when double press is made from display off

[mce] Rewrite powerkey handler to allow more flexible configuration. Fixes JB#23653
  • Loading branch information
spiiroin committed Oct 24, 2014
1 parent 0695840 commit 6154e96
Show file tree
Hide file tree
Showing 7 changed files with 2,757 additions and 1,126 deletions.
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -567,6 +567,9 @@ NORMALIZE_USES_SPC =\
modules/radiostates.h\
modules/sensor-gestures.c\
ofono-dbus-names.h\
powerkey.c\
powerkey.h\
powerkey.dot\
systemui/dbus-names.h\
tklock.c\
tklock.h\
Expand Down Expand Up @@ -616,8 +619,6 @@ NORMALIZE_USES_TAB =\
modules/proximity.c\
modules/proximity.h\
modules/radiostates.c\
powerkey.c\
powerkey.h\
systemui/tklock-dbus-names.h\

NORMALIZE_KNOWN := $(NORMALIZE_USES_SPC) $(NORMALIZE_USES_TAB)
Expand Down
50 changes: 50 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1482,6 +1482,56 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = "333",
},
{
.key = MCE_GCONF_POWERKEY_LONG_PRESS_DELAY,
.type = "i",
.def = G_STRINGIFY(DEFAULT_POWERKEY_LONG_DELAY),
},
{
.key = MCE_GCONF_POWERKEY_DOUBLE_PRESS_DELAY,
.type = "i",
.def = G_STRINGIFY(DEFAULT_POWERKEY_DOUBLE_DELAY),
},
{
.key = MCE_GCONF_POWERKEY_ACTIONS_SINGLE_ON,
.type = "s",
.def = DEFAULT_POWERKEY_ACTIONS_SINGLE_ON,
},
{
.key = MCE_GCONF_POWERKEY_ACTIONS_DOUBLE_ON,
.type = "s",
.def = DEFAULT_POWERKEY_ACTIONS_DOUBLE_ON,
},
{
.key = MCE_GCONF_POWERKEY_ACTIONS_LONG_ON,
.type = "s",
.def = DEFAULT_POWERKEY_ACTIONS_LONG_ON,
},
{
.key = MCE_GCONF_POWERKEY_ACTIONS_SINGLE_OFF,
.type = "s",
.def = DEFAULT_POWERKEY_ACTIONS_SINGLE_OFF,
},
{
.key = MCE_GCONF_POWERKEY_ACTIONS_DOUBLE_OFF,
.type = "s",
.def = DEFAULT_POWERKEY_ACTIONS_DOUBLE_OFF,
},
{
.key = MCE_GCONF_POWERKEY_ACTIONS_LONG_OFF,
.type = "s",
.def = DEFAULT_POWERKEY_ACTIONS_LONG_OFF,
},
{
.key = MCE_GCONF_POWERKEY_DBUS_ACTION1,
.type = "s",
.def = DEFAULT_POWERKEY_DBUS_ACTION1,
},
{
.key = MCE_GCONF_POWERKEY_DBUS_ACTION2,
.type = "s",
.def = DEFAULT_POWERKEY_DBUS_ACTION2,
},
{
.key = MCE_GCONF_MEMNOTIFY_WARNING_USED,
.type = "i",
Expand Down
65 changes: 0 additions & 65 deletions inifiles/mce.ini
Expand Up @@ -29,71 +29,6 @@ Modules=radiostates;filter-brightness-als;display;keypad;led;battery-upower;inac
# Timeout in milliseconds, default 800
HomeKeyLongDelay=800

[PowerKey]

# Timeout before keypress is regarded as a medium press
# This delay is used when powering up from charging
#
# Timeout in milliseconds, default 1000
PowerKeyMediumDelay=1000

# Timeout before keypress is regarded as a long press
#
# Timeout in milliseconds, default 1500
PowerKeyLongDelay=1500

# Timeout for double keypresses
#
# Timeout in milliseconds, default 500
PowerKeyDoubleDelay=500

# Short [power] behaviour
#
# WARNING:
# Setting short, long, and double press to disabled will make it
# near impossible to turn off your device without removing the battery!
#
# Valid options:
# disabled - do nothing on short press
# poweroff - shutdown device
# softpoweroff - enter soft poweroff mode
# tklock-lock - lock touchscreen/keypad lock if not locked
# tklock-unlock - unlock the touchscreen/keypad lock if locked
# tklock-both - lock the touchscreen/keypad if not locked,
# unlock the touchscreen/keypad lock if locked
# dbus-signal-<signal name> - send a D-Bus signal with the name <signal name>
PowerKeyShortAction=tklock-lock

# Long [power] behaviour
#
# Valid options:
# disabled - do nothing on long press
# poweroff - shutdown device <default>
# softpoweroff - enter soft poweroff mode
# tklock-lock - lock touchscreen/keypad lock if not locked
# tklock-unlock - unlock the touchscreen/keypad lock if locked
# tklock-both - lock the touchscreen/keypad if not locked,
# unlock the touchscreen/keypad lock if locked
# dbus-signal-<signal name> - send a D-Bus signal with the name <signal name>
PowerKeyLongAction=poweroff

# Double press [power] behaviour
# Note: the double press action is triggered on press, rather than release,
# to avoid the second press to be processed elsewhere before the
# double press action has taken place
#
# Valid options:
# disabled - do nothing on double press <default>
# poweroff - shutdown device
# softpoweroff - enter soft poweroff mode
# tklock-lock - lock touchscreen/keypad lock if not locked
# tklock-unlock - unlock the touchscreen/keypad lock if locked
# tklock-both - lock the touchscreen/keypad if not locked,
# unlock the touchscreen/keypad lock if locked
# dbus-signal-<signal name> - send a D-Bus signal with the name <signal name>
# PowerKeyDoubleAction=dbus-signal-powerkey_double_ind
PowerKeyDoubleAction=disabled

[SoftPowerOff]

# Charger connect policy
Expand Down

0 comments on commit 6154e96

Please sign in to comment.