forked from enlightenment/enlightenment
- the RESPONSE macro dosen't use HDL, so remove it
- remove reply_count from the macros as this is an e_remote thing and isn't used by the other types. e_remote seems to still be working, but some may want to check that - add E_Lib code in for key/mouse bindings. I've tested the list calls, add/del are untested at the moment. SVN revision: 16088
This commit is contained in:
parent
d31991de6f
commit
2cc1137cb7
|
@ -145,7 +145,7 @@ break;
|
|||
/**
|
||||
* Get event data for libe processing
|
||||
*/
|
||||
# define RESPONSE(__res, __store, HDL) \
|
||||
# define RESPONSE(__res, __store) \
|
||||
__store *__res = calloc(1, sizeof(__store)); \
|
||||
if (e->data) {
|
||||
#define END_RESPONSE(__res, __type) \
|
||||
|
@ -273,7 +273,6 @@ free(data);
|
|||
} \
|
||||
evas_list_free(dat); \
|
||||
} \
|
||||
reply_count++; \
|
||||
} \
|
||||
break;
|
||||
|
||||
|
@ -304,21 +303,30 @@ free(data);
|
|||
* Use END_INT3_STRING3_LIST to terminate the loop and free all data.
|
||||
*/
|
||||
#define INT3_STRING3_LIST(__v, HDL) \
|
||||
INT3_STRING3_LIST_START(__v, HDL) \
|
||||
INT3_STRING3_LIST_ITERATE(__v)
|
||||
|
||||
#define INT3_STRING3_LIST_START(__v, HDL) \
|
||||
case HDL: { \
|
||||
Evas_List *dat = NULL, *l; \
|
||||
if (e_ipc_codec_3int_3str_list_dec(e->data, e->size, &dat)) { \
|
||||
if (e_ipc_codec_3int_3str_list_dec(e->data, e->size, &dat)) {
|
||||
#define INT3_STRING3_LIST_ITERATE(__v) \
|
||||
for (l = dat; l; l = l->next) { \
|
||||
E_Ipc_3Int_3Str *__v; \
|
||||
__v = l->data;
|
||||
#define END_INT3_STRING3_LIST(__v) \
|
||||
END_INT3_STRING3_LIST_ITERATE(__v) \
|
||||
END_INT3_STRING3_LIST_START()
|
||||
|
||||
#define END_INT3_STRING3_LIST_ITERATE(__v) \
|
||||
free(__v->str1); \
|
||||
free(__v->str2); \
|
||||
free(__v->str3); \
|
||||
free(__v); \
|
||||
} \
|
||||
}
|
||||
#define END_INT3_STRING3_LIST_START() \
|
||||
evas_list_free(dat); \
|
||||
} \
|
||||
reply_count++; \
|
||||
} \
|
||||
break;
|
||||
|
||||
|
@ -358,20 +366,29 @@ free(data);
|
|||
* Use END_INT4_STRING2_LIST to terminate the loop and free all data.
|
||||
*/
|
||||
#define INT4_STRING2_LIST(__v, HDL) \
|
||||
INT4_STRING2_LIST_START(__v, HDL) \
|
||||
INT4_STRING2_LIST_ITERATE(__v)
|
||||
|
||||
#define INT4_STRING2_LIST_START(__v, HDL) \
|
||||
case HDL: { \
|
||||
Evas_List *dat = NULL, *l; \
|
||||
if (e_ipc_codec_4int_2str_list_dec(e->data, e->size, &dat)) { \
|
||||
if (e_ipc_codec_4int_2str_list_dec(e->data, e->size, &dat)) {
|
||||
#define INT4_STRING2_LIST_ITERATE(__v) \
|
||||
for (l = dat; l; l = l->next) { \
|
||||
E_Ipc_4Int_2Str *__v; \
|
||||
__v = l->data;
|
||||
#define END_INT4_STRING2_LIST(__v) \
|
||||
END_INT4_STRING2_LIST_ITERATE(__v) \
|
||||
END_INT4_STRING2_LIST_START()
|
||||
|
||||
#define END_INT4_STRING2_LIST_ITERATE(__v) \
|
||||
free(__v->str1); \
|
||||
free(__v->str2); \
|
||||
free(__v); \
|
||||
} \
|
||||
evas_list_free(dat); \
|
||||
evas_list_free(dat);
|
||||
#define END_INT4_STRING2_LIST_START() \
|
||||
} \
|
||||
reply_count++; \
|
||||
} \
|
||||
break;
|
||||
|
||||
|
@ -424,7 +441,6 @@ free(data);
|
|||
} \
|
||||
evas_list_free(dat); \
|
||||
} \
|
||||
reply_count++; \
|
||||
} \
|
||||
break;
|
||||
|
||||
|
@ -477,7 +493,6 @@ free(data);
|
|||
} \
|
||||
evas_list_free(dat); \
|
||||
} \
|
||||
reply_count++; \
|
||||
} \
|
||||
break;
|
||||
|
||||
|
@ -732,7 +747,7 @@ break;
|
|||
DECODE(e_ipc_codec_str_int_list_dec) {
|
||||
LIST();
|
||||
int count;
|
||||
RESPONSE(r, E_Response_Module_List, HDL);
|
||||
RESPONSE(r, E_Response_Module_List);
|
||||
|
||||
/* FIXME - this is a mess, needs to be merged into macros... */
|
||||
count = evas_list_count(dat);
|
||||
|
@ -798,7 +813,7 @@ break;
|
|||
END_STRING(s);
|
||||
#elif (TYPE == E_LIB_IN)
|
||||
STRING(s, HDL);
|
||||
RESPONSE(r, E_Response_Background_Get, HDL);
|
||||
RESPONSE(r, E_Response_Background_Get);
|
||||
r->file = strdup(s);
|
||||
END_RESPONSE(r, E_RESPONSE_BACKGROUND_GET);
|
||||
END_STRING(s);
|
||||
|
@ -1176,7 +1191,7 @@ break;
|
|||
END_STRING(s);
|
||||
#elif (TYPE == E_LIB_IN)
|
||||
STRING(s, HDL);
|
||||
RESPONSE(r, E_Response_Language_Get, HDL);
|
||||
RESPONSE(r, E_Response_Language_Get);
|
||||
r->lang = strdup(s);
|
||||
END_RESPONSE(r, E_RESPONSE_LANGUAGE_GET);
|
||||
END_STRING(s);
|
||||
|
@ -1253,7 +1268,7 @@ break;
|
|||
int count;
|
||||
char *type;
|
||||
int res;
|
||||
RESPONSE(r, E_Response_Dirs_List, HDL);
|
||||
RESPONSE(r, E_Response_Dirs_List);
|
||||
|
||||
/* FIXME - this is a mess, needs to be merged into macros... */
|
||||
count = evas_list_count(dat);
|
||||
|
@ -1991,7 +2006,6 @@ break;
|
|||
v->val3 = emb->button;
|
||||
v->val4 = emb->any_mod;
|
||||
END_SEND_INT4_STRING2_LIST(v, E_IPC_OP_BINDING_MOUSE_LIST_REPLY);
|
||||
#elif (TYPE == E_REMOTE_IN)
|
||||
#endif
|
||||
#undef HDL
|
||||
|
||||
|
@ -2053,6 +2067,36 @@ break;
|
|||
);
|
||||
}
|
||||
END_INT4_STRING2_LIST(v);
|
||||
#elif E_LIB_IN
|
||||
INT4_STRING2_LIST_START(v, HDL);
|
||||
{
|
||||
int count;
|
||||
RESPONSE(r, E_Response_Binding_Mouse_List);
|
||||
count = evas_list_count(dat);
|
||||
r->bindings = malloc(sizeof(E_Response_Binding_Mouse_Data *) * count);
|
||||
r->count = count;
|
||||
|
||||
count = 0;
|
||||
INT4_STRING2_LIST_ITERATE(v);
|
||||
{
|
||||
E_Response_Binding_Mouse_Data *d;
|
||||
|
||||
d = malloc(sizeof(E_Response_Binding_Mouse_Data));
|
||||
d->ctx = v->val1;
|
||||
d->button = v->val3;
|
||||
d->mod = v->val2;
|
||||
d->any_mod = v->val4;
|
||||
d->action = ((v->str1) ? strdup(v->str1) : NULL);
|
||||
d->params = ((v->str2) ? strdup(v->str2) : NULL);
|
||||
|
||||
r->bindings[count] = d;
|
||||
count++;
|
||||
}
|
||||
END_INT4_STRING2_LIST_ITERATE(v);
|
||||
/* this will leak, need to free the event data */
|
||||
END_RESPONSE(r, E_RESPONSE_BINDING_MOUSE_LIST);
|
||||
}
|
||||
END_INT4_STRING2_LIST_START();
|
||||
#endif
|
||||
#undef HDL
|
||||
|
||||
|
@ -2344,6 +2388,36 @@ break;
|
|||
);
|
||||
}
|
||||
END_INT3_STRING3_LIST(v);
|
||||
#elif E_LIB_IN
|
||||
INT3_STRING3_LIST_START(v, HDL);
|
||||
{
|
||||
int count = 0;
|
||||
RESPONSE(r, E_Response_Binding_Key_List);
|
||||
count = evas_list_count(dat);
|
||||
r->bindings = malloc(sizeof(E_Response_Binding_Key_Data *) * count);
|
||||
r->count = count;
|
||||
|
||||
count = 0;
|
||||
INT3_STRING3_LIST_ITERATE(v);
|
||||
{
|
||||
E_Response_Binding_Key_Data *d;
|
||||
|
||||
d = malloc(sizeof(E_Response_Binding_Key_Data));
|
||||
d->ctx = v->val1;
|
||||
d->key = ((v->str1) ? strdup(v->str1) : NULL);
|
||||
d->mod = v->val2;
|
||||
d->any_mod = v->val3;
|
||||
d->action = ((v->str2) ? strdup(v->str2) : NULL);
|
||||
d->params = ((v->str3) ? strdup(v->str3) : NULL);
|
||||
|
||||
r->bindings[count] = d;
|
||||
count++;
|
||||
}
|
||||
END_INT3_STRING3_LIST_ITERATE(v);
|
||||
/* this will leak, need to free the event data */
|
||||
END_RESPONSE(r, E_RESPONSE_BINDING_KEY_LIST);
|
||||
}
|
||||
END_INT3_STRING3_LIST_START();
|
||||
#endif
|
||||
#undef HDL
|
||||
|
||||
|
@ -4217,7 +4291,7 @@ break;
|
|||
END_STRING2(e_2str);
|
||||
#elif (TYPE == E_LIB_IN)
|
||||
STRING2(category, file, e_2str, HDL);
|
||||
RESPONSE(r, E_Response_Theme_Get, HDL);
|
||||
RESPONSE(r, E_Response_Theme_Get);
|
||||
r->file = strdup(file);
|
||||
r->category = strdup(category);
|
||||
END_RESPONSE(r, E_RESPONSE_THEME_GET);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=3:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifndef _E_H
|
||||
#define _E_H
|
||||
|
||||
|
@ -18,14 +21,40 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
typedef enum E_Lib_Binding_Context
|
||||
{
|
||||
E_LIB_BINDING_CONTEXT_NONE,
|
||||
E_LIB_BINDING_CONTEXT_UNKNOWN,
|
||||
E_LIB_BINDING_CONTEXT_BORDER,
|
||||
E_LIB_BINDING_CONTEXT_ZONE,
|
||||
E_LIB_BINDING_CONTEXT_CONTAINER,
|
||||
E_LIB_BINDING_CONTEXT_MANAGER,
|
||||
E_LIB_BINDING_CONTEXT_MENU,
|
||||
E_LIB_BINDING_CONTEXT_WINLIST,
|
||||
E_LIB_BINDING_CONTEXT_ANY
|
||||
} E_Lib_Binding_Context;
|
||||
|
||||
typedef struct _E_Response_Module_List E_Response_Module_List;
|
||||
typedef struct _E_Response_Module_Data E_Response_Module_Data;
|
||||
typedef struct _E_Response_Dirs_List E_Response_Dirs_List;
|
||||
typedef enum E_Lib_Binding_Modifier
|
||||
{
|
||||
E_LIB_BINDING_MODIFIER_NONE = 0,
|
||||
E_LIB_BINDING_MODIFIER_SHIFT = (1 << 0),
|
||||
E_LIB_BINDING_MODIFIER_CTRL = (1 << 1),
|
||||
E_LIB_BINDING_MODIFIER_ALT = (1 << 2),
|
||||
E_LIB_BINDING_MODIFIER_WIN = (1 << 3)
|
||||
} E_Lib_Binding_Modifier;
|
||||
|
||||
typedef struct _E_Response_Module_List E_Response_Module_List;
|
||||
typedef struct _E_Response_Module_Data E_Response_Module_Data;
|
||||
typedef struct _E_Response_Dirs_List E_Response_Dirs_List;
|
||||
typedef struct _E_Response_Background_Get E_Response_Background_Get;
|
||||
typedef struct _E_Response_Language_Get E_Response_Language_Get;
|
||||
typedef struct _E_Response_Theme_Get E_Response_Theme_Get;
|
||||
|
||||
typedef struct _E_Response_Binding_Mouse_List E_Response_Binding_Mouse_List;
|
||||
typedef struct _E_Response_Binding_Mouse_Data E_Response_Binding_Mouse_Data;
|
||||
typedef struct _E_Response_Binding_Key_List E_Response_Binding_Key_List;
|
||||
typedef struct _E_Response_Binding_Key_Data E_Response_Binding_Key_Data;
|
||||
|
||||
struct _E_Response_Module_List
|
||||
{
|
||||
E_Response_Module_Data **modules;
|
||||
|
@ -60,6 +89,38 @@ struct _E_Response_Language_Get
|
|||
char *lang;
|
||||
};
|
||||
|
||||
struct _E_Response_Binding_Key_List
|
||||
{
|
||||
E_Response_Binding_Key_Data **bindings;
|
||||
int count;
|
||||
};
|
||||
|
||||
struct _E_Response_Binding_Key_Data
|
||||
{
|
||||
E_Lib_Binding_Context ctx;
|
||||
char *key;
|
||||
E_Lib_Binding_Modifier mod;
|
||||
unsigned char any_mod : 1;
|
||||
char *action;
|
||||
char *params;
|
||||
};
|
||||
|
||||
struct _E_Response_Binding_Mouse_List
|
||||
{
|
||||
E_Response_Binding_Mouse_Data **bindings;
|
||||
int count;
|
||||
};
|
||||
|
||||
struct _E_Response_Binding_Mouse_Data
|
||||
{
|
||||
E_Lib_Binding_Context ctx;
|
||||
int button;
|
||||
E_Lib_Binding_Modifier mod;
|
||||
unsigned char any_mod : 1;
|
||||
char *action;
|
||||
char *params;
|
||||
};
|
||||
|
||||
extern EAPI int E_RESPONSE_MODULE_LIST;
|
||||
extern EAPI int E_RESPONSE_BACKGROUND_GET;
|
||||
extern EAPI int E_RESPONSE_LANGUAGE_GET;
|
||||
|
@ -74,6 +135,9 @@ extern EAPI int E_RESPONSE_ICON_DIRS_LIST;
|
|||
extern EAPI int E_RESPONSE_MODULE_DIRS_LIST;
|
||||
extern EAPI int E_RESPONSE_BACKGROUND_DIRS_LIST;
|
||||
|
||||
extern EAPI int E_RESPONSE_BINDING_KEY_LIST;
|
||||
extern EAPI int E_RESPONSE_BINDING_MOUSE_LIST;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -97,6 +161,19 @@ extern "C" {
|
|||
EAPI void e_lib_desktop_background_add (const int con, const int zone, const int desk_x, const int desk_y, const char *bgfile);
|
||||
EAPI void e_lib_desktop_background_del (const int con, const int zone, const int desk_x, const int desk_y);
|
||||
|
||||
/* key/mouse bindings */
|
||||
EAPI void e_lib_bindings_key_list (void);
|
||||
EAPI void e_lib_binding_key_del (unsigned int *context, unsigned int modifiers, const char *key,
|
||||
unsigned int any_mod, const char *action, const char *params);
|
||||
EAPI void e_lib_binding_key_add (unsigned int *context, unsigned int modifiers, const char *key,
|
||||
unsigned int any_mod, const char *action, const char *params);
|
||||
|
||||
EAPI void e_lib_bindings_mouse_list (void);
|
||||
EAPI void e_lib_binding_mouse_del (unsigned int *context, unsigned int modifiers, unsigned int button,
|
||||
unsigned int any_mod, const char *action, const char *params);
|
||||
EAPI void e_lib_binding_mouse_add (unsigned int *context, unsigned int modifiers, unsigned int button,
|
||||
unsigned int any_mod, const char *action, const char *params);
|
||||
|
||||
/* E current theme manipulation */
|
||||
EAPI void e_lib_theme_set (const char *category, const char *file);
|
||||
EAPI void e_lib_theme_get (const char *category);
|
||||
|
|
128
src/lib/e_main.c
128
src/lib/e_main.c
|
@ -51,6 +51,11 @@ static int _e_cb_server_data(void *data, int type, void *event);
|
|||
static void _e_cb_module_list_free(void *data, void *ev);
|
||||
static void _e_cb_dir_list_free(void *data __UNUSED__, void *ev);
|
||||
|
||||
static void e_lib_binding_key_handle(int hdl, unsigned int *context, unsigned int modifiers, const char *key,
|
||||
unsigned int any_mod, const char *action, const char *params);
|
||||
static void e_lib_binding_mouse_handle(int hdl, unsigned int *context, unsigned int modifiers, unsigned int button,
|
||||
unsigned int any_mod, const char *action, const char *params);
|
||||
|
||||
static Ecore_Ipc_Server *_e_ipc_server = NULL;
|
||||
|
||||
int E_RESPONSE_MODULE_LIST = 0;
|
||||
|
@ -67,6 +72,8 @@ int E_RESPONSE_ICON_DIRS_LIST = 0;
|
|||
int E_RESPONSE_MODULE_DIRS_LIST = 0;
|
||||
int E_RESPONSE_BACKGROUND_DIRS_LIST = 0;
|
||||
|
||||
int E_RESPONSE_BINDING_KEY_LIST = 0;
|
||||
int E_RESPONSE_BINDING_MOUSE_LIST = 0;
|
||||
|
||||
/*
|
||||
* initialise connection to the current E running on "display".
|
||||
|
@ -153,6 +160,8 @@ e_lib_init(const char* display)
|
|||
E_RESPONSE_MODULE_DIRS_LIST = ecore_event_type_new();
|
||||
E_RESPONSE_BACKGROUND_DIRS_LIST = ecore_event_type_new();
|
||||
|
||||
E_RESPONSE_BINDING_KEY_LIST = ecore_event_type_new();
|
||||
E_RESPONSE_BINDING_MOUSE_LIST = ecore_event_type_new();
|
||||
}
|
||||
|
||||
if (free_disp)
|
||||
|
@ -390,6 +399,125 @@ e_lib_background_dirs_list(void)
|
|||
_e_ipc_call(E_IPC_OP_DIRS_LIST, &type);
|
||||
}
|
||||
|
||||
void
|
||||
e_lib_bindings_key_list(void)
|
||||
{
|
||||
_e_ipc_call(E_IPC_OP_BINDING_KEY_LIST, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
e_lib_binding_key_handle(int hdl, unsigned int *context, unsigned int modifiers, const char *key,
|
||||
unsigned int any_mod, const char *action, const char *key_params)
|
||||
{
|
||||
char buf[256];
|
||||
char *params[6];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
params[i] = calloc(5, sizeof(char));
|
||||
|
||||
snprintf(buf, 256, "%d", context);
|
||||
params[0] = strdup(buf);
|
||||
|
||||
snprintf(buf, 256, "%d", modifiers);
|
||||
params[1] = strdup(buf);
|
||||
|
||||
params[2] = strdup(key);
|
||||
|
||||
snprintf(buf, 256, "%d", any_mod);
|
||||
params[3] = strdup(buf);
|
||||
|
||||
params[4] = strdup(action);
|
||||
params[5] = strdup(key_params);
|
||||
|
||||
if ((!params[0]) || (!params[1]) || (!params[2])
|
||||
|| (!params[3]) || (!params[4]) || (!params[5]))
|
||||
return;
|
||||
|
||||
_e_ipc_call(hdl, params);
|
||||
|
||||
free(params[0]);
|
||||
free(params[1]);
|
||||
free(params[2]);
|
||||
free(params[3]);
|
||||
free(params[4]);
|
||||
free(params[5]);
|
||||
}
|
||||
|
||||
void
|
||||
e_lib_binding_key_del(unsigned int *context, unsigned int modifiers, const char *key,
|
||||
unsigned int any_mod, const char *action, const char *params)
|
||||
{
|
||||
e_lib_binding_key_handle(E_IPC_OP_BINDING_KEY_DEL, context, modifiers, key, any_mod, action, params);
|
||||
}
|
||||
|
||||
void
|
||||
e_lib_binding_key_add(unsigned int *context, unsigned int modifiers, const char *key,
|
||||
unsigned int any_mod, const char *action, const char *params)
|
||||
{
|
||||
e_lib_binding_key_handle(E_IPC_OP_BINDING_KEY_ADD, context, modifiers, key, any_mod, action, params);
|
||||
}
|
||||
|
||||
void
|
||||
e_lib_bindings_mouse_list(void)
|
||||
{
|
||||
_e_ipc_call(E_IPC_OP_BINDING_MOUSE_LIST, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
e_lib_binding_mouse_handle(int hdl, unsigned int *context, unsigned int modifiers, unsigned int button,
|
||||
unsigned int any_mod, const char *action, const char *mouse_params)
|
||||
{
|
||||
char buf[256];
|
||||
char *params[6];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
params[i] = calloc(5, sizeof(char));
|
||||
|
||||
snprintf(buf, 256, "%d", context);
|
||||
params[0] = strdup(buf);
|
||||
|
||||
snprintf(buf, 256, "%d", modifiers);
|
||||
params[1] = strdup(buf);
|
||||
|
||||
snprintf(buf, 256, "%d", button);
|
||||
params[2] = strdup(buf);
|
||||
|
||||
snprintf(buf, 256, "%d", any_mod);
|
||||
params[3] = strdup(buf);
|
||||
|
||||
params[4] = strdup(action);
|
||||
params[5] = strdup(mouse_params);
|
||||
|
||||
if ((!params[0]) || (!params[1]) || (!params[2])
|
||||
|| (!params[3]) || (!params[4]) || (!params[5]))
|
||||
return;
|
||||
|
||||
_e_ipc_call(hdl, params);
|
||||
|
||||
free(params[0]);
|
||||
free(params[1]);
|
||||
free(params[2]);
|
||||
free(params[3]);
|
||||
free(params[4]);
|
||||
free(params[5]);
|
||||
}
|
||||
|
||||
void
|
||||
e_lib_binding_mouse_del(unsigned int *context, unsigned int modifiers, unsigned int button,
|
||||
unsigned int any_mod, const char *action, const char *params)
|
||||
{
|
||||
e_lib_binding_mouse_handle(E_IPC_OP_BINDING_MOUSE_DEL, context, modifiers, button, any_mod, action, params);
|
||||
}
|
||||
|
||||
void
|
||||
e_lib_binding_mouse_add(unsigned int *context, unsigned int modifiers, unsigned int button,
|
||||
unsigned int any_mod, const char *action, const char *params)
|
||||
{
|
||||
e_lib_binding_mouse_handle(E_IPC_OP_BINDING_MOUSE_ADD, context, modifiers, button, any_mod, action, params);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_ipc_init(const char *display)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue