static Eet_Data_Descriptor *_config_color_edd = NULL;
static Eet_Data_Descriptor *_config_color_palette_edd = NULL;
static Eet_Data_Descriptor *_config_color_overlay_edd = NULL;
+static Eet_Data_Descriptor *_config_bindings_widget_edd = NULL;
+static Eet_Data_Descriptor *_config_binding_key_edd = NULL;
const char *_elm_preferred_engine = NULL;
Eina_List *_font_overlays_del = NULL;
Eina_List *_color_overlays_del = NULL;
static Ecore_Poller *_elm_cache_flush_poller = NULL;
+Eina_Hash *_elm_key_bindings = NULL;
+
const char *_elm_engines[] = {
"software_x11",
"fb",
return;
}
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config_Bindings_Widget);
+ eddc.func.str_direct_alloc = NULL;
+ eddc.func.str_direct_free = NULL;
+
+ _config_bindings_widget_edd = eet_data_descriptor_stream_new(&eddc);
+ if (!_config_bindings_widget_edd)
+ {
+ ERR("EEEK! eet_data_descriptor_stream_new() failed.");
+ eet_data_descriptor_free(_config_edd);
+ return;
+ }
+
+ memset(&eddc, 0, sizeof(eddc)); /* just in case... */
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config_Binding_Key);
+ eddc.func.str_direct_alloc = NULL;
+ eddc.func.str_direct_free = NULL;
+
+ _config_binding_key_edd = eet_data_descriptor_stream_new(&eddc);
+ if (!_config_binding_key_edd)
+ {
+ ERR("EEEK! eet_data_descriptor_stream_new() failed.");
+ eet_data_descriptor_free(_config_edd);
+ return;
+ }
+
#define T_INT EET_T_INT
#define T_DOUBLE EET_T_DOUBLE
#define T_STRING EET_T_STRING
#undef T
#undef D
+#define T Elm_Config_Bindings_Widget
+#define D _config_bindings_widget_edd
+ ELM_CONFIG_VAL(D, T, name, EET_T_STRING);
+ ELM_CONFIG_LIST(D, T, key_bindings, _config_binding_key_edd);
+#undef T
+#undef D
+
+#define T Elm_Config_Binding_Key
+#define D _config_binding_key_edd
+ ELM_CONFIG_VAL(D, T, context, EET_T_INT);
+ ELM_CONFIG_VAL(D, T, modifiers, EET_T_STRING);
+ ELM_CONFIG_VAL(D, T, key, EET_T_STRING);
+ ELM_CONFIG_VAL(D, T, action, EET_T_STRING);
+ ELM_CONFIG_VAL(D, T, params, EET_T_STRING);
+ ELM_CONFIG_VAL(D, T, any_mod, EET_T_UCHAR);
+#undef T
+#undef D
+
#define T Elm_Config
#define D _config_edd
ELM_CONFIG_VAL(D, T, config_version, T_INT);
ELM_CONFIG_VAL(D, T, audio_mute_input, T_UCHAR);
ELM_CONFIG_VAL(D, T, audio_mute_alert, T_UCHAR);
ELM_CONFIG_VAL(D, T, audio_mute_all, T_UCHAR);
+ ELM_CONFIG_LIST(D, T, bindings, _config_bindings_widget_edd);
#undef T
#undef D
#undef T_INT
eet_data_descriptor_free(_config_color_overlay_edd);
_config_color_overlay_edd = NULL;
}
+
+ if (_config_bindings_widget_edd)
+ {
+ eet_data_descriptor_free(_config_bindings_widget_edd);
+ _config_bindings_widget_edd = NULL;
+ }
+
+ if (_config_binding_key_edd)
+ {
+ eet_data_descriptor_free(_config_binding_key_edd);
+ _config_binding_key_edd = NULL;
+ }
}
static int
Elm_Custom_Palette *palette;
Elm_Color_RGBA *color;
char *color_class;
+ Elm_Config_Bindings_Widget *wb;
+ Elm_Config_Binding_Key *kb;
if (!cfg) return;
EINA_LIST_FREE(cfg->font_dirs, fontdir)
EINA_LIST_FREE(palette->color_list, color) free(color);
free(palette);
}
+ EINA_LIST_FREE(cfg->bindings, wb)
+ {
+ eina_stringshare_del(wb->name);
+ EINA_LIST_FREE(wb->key_bindings, kb)
+ {
+ eina_stringshare_del(kb->modifiers);
+ eina_stringshare_del(kb->key);
+ eina_stringshare_del(kb->action);
+ eina_stringshare_del(kb->params);
+ free(kb);
+ }
+ free(wb);
+ }
eina_stringshare_del(cfg->theme);
eina_stringshare_del(cfg->modules);
eina_stringshare_del(cfg->indicator_service_0);
if (s) _elm_config->magnifier_scale = _elm_atof(s);
}
+void
+_elm_config_key_binding_hash(void)
+{
+ Elm_Config_Bindings_Widget *wb;
+ Eina_List *l;
+
+ if (_elm_key_bindings)
+ eina_hash_free(_elm_key_bindings);
+
+ _elm_key_bindings = eina_hash_string_superfast_new(NULL);
+ EINA_LIST_FOREACH(_elm_config->bindings, l, wb)
+ {
+ eina_hash_add(_elm_key_bindings, wb->name, wb->key_bindings);
+ }
+}
+
+Eina_Bool
+_elm_config_key_binding_call(Evas_Object *obj,
+ const Evas_Event_Key_Down *ev,
+ const Elm_Action *actions)
+{
+ Elm_Config_Binding_Key *binding;
+ Eina_List *binding_list, *l;
+ int i = 0;
+
+ binding_list = eina_hash_find(_elm_key_bindings, elm_widget_type_get(obj));
+
+ if (binding_list)
+ {
+ EINA_LIST_FOREACH(binding_list, l, binding)
+ {
+ if (binding->key && (!strcmp(binding->key, ev->keyname))
+ && ((evas_key_modifier_is_set
+ (ev->modifiers, binding->modifiers)
+ || (binding->any_mod))))
+ {
+ while (actions[i].name)
+ {
+ if (!strcmp(binding->action, actions[i].name))
+ {
+ actions[i].func(obj, binding->params);
+ return EINA_TRUE;
+ }
+ i++;
+ }
+ break;
+ }
+ }
+ }
+ return EINA_FALSE;
+}
+
EAPI Eina_Bool
elm_config_mirrored_get(void)
{
_elm_config_color_overlay_apply();
_elm_recache();
_elm_clouseau_reload();
+ _elm_config_key_binding_hash();
}
void
_elm_rescale();
_elm_recache();
_elm_clouseau_reload();
+ _elm_config_key_binding_hash();
ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
}
_elm_rescale();
_elm_recache();
_elm_clouseau_reload();
+ _elm_config_key_binding_hash();
}
void
#endif
_desc_shutdown();
+
+ if (_elm_key_bindings)
+ eina_hash_free(_elm_key_bindings);
}
{NULL, NULL}
};
+void _key_action_toggle(Evas_Object *obj, const char *params);
+
+static const Elm_Action key_actions[] = {
+ {"toggle", _key_action_toggle},
+ {NULL, NULL}
+};
+
static void
_mirrored_set(Evas_Object *obj,
Eina_Bool rtl)
edje_object_message_signal_process(wd->resize_obj);
}
+void _key_action_toggle(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+ _panel_toggle(NULL, obj, NULL, NULL);
+}
+
static void
_elm_panel_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
{
-
Evas_Object *src = va_arg(*list, Evas_Object *);
Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
Evas_Event_Key_Down *ev = va_arg(*list, void *);
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
if (src != obj) return;
- if ((strcmp(ev->key, "Return")) &&
- (strcmp(ev->key, "KP_Enter")) &&
- (strcmp(ev->key, "space")))
- return;
-
- _panel_toggle(NULL, obj, NULL, NULL);
+ _elm_config_key_binding_call(obj, ev, key_actions);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
typedef struct _Elm_Theme_Files Elm_Theme_Files;
typedef struct _Edje_Signal_Data Edje_Signal_Data;
typedef struct _Elm_Config Elm_Config;
+typedef struct _Elm_Config_Bindings_Widget Elm_Config_Bindings_Widget;
+typedef struct _Elm_Config_Binding_Key Elm_Config_Binding_Key;
typedef struct _Elm_Module Elm_Module;
typedef struct _Elm_Datetime_Module_Data Elm_Datetime_Module_Data;
unsigned char audio_mute_input;
unsigned char audio_mute_alert;
unsigned char audio_mute_all;
+ Eina_List *bindings;
/* Not part of the EET file */
Eina_Bool is_mirrored : 1;
Eina_Bool translate : 1;
};
+struct _Elm_Config_Bindings_Widget
+{
+ const char *name;
+ Eina_List *key_bindings;
+};
+
+struct _Elm_Config_Binding_Key
+{
+ int context;
+ const char *modifiers;
+ const char *key;
+ const char *action;
+ const char *params;
+ unsigned char any_mod;
+};
+
struct _Elm_Module
{
int version;
Eina_Bool _elm_config_access_get(void);
void _elm_config_access_set(Eina_Bool is_access);
+Eina_Bool _elm_config_key_binding_call(Evas_Object *obj,
+ const Evas_Event_Key_Down *ev,
+ const Elm_Action *actions);
+
Elm_Font_Properties *_elm_font_properties_get(Eina_Hash **font_hash,
const char *font);
Eina_Hash *_elm_font_available_hash_add(Eina_Hash *font_hash,