allow 1 of the syscon entries to be marked iwth is_main=2 as the

"default" one so if you press the binding that broung syscon up again
while syscon is up - and later than 0.5 seconds after syscon came up
and more than 2 times, then it execs that default action (eg power
down, suspend etc.)



SVN revision: 63831
This commit is contained in:
Carsten Haitzler 2011-10-05 09:39:39 +00:00
parent 9464f17dd1
commit a0781f02c4
5 changed files with 190 additions and 46 deletions

View File

@ -1,4 +1,47 @@
group "E_Config" struct {
group "syscon.actions" list {
group "E_Config_Syscon_Action" struct {
value "action" string: "halt";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-shutdown";
value "is_main" int: 1;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "suspend";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-suspend";
value "is_main" int: 2;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "desk_lock";
value "button" string: "button";
value "icon" string: "system-lock-screen";
value "is_main" int: 1;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "reboot";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-restart";
value "is_main" int: 0;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "hibernate";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-suspend-hibernate";
value "is_main" int: 0;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "logout";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-log-out";
value "is_main" int: 0;
}
}
group "modules" list {
group "E_Config_Module" struct {
value "name" string: "comp";
@ -1434,49 +1477,6 @@ group "E_Config" struct {
value "icon" string: "DESKTOP";
}
}
group "syscon.actions" list {
group "E_Config_Syscon_Action" struct {
value "action" string: "halt";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-shutdown";
value "is_main" int: 1;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "suspend";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-suspend";
value "is_main" int: 1;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "desk_lock";
value "button" string: "button";
value "icon" string: "system-lock-screen";
value "is_main" int: 1;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "reboot";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-restart";
value "is_main" int: 0;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "hibernate";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-suspend-hibernate";
value "is_main" int: 0;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "logout";
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-log-out";
value "is_main" int: 0;
}
}
value "config_version" int: 65847;
value "show_splash" int: 1;
value "init_default_theme" string: "default.edj";

View File

@ -5,7 +5,7 @@ group "E_Config" struct {
value "params" string: "now";
value "button" string: "button";
value "icon" string: "system-shutdown";
value "is_main" int: 1;
value "is_main" int: 2;
}
group "E_Config_Syscon_Action" struct {
value "action" string: "suspend";

View File

@ -446,6 +446,56 @@ e_bindings_key_up_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_Even
return NULL;
}
EAPI E_Action *
e_bindings_key_down_event_find(E_Binding_Context ctxt, Ecore_Event_Key *ev)
{
E_Binding_Modifier mod = 0;
E_Binding_Key *bind;
Eina_List *l;
mod = _e_bindings_modifiers(ev->modifiers);
EINA_LIST_FOREACH(key_bindings, l, bind)
{
if ((bind->key) && (!strcmp(bind->key, ev->keyname)) &&
((bind->any_mod) || (bind->mod == mod)))
{
if (_e_bindings_context_match(bind->ctxt, ctxt))
{
E_Action *act;
act = e_action_find(bind->action);
return act;
}
}
}
return NULL;
}
EAPI E_Action *
e_bindings_key_up_event_find(E_Binding_Context ctxt, Ecore_Event_Key *ev)
{
E_Binding_Modifier mod = 0;
E_Binding_Key *bind;
Eina_List *l;
mod = _e_bindings_modifiers(ev->modifiers);
EINA_LIST_FOREACH(key_bindings, l, bind)
{
if ((bind->key) && (!strcmp(bind->key, ev->keyname)) &&
((bind->any_mod) || (bind->mod == mod)))
{
if (_e_bindings_context_match(bind->ctxt, ctxt))
{
E_Action *act;
act = e_action_find(bind->action);
return act;
}
}
}
return NULL;
}
EAPI void
e_bindings_edge_add(E_Binding_Context ctxt, E_Zone_Edge edge, E_Binding_Modifier mod, int any_mod, const char *action, const char *params, float delay)
{

View File

@ -120,6 +120,8 @@ EAPI void e_bindings_key_grab(E_Binding_Context ctxt, Ecore_X_Window win)
EAPI void e_bindings_key_ungrab(E_Binding_Context ctxt, Ecore_X_Window win);
EAPI E_Action *e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_Event_Key *ev);
EAPI E_Action *e_bindings_key_up_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_Event_Key *ev);
EAPI E_Action *e_bindings_key_down_event_find(E_Binding_Context ctxt, Ecore_Event_Key *ev);
EAPI E_Action *e_bindings_key_up_event_find(E_Binding_Context ctxt, Ecore_Event_Key *ev);
EAPI void e_bindings_edge_add(E_Binding_Context ctxt, E_Zone_Edge edge, E_Binding_Modifier mod, int any_mod, const char *action, const char *params, float delay);
EAPI E_Binding_Edge *e_bindings_edge_get(const char *action, E_Zone_Edge edge, Eina_Bool click);

View File

@ -24,6 +24,8 @@ static Evas_Object *o_flow_secondary = NULL;
static Evas_Object *o_flow_extra = NULL;
static int inevas = 0;
static Ecore_Timer *deftimer = NULL;
static double show_time = 0.0;
static int act_count = 0;
/* externally accessible functions */
int
@ -47,8 +49,30 @@ e_syscon_show(E_Zone *zone, const char *defact)
int x, y, w, h, zx, zy, zw, zh;
int iw, ih;
Eina_List *l;
double t;
if (popup) return 0;
t = ecore_loop_time_get();
if (popup)
{
if ((t - show_time) > 0.5)
{
for (l = e_config->syscon.actions; l; l = l->next)
{
E_Config_Syscon_Action *sca;
E_Action *a;
if (!(sca = l->data)) continue;
if (!sca->action) continue;
a = e_action_find(sca->action);
if (!a) continue;
if (sca->is_main == 2)
{
a->func.go(NULL, sca->params);
}
}
}
return 0;
}
input_window = ecore_x_window_input_new(zone->container->win, zone->x,
zone->y, zone->w, zone->h);
@ -97,6 +121,9 @@ e_syscon_show(E_Zone *zone, const char *defact)
edje_object_signal_callback_add(o, "e,action,syscon", "*",
_cb_signal_syscon, NULL);
act_count = 0;
show_time = t;
// main (default):
// halt | suspend | desk_lock
// secondary (default):
@ -317,6 +344,71 @@ _cb_key_down(__UNUSED__ void *data, __UNUSED__ int type, void *event)
{
// FIXME: implement focus and key control... eventually
}
else if (!strcmp(ev->key, "Down"))
{
// FIXME: implement focus and key control... eventually
}
else if (!strcmp(ev->key, "Left"))
{
// FIXME: implement focus and key control... eventually
}
else if (!strcmp(ev->key, "Right"))
{
// FIXME: implement focus and key control... eventually
}
else if (!strcmp(ev->key, "Tab"))
{
// FIXME: implement focus and key control... eventually
}
else if (!strcmp(ev->key, "Enter"))
{
// FIXME: implement focus and key control... eventually
}
else
{
E_Action *act;
double t;
t = ecore_loop_time_get();
if (t - show_time > 0.5)
{
act = e_bindings_key_down_event_find(E_BINDING_CONTEXT_ANY, ev);
printf("%p\n", act);
if ((act) && (act->name))
{
printf("%s\n", act->name);
if (!strcmp(act->name, "syscon"))
{
if (popup)
{
printf("sy show again\n");
e_syscon_show(popup->zone, do_defact);
}
}
else
{
Eina_List *l;
for (l = e_config->syscon.actions; l; l = l->next)
{
E_Config_Syscon_Action *sca;
if (!(sca = l->data)) continue;
if (!sca->action) continue;
if (!strcmp(sca->action, act->name))
{
act_count++;
if (act_count > 2)
{
act->func.go(NULL, sca->params);
break;
}
}
}
}
}
}
}
return ECORE_CALLBACK_PASS_ON;
}