/** * Handle debounced power button changing state. */ static void powerbtn_x86_changed(void) { if (pwrbtn_state == PWRBTN_STATE_BOOT_KB_RESET || pwrbtn_state == PWRBTN_STATE_INIT_ON || pwrbtn_state == PWRBTN_STATE_LID_OPEN || pwrbtn_state == PWRBTN_STATE_WAS_OFF) { /* Ignore all power button changes during an initial pulse */ CPRINTS("PB ignoring change"); return; } if (power_button_is_pressed()) { /* Power button pressed */ power_button_pressed(get_time().val); } else { /* Power button released */ if (pwrbtn_state == PWRBTN_STATE_EAT_RELEASE) { /* * Ignore the first power button release if we already * told the PCH the power button was released. */ CPRINTS("PB ignoring release"); pwrbtn_state = PWRBTN_STATE_IDLE; return; } power_button_released(get_time().val); } /* Wake the power button task */ task_wake(TASK_ID_POWERBTN); }
/** * plugin_notify: * @plugin: This class instance * * Notify the plugin that a key marked with ohm_plugin_conf_interested () * has it's value changed. * An enumerated numeric id rather than the key is returned for processing speed. */ static void plugin_notify (OhmPlugin *plugin, gint id, gint value) { if (id == CONF_BUTTON_LID_CHANGED) { if (value == 1) { lid_closed (plugin, TRUE); } else { lid_closed (plugin, FALSE); } } else if (id == CONF_BUTTON_POWER_CHANGED) { /* only match on button press, not release */ if (value == 1) { power_button_pressed (plugin); } } else if (id == CONF_TIMEOUTS_POWERDOWN_CHANGED) { /* only match on idle, not reset */ if (value == 1) { g_debug ("powerdown is 1, suspending"); system_is_idle (plugin); } } }