Skip to content

Commit

Permalink
Use mce_gconf_track_xxx() helpers in tklock module
Browse files Browse the repository at this point in the history
Using helper functions for getting initial setting value and installing
change notifier callback allows bit more compact code and makes it a bit
more difficult to make obvious errors.

Initialize fallback values from named constants. When possible use
the same constants to initialize also the built-in config defaults.

No functional changes.
  • Loading branch information
spiiroin committed Mar 15, 2015
1 parent ab33cbf commit 0bf71f2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 48 deletions.
8 changes: 3 additions & 5 deletions builtin-gconf.c
Expand Up @@ -1199,8 +1199,7 @@ static const setting_t gconf_defaults[] =
.def = "1",
},
{
// MCE_GCONF_LPMUI_TRIGGERING @ tklock.h
.key = "/system/osso/dsm/locks/lpm_triggering",
.key = MCE_GCONF_LPMUI_TRIGGERING,
.type = "i",
.def = "1", // = LPMUI_TRIGGERING_FROM_POCKET
},
Expand Down Expand Up @@ -1306,10 +1305,9 @@ static const setting_t gconf_defaults[] =
.def = "0", // = DISPLAY_OFF_OVERRIDE_DISABLED
},
{
// MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH @ tklock.h
.key = "/system/osso/dsm/locks/tklock_blank_disable",
.key = MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
.type = "i",
.def = "0",
.def = G_STRINGIFY(DEFAULT_TK_AUTO_BLANK_DISABLE),
},
#ifdef ENABLE_DOUBLETAP_EMULATION
{
Expand Down
76 changes: 33 additions & 43 deletions tklock.c
Expand Up @@ -374,7 +374,7 @@ static gint doubletap_enable_mode = DBLTAP_ENABLE_DEFAULT;
static guint doubletap_enable_mode_cb_id = 0;

/** Flag: Disable automatic dim/blank from tklock */
static gint tklock_blank_disable = FALSE;
static gint tklock_blank_disable = DEFAULT_TK_AUTO_BLANK_DISABLE;
/** GConf notifier id for tracking tklock_blank_disable changes */
static guint tklock_blank_disable_id = 0;

Expand Down Expand Up @@ -2810,7 +2810,7 @@ static void tklock_uiexcept_begin(uiexctype_t type, int64_t linger)
* ========================================================================= */

/** Bitmap of automatic lpm triggering modes */
static gint tklock_lpmui_triggering = LPMUI_TRIGGERING_FROM_POCKET;
static gint tklock_lpmui_triggering = DEFAULT_LPMUI_TRIGGERING;

/** GConf notifier id for tklock_lpmui_triggering */
static guint tklock_lpmui_triggering_cb_id = 0;
Expand Down Expand Up @@ -3634,59 +3634,49 @@ static void tklock_gconf_cb(GConfClient *const gcc, const guint id,
static void tklock_gconf_init(void)
{
/* Config tracking for disabling automatic screen dimming/blanking
* while showing lockscreen. This is demo/debugging feature, so sane
* defaults must be used and no error checking is needed. */
mce_gconf_notifier_add(MCE_GCONF_LOCK_PATH,
MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
tklock_gconf_cb,
&tklock_blank_disable_id);

mce_gconf_get_int(MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
&tklock_blank_disable);
* while showing lockscreen. */
mce_gconf_track_int(MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
&tklock_blank_disable,
DEFAULT_TK_AUTO_BLANK_DISABLE,
tklock_gconf_cb,
&tklock_blank_disable_id);

/* Touchscreen/keypad autolock */
/* Since we've set a default, error handling is unnecessary */
mce_gconf_notifier_add(MCE_GCONF_LOCK_PATH,
MCE_GCONF_TK_AUTOLOCK_ENABLED_PATH,
tklock_gconf_cb,
&tk_autolock_enabled_cb_id);

mce_gconf_get_bool(MCE_GCONF_TK_AUTOLOCK_ENABLED_PATH,
&tk_autolock_enabled);
mce_gconf_track_bool(MCE_GCONF_TK_AUTOLOCK_ENABLED_PATH,
&tk_autolock_enabled,
DEFAULT_TK_AUTOLOCK,
tklock_gconf_cb,
&tk_autolock_enabled_cb_id);

/* Touchscreen/keypad double-tap gesture policy */
mce_gconf_notifier_add(MCE_GCONF_LOCK_PATH,
MCE_GCONF_TK_DOUBLE_TAP_GESTURE_PATH,
tklock_gconf_cb,
&doubletap_gesture_policy_cb_id);
mce_gconf_track_int(MCE_GCONF_TK_DOUBLE_TAP_GESTURE_PATH,
&doubletap_gesture_policy,
DBLTAP_ACTION_DEFAULT,
tklock_gconf_cb,
&doubletap_gesture_policy_cb_id);

mce_gconf_get_int(MCE_GCONF_TK_DOUBLE_TAP_GESTURE_PATH,
&doubletap_gesture_policy);
tklock_gconf_sanitize_doubletap_gesture_policy();

/** Touchscreen double tap gesture mode */
mce_gconf_notifier_add(MCE_GCONF_DOUBLETAP_PATH,
MCE_GCONF_DOUBLETAP_MODE,
tklock_gconf_cb,
&doubletap_enable_mode_cb_id);

mce_gconf_get_int(MCE_GCONF_DOUBLETAP_MODE, &doubletap_enable_mode);
mce_gconf_track_int(MCE_GCONF_DOUBLETAP_MODE,
&doubletap_enable_mode,
DBLTAP_ENABLE_DEFAULT,
tklock_gconf_cb,
&doubletap_enable_mode_cb_id);

/* Bitmap of automatic lpm triggering modes */
mce_gconf_notifier_add(MCE_GCONF_LOCK_PATH,
MCE_GCONF_LPMUI_TRIGGERING,
tklock_gconf_cb,
&tklock_lpmui_triggering_cb_id);

mce_gconf_get_int(MCE_GCONF_LPMUI_TRIGGERING, &tklock_lpmui_triggering);
mce_gconf_track_int(MCE_GCONF_LPMUI_TRIGGERING,
&tklock_lpmui_triggering,
DEFAULT_LPMUI_TRIGGERING,
tklock_gconf_cb,
&tklock_lpmui_triggering_cb_id);

/* Proximity can block touch input */
mce_gconf_notifier_add(MCE_GCONF_LOCK_PATH,
MCE_GCONF_PROXIMITY_BLOCKS_TOUCH,
tklock_gconf_cb,
&proximity_blocks_touch_cb_id);
mce_gconf_get_bool(MCE_GCONF_PROXIMITY_BLOCKS_TOUCH,
&proximity_blocks_touch);
mce_gconf_track_bool(MCE_GCONF_PROXIMITY_BLOCKS_TOUCH,
&proximity_blocks_touch,
PROXIMITY_BLOCKS_TOUCH_DEFAULT,
tklock_gconf_cb,
&proximity_blocks_touch_cb_id);
}

/** Remove gconf change notifiers
Expand Down
9 changes: 9 additions & 0 deletions tklock.h
Expand Up @@ -90,9 +90,18 @@ typedef enum
/** Path to the automatic tklock dim/blank disable GConf setting */
#define MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH MCE_GCONF_LOCK_PATH "/tklock_blank_disable"

/** Default value for MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH */
#define DEFAULT_TK_AUTO_BLANK_DISABLE 0

/** Automatic lpm triggering modes GConf setting */
# define MCE_GCONF_LPMUI_TRIGGERING MCE_GCONF_LOCK_PATH "/lpm_triggering"

/** Default value for MCE_GCONF_LPMUI_TRIGGERING
*
* Note: Keep this in sync with the entry in builtin-gconf.c
*/
#define DEFAULT_LPMUI_TRIGGERING LPMUI_TRIGGERING_FROM_POCKET

/** Proximity can block touch input GConf setting */
# define MCE_GCONF_PROXIMITY_BLOCKS_TOUCH MCE_GCONF_LOCK_PATH "/proximity_blocks_touch"

Expand Down

0 comments on commit 0bf71f2

Please sign in to comment.