shorne's mouse/key bindings ipc patch... :)

SVN revision: 15548
This commit is contained in:
Carsten Haitzler 2005-06-27 13:50:10 +00:00
parent 8f1323e5bd
commit b5ece28d8a
5 changed files with 905 additions and 919 deletions

View File

@ -76,138 +76,6 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
#define TYPE E_WM_IN
#include "e_ipc_handlers.h"
#undef TYPE
/* here to steal from to port over to the new e_ipc_handlers.h */
#if 0
case E_IPC_OP_BINDING_MOUSE_LIST:
{
Evas_List *bindings;
int bytes;
char *data;
bindings = e_config->mouse_bindings;
data = _e_ipc_mouse_binding_list_enc(bindings, &bytes);
ecore_ipc_client_send(e->client,
E_IPC_DOMAIN_REPLY,
E_IPC_OP_BINDING_MOUSE_LIST_REPLY,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
break;
case E_IPC_OP_BINDING_MOUSE_ADD:
{
E_Config_Binding_Mouse bind, *eb;
_e_ipc_mouse_binding_dec(e->data, e->size, &bind);
{
eb = e_config_binding_mouse_match(&bind);
if (!eb)
{
eb = E_NEW(E_Config_Binding_Key, 1);
e_config->mouse_bindings = evas_list_append(e_config->mouse_bindings, eb);
eb->context = bind.context;
eb->button = bind.button;
eb->modifiers = bind.modifiers;
eb->any_mod = bind.any_mod;
eb->action = strdup(bind.action);
eb->params = strdup(bind.params);
e_border_button_bindings_ungrab_all();
e_bindings_mouse_add(bind.context, bind.button, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_border_button_bindings_grab_all();
e_config_save_queue();
}
}
}
break;
case E_IPC_OP_BINDING_MOUSE_DEL:
{
E_Config_Binding_Mouse bind, *eb;
_e_ipc_mouse_binding_dec(e->data, e->size, &bind);
{
eb = e_config_binding_mouse_match(&bind);
if (eb)
{
e_config->mouse_bindings = evas_list_remove(e_config->mouse_bindings, eb);
IF_FREE(eb->action);
IF_FREE(eb->params);
IF_FREE(eb);
e_border_button_bindings_ungrab_all();
e_bindings_mouse_del(bind.context, bind.button, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_border_button_bindings_grab_all();
e_config_save_queue();
}
}
}
break;
case E_IPC_OP_BINDING_KEY_LIST:
{
Evas_List *bindings;
int bytes;
char *data;
bindings = e_config->key_bindings;
data = _e_ipc_key_binding_list_enc(bindings, &bytes);
ecore_ipc_client_send(e->client,
E_IPC_DOMAIN_REPLY,
E_IPC_OP_BINDING_KEY_LIST_REPLY,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
break;
case E_IPC_OP_BINDING_KEY_ADD:
{
E_Config_Binding_Key bind, *eb;
_e_ipc_key_binding_dec(e->data, e->size, &bind);
{
eb = e_config_binding_key_match(&bind);
if (!eb)
{
eb = E_NEW(E_Config_Binding_Key, 1);
e_config->key_bindings = evas_list_append(e_config->key_bindings, eb);
eb->context = bind.context;
eb->modifiers = bind.modifiers;
eb->any_mod = bind.any_mod;
eb->key = strdup(bind.key);
eb->action = strdup(bind.action);
eb->params = strdup(bind.params);
e_managers_keys_ungrab();
e_bindings_key_add(bind.context, bind.key, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_managers_keys_grab();
e_config_save_queue();
}
}
}
break;
case E_IPC_OP_BINDING_KEY_DEL:
{
E_Config_Binding_Key bind, *eb;
_e_ipc_key_binding_dec(e->data, e->size, &bind);
{
eb = e_config_binding_key_match(&bind);
if (eb)
{
e_config->key_bindings = evas_list_remove(e_config->key_bindings, eb);
IF_FREE(eb->key);
IF_FREE(eb->action);
IF_FREE(eb->params);
IF_FREE(eb);
e_managers_keys_ungrab();
e_bindings_key_del(bind.context, bind.key, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_managers_keys_grab();
e_config_save_queue();
}
}
}
break;
#endif
default:
break;
}
@ -220,55 +88,3 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
return 1;
}
#if 0
static void
_e_ipc_reply_double_send(Ecore_Ipc_Client *client, double val, int opcode)
{
void *data;
int bytes;
if ((data = e_ipc_codec_double_enc(val, &bytes)))
{
ecore_ipc_client_send(client,
E_IPC_DOMAIN_REPLY,
opcode,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
}
static void
_e_ipc_reply_int_send(Ecore_Ipc_Client *client, int val, int opcode)
{
void *data;
int bytes;
if ((data = e_ipc_codec_int_enc(val, &bytes)))
{
ecore_ipc_client_send(client,
E_IPC_DOMAIN_REPLY,
opcode,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
}
static void
_e_ipc_reply_2int_send(Ecore_Ipc_Client *client, int val1, int val2, int opcode)
{
void *data;
int bytes;
if ((data = e_ipc_codec_2int_enc(val1, val2, &bytes)))
{
ecore_ipc_client_send(client,
E_IPC_DOMAIN_REPLY,
opcode,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
}
#endif

View File

@ -15,6 +15,10 @@ static Eet_Data_Descriptor *_e_ipc_str_int_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_str_int_list_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_2str_int_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_2str_int_list_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_4int_2str_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_4int_2str_list_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_3int_3str_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_3int_3str_list_edd = NULL;
/* externally accessible functions */
int
@ -54,6 +58,28 @@ e_ipc_codec_init(void)
_e_ipc_2str_int_list_edd = E_CONFIG_DD_NEW("2str_int_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_2str_int_list_edd, E_Ipc_List, list, _e_ipc_2str_int_edd);
_e_ipc_4int_2str_edd = E_CONFIG_DD_NEW("4int_2str", E_Ipc_4Int_2Str);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val1, INT);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val2, INT);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val3, INT);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val4, INT);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, str1, STR);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, str2, STR);
_e_ipc_4int_2str_list_edd = E_CONFIG_DD_NEW("4int_2str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_4int_2str_list_edd, E_Ipc_List, list, _e_ipc_4int_2str_edd);
_e_ipc_3int_3str_edd = E_CONFIG_DD_NEW("3int_3str", E_Ipc_3Int_3Str);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, val1, INT);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, val2, INT);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, val3, INT);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, str1, STR);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, str2, STR);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, str3, STR);
_e_ipc_3int_3str_list_edd = E_CONFIG_DD_NEW("3int_3str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_3int_3str_list_edd, E_Ipc_List, list, _e_ipc_3int_3str_edd);
return 1;
}
@ -70,6 +96,10 @@ e_ipc_codec_shutdown(void)
E_CONFIG_DD_FREE(_e_ipc_str_int_list_edd);
E_CONFIG_DD_FREE(_e_ipc_2str_int_edd);
E_CONFIG_DD_FREE(_e_ipc_2str_int_list_edd);
E_CONFIG_DD_FREE(_e_ipc_4int_2str_edd);
E_CONFIG_DD_FREE(_e_ipc_4int_2str_list_edd);
E_CONFIG_DD_FREE(_e_ipc_3int_3str_edd);
E_CONFIG_DD_FREE(_e_ipc_3int_3str_list_edd);
}
int
@ -322,6 +352,98 @@ e_ipc_codec_2str_int_list_enc(Evas_List *list, int *size_ret)
return eet_data_descriptor_encode(_e_ipc_2str_int_list_edd, &dat, size_ret);
}
int
e_ipc_codec_4int_2str_dec(char *data, int bytes, E_Ipc_4Int_2Str **dest)
{
E_Ipc_4Int_2Str *dat;
if (!data) return 0;
dat = eet_data_descriptor_decode(_e_ipc_4int_2str_edd, data, bytes);
if (!dat) return 0;
if (dest) *dest = dat;
return 1;
}
void *
e_ipc_codec_4int_2str_enc(int val1, int val2, int val3, int val4, char *str1, char *str2, int *size_ret)
{
E_Ipc_4Int_2Str dat;
dat.val1 = val1;
dat.val2 = val2;
dat.val3 = val3;
dat.val4 = val4;
dat.str1 = str1;
dat.str2 = str2;
return eet_data_descriptor_encode(_e_ipc_4int_2str_edd, &dat, size_ret);
}
int
e_ipc_codec_4int_2str_list_dec(char *data, int bytes, Evas_List **dest)
{
E_Ipc_List *dat;
if (!data) return 0;
dat = eet_data_descriptor_decode(_e_ipc_4int_2str_list_edd, data, bytes);
if (!dat) return 0;
if (dest) *dest = dat->list;
free(dat);
return 1;
}
void *
e_ipc_codec_4int_2str_list_enc(Evas_List *list, int *size_ret)
{
E_Ipc_List dat;
dat.list = list;
return eet_data_descriptor_encode(_e_ipc_4int_2str_list_edd, &dat, size_ret);
}
int
e_ipc_codec_3int_3str_dec(char *data, int bytes, E_Ipc_3Int_3Str **dest)
{
E_Ipc_3Int_3Str *dat;
if (!data) return 0;
dat = eet_data_descriptor_decode(_e_ipc_3int_3str_edd, data, bytes);
if (!dat) return 0;
if (dest) *dest = dat;
return 1;
}
void *
e_ipc_codec_3int_3str_enc(int val1, int val2, int val3, char *str1, char *str2, char *str3, int *size_ret)
{
E_Ipc_3Int_3Str dat;
dat.val1 = val1;
dat.val2 = val2;
dat.val3 = val3;
dat.str1 = str1;
dat.str2 = str2;
dat.str3 = str3;
return eet_data_descriptor_encode(_e_ipc_3int_3str_edd, &dat, size_ret);
}
int
e_ipc_codec_3int_3str_list_dec(char *data, int bytes, Evas_List **dest)
{
E_Ipc_List *dat;
if (!data) return 0;
dat = eet_data_descriptor_decode(_e_ipc_3int_3str_list_edd, data, bytes);
if (!dat) return 0;
if (dest) *dest = dat->list;
free(dat);
return 1;
}
void *
e_ipc_codec_3int_3str_list_enc(Evas_List *list, int *size_ret)
{
E_Ipc_List dat;
dat.list = list;
return eet_data_descriptor_encode(_e_ipc_3int_3str_list_edd, &dat, size_ret);
}
/* local subsystem globals */

View File

@ -13,6 +13,8 @@ typedef struct _E_Ipc_Str_Int E_Ipc_Str_Int;
typedef struct _E_Ipc_Str_Int_List E_Ipc_Str_Int_List;
typedef struct _E_Ipc_2Str_Int E_Ipc_2Str_Int;
typedef struct _E_Ipc_2Str_Int_List E_Ipc_2Str_Int_List;
typedef struct _E_Ipc_4Int_2Str E_Ipc_4Int_2Str;
typedef struct _E_Ipc_3Int_3Str E_Ipc_3Int_3Str;
#else
#ifndef E_IPC_CODEC_H
@ -60,6 +62,17 @@ struct _E_Ipc_2Str_Int
int val;
};
struct _E_Ipc_4Int_2Str
{
int val1, val2, val3, val4;
char *str1, *str2;
};
struct _E_Ipc_3Int_3Str
{
int val1, val2, val3;
char *str1, *str2, *str3;
};
EAPI int e_ipc_codec_init(void);
EAPI void e_ipc_codec_shutdown(void);
@ -80,10 +93,21 @@ EAPI int e_ipc_codec_str_int_dec(char *data, int bytes, E_Ipc_Str_Int **des
EAPI void *e_ipc_codec_str_int_enc(char *str, int val, int *size_ret);
EAPI int e_ipc_codec_str_int_list_dec(char *data, int bytes, Evas_List **dest);
EAPI void *e_ipc_codec_str_int_list_enc(Evas_List *list, int *size_ret);
EAPI int e_ipc_codec_2str_int_dec(char *data, int bytes, E_Ipc_2Str_Int **dest);
EAPI void *e_ipc_codec_2str_int_enc(char *str1, char *str2, int val, int *size_ret);
EAPI int e_ipc_codec_2str_int_list_dec(char *data, int bytes, Evas_List **dest);
EAPI void *e_ipc_codec_2str_int_list_enc(Evas_List *list, int *size_ret);
EAPI int e_ipc_codec_4int_2str_dec(char *data, int bytes, E_Ipc_4Int_2Str **dest);
EAPI void *e_ipc_codec_4int_2str_enc(int val1, int val2, int val3, int val4, char *str1, char *str2, int *size_ret);
EAPI int e_ipc_codec_4int_2str_list_dec(char *data, int bytes, Evas_List **dest);
EAPI void *e_ipc_codec_4int_2str_list_enc(Evas_List *list, int *size_ret);
EAPI int e_ipc_codec_3int_3str_dec(char *data, int bytes, E_Ipc_3Int_3Str **dest);
EAPI void *e_ipc_codec_3int_3str_enc(int val1, int val2, int val3, char *str1, char *str2, char *str3, int *size_ret);
EAPI int e_ipc_codec_3int_3str_list_dec(char *data, int bytes, Evas_List **dest);
EAPI void *e_ipc_codec_3int_3str_list_enc(Evas_List *list, int *size_ret);
#endif
#endif

View File

@ -51,6 +51,43 @@ if (e->data) { \
} \
break;
/**
* INT3_STRING3:
* Decode event data of type E_Ipc_3Int_3Str
*/
# define INT3_STRING3(__3int_3str, HDL) \
case HDL: \
if (e->data) { \
E_Ipc_3Int_3Str *__3int_3str = NULL; \
__3int_3str = calloc(1, sizeof(E_Ipc_3Int_3Str)); \
if (e_ipc_codec_3int_3str_dec(e->data, e->size, &(__3int_3str))) {
# define END_INT3_STRING3(__3int_3str) \
free(__3int_3str->str1); \
free(__3int_3str->str2); \
free(__3int_3str->str3); \
free(__3int_3str); \
} \
} \
break;
/**
* INT4_STRING2:
* Decode event data of type E_Ipc_4Int_2Str
*/
# define INT4_STRING2(__4int_2str, HDL) \
case HDL: \
if (e->data) { \
E_Ipc_4Int_2Str *__4int_2str = NULL; \
__4int_2str = calloc(1, sizeof(E_Ipc_4Int_2Str)); \
if (e_ipc_codec_4int_2str_dec(e->data, e->size, &(__4int_2str))) {
# define END_INT4_STRING2(__4int_2str) \
free(__4int_2str->str1); \
free(__4int_2str->str2); \
free(__4int_2str); \
} \
} \
break;
# define STRING2_INT(__str1, __str2, __int, __2str_int, HDL) \
case HDL: \
if (e->data) { \
@ -130,6 +167,31 @@ case HDL: { void *data; int bytes; \
} \
break;
#define REQ_3INT_3STRING_START(HDL) \
case HDL: { void *data; int bytes; \
#define REQ_3INT_3STRING_END(__val1, __val2, __val3, __str1, __str2, __str3, HDL) \
data = e_ipc_codec_3int_3str_enc(__val1, __val2, __val3, __str1, __str2, __str3, &bytes); \
if (data) { \
ecore_ipc_server_send(e->server, E_IPC_DOMAIN_REQUEST, HDL, 0, 0, 0, data, bytes); \
free(data); \
} \
} \
break;
#define REQ_4INT_2STRING_START(HDL) \
case HDL: { void *data; int bytes; \
#define REQ_4INT_2STRING_END(__val1, __val2, __val3, __val4, __str1, __str2, HDL) \
data = e_ipc_codec_4int_2str_enc(__val1, __val2, __val3, __val4, __str1, __str2, &bytes); \
if (data) { \
ecore_ipc_server_send(e->server, E_IPC_DOMAIN_REQUEST, HDL, 0, 0, 0, data, bytes); \
free(data); \
} \
} \
break;
# define REQ_2STRING_INT(__str1, __str2, __int, HDL) \
case HDL: { void *data; int bytes; \
data = e_ipc_codec_2str_int_enc(__str1, __str2, __int, &bytes); \
@ -226,7 +288,126 @@ free(data);
} \
break;
# define STRING2_INT_LIST(__v, HDL) \
/**
* INT3_STRING3:
* Decode event data is a list of E_Ipc_3Int_3Str objects and iterate
* the list. For each iteration the object __v will contain a decoded list
* element.
*
* Use END_INT3_STRING3_LIST to terminate the loop and free all data.
*/
#define INT3_STRING3_LIST(__v, HDL) \
case HDL: { \
Evas_List *dat = NULL, *l; \
if (e_ipc_codec_3int_3str_list_dec(e->data, e->size, &dat)) { \
for (l = dat; l; l = l->next) { \
E_Ipc_3Int_3Str *__v; \
__v = l->data;
#define END_INT3_STRING3_LIST(__v) \
free(__v->str1); \
free(__v->str2); \
free(__v->str3); \
free(__v); \
} \
evas_list_free(dat); \
} else { \
printf("Decode FAILURE!!!\n"); \
} \
reply_count++; \
} \
break;
/**
* SEND_INT3_STRING3_LIST:
* Start to encode a list of objects to prepare them for sending via
* ipc. The object __v1 will be of type __typ1 and __v2 will be of type
* E_Ipc_3Int_3Str.
*
* Use END_SEND_INT3_STRING3_LIST to terminate the encode iteration and
* send that data. The list will be freed.
*/
#define SEND_INT3_STRING3_LIST(__list, __typ1, __v1, __v2, HDL) \
case HDL: { \
Evas_List *dat = NULL, *l; \
void *data; int bytes; \
for (l = __list; l; l = l->next) { \
__typ1 *__v1; \
E_Ipc_3Int_3Str *__v2; \
__v1 = l->data; \
__v2 = calloc(1, sizeof(E_Ipc_3Int_3Str));
#define END_SEND_INT3_STRING3_LIST(__v1, __op) \
dat = evas_list_append(dat, __v1); \
} \
data = e_ipc_codec_3int_3str_list_enc(dat, &bytes); \
SEND_DATA(__op); \
FREE_LIST(dat); \
} \
break;
/**
* INT4_STRING2:
* Decode event data is a list of E_Ipc_4Int_2Str objects and iterate
* the list. For each iteration the object __v will contain a decoded list
* element.
*
* Use END_INT4_STRING2_LIST to terminate the loop and free all data.
*/
#define INT4_STRING2_LIST(__v, HDL) \
case HDL: { \
Evas_List *dat = NULL, *l; \
if (e_ipc_codec_4int_2str_list_dec(e->data, e->size, &dat)) { \
for (l = dat; l; l = l->next) { \
E_Ipc_4Int_2Str *__v; \
__v = l->data;
#define END_INT4_STRING2_LIST(__v) \
free(__v->str1); \
free(__v->str2); \
free(__v); \
} \
evas_list_free(dat); \
} else { \
printf("Decode FAILURE!!!\n"); \
} \
reply_count++; \
} \
break;
/**
* SEND_INT4_STRING2_LIST:
* Start to encode a list of objects to prepare them for sending via
* ipc. The object __v1 will be of type __typ1 and __v2 will be of type
* E_Ipc_4Int_2Str.
*
* Use END_SEND_INT4_STRING2_LIST to terminate the encode iteration and
* send that data. The list will be freed.
*/
#define SEND_INT4_STRING2_LIST(__list, __typ1, __v1, __v2, HDL) \
case HDL: { \
Evas_List *dat = NULL, *l; \
void *data; int bytes; \
for (l = __list; l; l = l->next) { \
__typ1 *__v1; \
E_Ipc_4Int_2Str *__v2; \
__v1 = l->data; \
__v2 = calloc(1, sizeof(E_Ipc_4Int_2Str));
#define END_SEND_INT4_STRING2_LIST(__v1, __op) \
dat = evas_list_append(dat, __v1); \
} \
data = e_ipc_codec_4int_2str_list_enc(dat, &bytes); \
SEND_DATA(__op); \
FREE_LIST(dat); \
} \
break;
/**
* STRING2_INT_LIST:
* Decode event data which is a list of E_Ipc_2Str_Int objects and iterate
* the list. For each iteration the object __v will contain a decoded list
* element.
*
* Use END_STRING2_INT_LIST to terminate the loop and free all data.
*/
#define STRING2_INT_LIST(__v, HDL) \
case HDL: { \
Evas_List *dat = NULL, *l; \
if (e_ipc_codec_2str_int_list_dec(e->data, e->size, &dat)) { \
@ -244,6 +425,15 @@ free(data);
} \
break;
/**
* SEND_STRING2_INT_LIST:
* Start to encode a list of objects to prepare them for sending via
* ipc. The object __v1 will be of type __typ1 and __v2 will be of type
* E_Ipc_2Str_Int.
*
* Use END_SEND_STRING2_INT_LIST to terminate the encode iteration and
* send that data. The list will be freed.
*/
#define SEND_STRING2_INT_LIST(__list, __typ1, __v1, __v2, HDL) \
case HDL: { \
Evas_List *dat = NULL, *l; \
@ -1731,6 +1921,573 @@ break;
#endif
#undef HDL
/***************/
#define HDL E_IPC_OP_BINDING_MOUSE_LIST
#if (TYPE == E_REMOTE_OPTIONS)
/* e_remote define command line args */
OP("-binding-mouse-list", 0, "List all mouse bindings", 1, HDL)
#elif (TYPE == E_REMOTE_OUT)
/* e_remote parse command line args encode and send request */
REQ_NULL(HDL);
#elif (TYPE == E_WM_IN)
/* e_ipc decode request and do action or send reply */
SEND_INT4_STRING2_LIST(e_config->mouse_bindings, E_Config_Binding_Mouse, emb, v, HDL);
v->val1 = emb->context;
v->val2 = emb->modifiers;
v->str1 = emb->action;
v->str2 = emb->params;
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
/****************************************************************************/
#define HDL E_IPC_OP_BINDING_MOUSE_LIST_REPLY
#if (TYPE == E_REMOTE_OPTIONS)
#elif (TYPE == E_REMOTE_OUT)
#elif (TYPE == E_WM_IN)
#elif (TYPE == E_REMOTE_IN)
/* e_remote decode the response from e_ipc and print it to the console */
INT4_STRING2_LIST(v, HDL);
{
char *context;
char modifier[256];
if (v->val1 == E_BINDING_CONTEXT_NONE) context = "NONE";
else if (v->val1 == E_BINDING_CONTEXT_UNKNOWN) context = "UNKNOWN";
else if (v->val1 == E_BINDING_CONTEXT_BORDER) context = "BORDER";
else if (v->val1 == E_BINDING_CONTEXT_ZONE) context = "ZONE";
else if (v->val1 == E_BINDING_CONTEXT_MANAGER) context = "MANAGER";
else if (v->val1 == E_BINDING_CONTEXT_ANY) context = "ANY";
else context = "";
modifier[0] = 0;
if (v->val2 & E_BINDING_MODIFIER_SHIFT)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "SHIFT");
}
if (v->val2 & E_BINDING_MODIFIER_CTRL)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "CTRL");
}
if (v->val2 & E_BINDING_MODIFIER_ALT)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "ALT");
}
if (v->val2 & E_BINDING_MODIFIER_WIN)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "WIN");
}
if (v->val2 == E_BINDING_MODIFIER_NONE)
strcpy(modifier, "NONE");
printf("REPLY: BINDING CONTEXT=%s BUTTON=%i MODIFIERS=%s ANY_MOD=%i ACTION=\"%s\" PARAMS=\"%s\"\n",
context,
v->val3,
modifier,
v->val4,
v->str1,
v->str2
);
}
END_INT4_STRING2_LIST(v);
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_BINDING_MOUSE_ADD
#if (TYPE == E_REMOTE_OPTIONS)
/* e_remote define command line args */
OP("-binding-mouse-add", 6, "Add an existing mouse binding. OPT1 = Context, OPT2 = button, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 0, HDL)
#elif (TYPE == E_REMOTE_OUT)
/* e_remote parse command line args encode and send request */
REQ_4INT_2STRING_START(HDL);
E_Config_Binding_Mouse eb;
if (!strcmp(params[0], "NONE")) eb.context = E_BINDING_CONTEXT_NONE;
else if (!strcmp(params[0], "UNKNOWN")) eb.context = E_BINDING_CONTEXT_UNKNOWN;
else if (!strcmp(params[0], "BORDER")) eb.context = E_BINDING_CONTEXT_BORDER;
else if (!strcmp(params[0], "ZONE")) eb.context = E_BINDING_CONTEXT_ZONE;
else if (!strcmp(params[0], "MANAGER")) eb.context = E_BINDING_CONTEXT_MANAGER;
else if (!strcmp(params[0], "ANY")) eb.context = E_BINDING_CONTEXT_ANY;
else
{
printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
" NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
exit(-1);
}
eb.button = atoi(params[1]);
/* M1[|M2...] */
{
char *p, *pp;
eb.modifiers = 0;
pp = params[2];
for (;;)
{
p = strchr(pp, '|');
if (p)
{
if (!strncmp(pp, "SHIFT|", 6)) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strncmp(pp, "CTRL|", 5)) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strncmp(pp, "ALT|", 4)) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strncmp(pp, "WIN|", 4)) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
pp = p + 1;
}
else
{
if (!strcmp(pp, "SHIFT")) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strcmp(pp, "CTRL")) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strcmp(pp, "ALT")) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strcmp(pp, "WIN")) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (!strcmp(pp, "NONE")) eb.modifiers = E_BINDING_MODIFIER_NONE;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
break;
}
}
}
eb.any_mod = atoi(params[3]);
eb.action = params[4];
eb.params = params[5];
REQ_4INT_2STRING_END(eb.context, eb.modifiers, eb.button, eb.any_mod, eb.action, eb.params, HDL);
#elif (TYPE == E_WM_IN)
/* e_ipc decode request and do action */
INT4_STRING2(v, HDL)
E_Config_Binding_Mouse bind, *eb;
bind.context = v->val1;
bind.modifiers = v->val2;
bind.button = v->val3;
bind.any_mod = v->val4;
bind.action = v->str1;
bind.params = v->str2;
eb = e_config_binding_mouse_match(&bind);
if (!eb)
{
eb = E_NEW(E_Config_Binding_Key, 1);
e_config->mouse_bindings = evas_list_append(e_config->mouse_bindings, eb);
eb->context = bind.context;
eb->button = bind.button;
eb->modifiers = bind.modifiers;
eb->any_mod = bind.any_mod;
eb->action = strdup(bind.action);
eb->params = strdup(bind.params);
e_border_button_bindings_ungrab_all();
e_bindings_mouse_add(bind.context, bind.button, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_border_button_bindings_grab_all();
e_config_save_queue();
}
END_INT4_STRING2(v);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/*****/
/***************/
#define HDL E_IPC_OP_BINDING_MOUSE_DEL
#if (TYPE == E_REMOTE_OPTIONS)
/* e_remote define command line args */
OP("-binding-mouse-del", 6, "Delete an existing mouse binding. OPT1 = Context, OPT2 = button, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 0, HDL)
#elif (TYPE == E_REMOTE_OUT)
/* e_remote parse command line args encode and send request */
REQ_4INT_2STRING_START(HDL);
E_Config_Binding_Mouse eb;
if (!strcmp(params[0], "NONE")) eb.context = E_BINDING_CONTEXT_NONE;
else if (!strcmp(params[0], "UNKNOWN")) eb.context = E_BINDING_CONTEXT_UNKNOWN;
else if (!strcmp(params[0], "BORDER")) eb.context = E_BINDING_CONTEXT_BORDER;
else if (!strcmp(params[0], "ZONE")) eb.context = E_BINDING_CONTEXT_ZONE;
else if (!strcmp(params[0], "MANAGER")) eb.context = E_BINDING_CONTEXT_MANAGER;
else if (!strcmp(params[0], "ANY")) eb.context = E_BINDING_CONTEXT_ANY;
else
{
printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
" NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
exit(-1);
}
eb.button = atoi(params[1]);
/* M1[|M2...] */
{
char *p, *pp;
eb.modifiers = 0;
pp = params[2];
for (;;)
{
p = strchr(pp, '|');
if (p)
{
if (!strncmp(pp, "SHIFT|", 6)) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strncmp(pp, "CTRL|", 5)) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strncmp(pp, "ALT|", 4)) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strncmp(pp, "WIN|", 4)) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
pp = p + 1;
}
else
{
if (!strcmp(pp, "SHIFT")) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strcmp(pp, "CTRL")) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strcmp(pp, "ALT")) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strcmp(pp, "WIN")) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (!strcmp(pp, "NONE")) eb.modifiers = E_BINDING_MODIFIER_NONE;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
break;
}
}
}
eb.any_mod = atoi(params[3]);
eb.action = params[4];
eb.params = params[5];
REQ_4INT_2STRING_END(eb.context, eb.modifiers, eb.button, eb.any_mod, eb.action, eb.params, HDL);
#elif (TYPE == E_WM_IN)
/* e_ipc decode request and do action */
INT4_STRING2(v, HDL)
E_Config_Binding_Mouse bind, *eb;
bind.context = v->val1;
bind.modifiers = v->val2;
bind.button = v->val3;
bind.any_mod = v->val4;
bind.action = v->str1;
bind.params = v->str2;
eb = e_config_binding_mouse_match(&bind);
if (eb)
{
e_config->mouse_bindings = evas_list_remove(e_config->mouse_bindings, eb);
IF_FREE(eb->action);
IF_FREE(eb->params);
IF_FREE(eb);
e_border_button_bindings_ungrab_all();
e_bindings_mouse_del(bind.context, bind.button, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_border_button_bindings_grab_all();
e_config_save_queue();
}
END_INT4_STRING2(v);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_BINDING_KEY_LIST
#if (TYPE == E_REMOTE_OPTIONS)
/* e_remote define command line args */
OP("-binding-key-list", 0, "List all key bindings", 1, HDL)
#elif (TYPE == E_REMOTE_OUT)
/* e_remote parse command line args encode and send request */
REQ_NULL(HDL);
#elif (TYPE == E_WM_IN)
/* e_ipc decode request and do action or send reply */
SEND_INT3_STRING3_LIST(e_config->key_bindings, E_Config_Binding_Key, ekb, v, HDL);
v->val1 = ekb->context;
v->val2 = ekb->modifiers;
v->val3 = ekb->any_mod;
v->str1 = ekb->key;
v->str2 = ekb->action;
v->str3 = ekb->params;
END_SEND_INT3_STRING3_LIST(v, E_IPC_OP_BINDING_KEY_LIST_REPLY);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_BINDING_KEY_LIST_REPLY
#if (TYPE == E_REMOTE_OPTIONS)
#elif (TYPE == E_REMOTE_OUT)
#elif (TYPE == E_WM_IN)
#elif (TYPE == E_REMOTE_IN)
/* e_remote decode the response from e_ipc and print it to the console */
INT3_STRING3_LIST(v, HDL);
{
char *context;
char modifier[256];
if (v->val1 == E_BINDING_CONTEXT_NONE) context = "NONE";
else if (v->val1 == E_BINDING_CONTEXT_UNKNOWN) context = "UNKNOWN";
else if (v->val1 == E_BINDING_CONTEXT_BORDER) context = "BORDER";
else if (v->val1 == E_BINDING_CONTEXT_ZONE) context = "ZONE";
else if (v->val1 == E_BINDING_CONTEXT_MANAGER) context = "MANAGER";
else if (v->val1 == E_BINDING_CONTEXT_ANY) context = "ANY";
else context = "";
modifier[0] = 0;
if (v->val2 & E_BINDING_MODIFIER_SHIFT)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "SHIFT");
}
if (v->val2 & E_BINDING_MODIFIER_CTRL)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "CTRL");
}
if (v->val2 & E_BINDING_MODIFIER_ALT)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "ALT");
}
if (v->val2 & E_BINDING_MODIFIER_WIN)
{
if (modifier[0] != 0) strcat(modifier, "|");
strcat(modifier, "WIN");
}
if (v->val2 == E_BINDING_MODIFIER_NONE)
strcpy(modifier, "NONE");
printf("REPLY: BINDING CONTEXT=%s KEY=\"%s\" MODIFIERS=%s ANY_MOD=%i ACTION=\"%s\" PARAMS=\"%s\"\n",
context,
v->str1,
modifier,
v->val3,
v->str2,
v->str3
);
}
END_INT3_STRING3_LIST(v);
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_BINDING_KEY_ADD
#if (TYPE == E_REMOTE_OPTIONS)
/* e_remote define command line args */
OP("-binding-key-add", 6, "Add an existing key binding. OPT1 = Context, OPT2 = key, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 0, HDL)
#elif (TYPE == E_REMOTE_OUT)
/* e_remote parse command line args encode and send request */
REQ_3INT_3STRING_START(HDL);
E_Config_Binding_Key eb;
if (!strcmp(params[0], "NONE")) eb.context = E_BINDING_CONTEXT_NONE;
else if (!strcmp(params[0], "UNKNOWN")) eb.context = E_BINDING_CONTEXT_UNKNOWN;
else if (!strcmp(params[0], "BORDER")) eb.context = E_BINDING_CONTEXT_BORDER;
else if (!strcmp(params[0], "ZONE")) eb.context = E_BINDING_CONTEXT_ZONE;
else if (!strcmp(params[0], "MANAGER")) eb.context = E_BINDING_CONTEXT_MANAGER;
else if (!strcmp(params[0], "ANY")) eb.context = E_BINDING_CONTEXT_ANY;
else
{
printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
" NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
exit(-1);
}
eb.key = params[1];
/* M1[|M2...] */
{
char *p, *pp;
eb.modifiers = 0;
pp = params[2];
for (;;)
{
p = strchr(pp, '|');
if (p)
{
if (!strncmp(pp, "SHIFT|", 6)) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strncmp(pp, "CTRL|", 5)) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strncmp(pp, "ALT|", 4)) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strncmp(pp, "WIN|", 4)) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
pp = p + 1;
}
else
{
if (!strcmp(pp, "SHIFT")) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strcmp(pp, "CTRL")) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strcmp(pp, "ALT")) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strcmp(pp, "WIN")) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (!strcmp(pp, "NONE")) eb.modifiers = E_BINDING_MODIFIER_NONE;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
break;
}
}
}
eb.any_mod = atoi(params[3]);
eb.action = params[4];
eb.params = params[5];
REQ_3INT_3STRING_END(eb.context, eb.modifiers, eb.any_mod, eb.key, eb.action, eb.params, HDL);
#elif (TYPE == E_WM_IN)
/* e_ipc decode request and do action */
INT3_STRING3(v, HDL)
E_Config_Binding_Key bind, *eb;
bind.context = v->val1;
bind.modifiers = v->val2;
bind.any_mod = v->val3;
bind.key = v->str1;
bind.action = v->str2;
bind.params = v->str3;
eb = e_config_binding_key_match(&bind);
if (!eb)
{
eb = E_NEW(E_Config_Binding_Key, 1);
e_config->key_bindings = evas_list_append(e_config->key_bindings, eb);
eb->context = bind.context;
eb->modifiers = bind.modifiers;
eb->any_mod = bind.any_mod;
eb->key = strdup(bind.key);
eb->action = strdup(bind.action);
eb->params = strdup(bind.params);
e_managers_keys_ungrab();
e_bindings_key_add(bind.context, bind.key, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_managers_keys_grab();
e_config_save_queue();
}
END_INT3_STRING3(v);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/*****/
/***************/
#define HDL E_IPC_OP_BINDING_KEY_DEL
#if (TYPE == E_REMOTE_OPTIONS)
/* e_remote define command line args */
OP("-binding-key-del", 6, "Delete an existing key binding. OPT1 = Context, OPT2 = key, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 0, HDL)
#elif (TYPE == E_REMOTE_OUT)
/* e_remote parse command line args encode and send request */
REQ_3INT_3STRING_START(HDL);
E_Config_Binding_Key eb;
if (!strcmp(params[0], "NONE")) eb.context = E_BINDING_CONTEXT_NONE;
else if (!strcmp(params[0], "UNKNOWN")) eb.context = E_BINDING_CONTEXT_UNKNOWN;
else if (!strcmp(params[0], "BORDER")) eb.context = E_BINDING_CONTEXT_BORDER;
else if (!strcmp(params[0], "ZONE")) eb.context = E_BINDING_CONTEXT_ZONE;
else if (!strcmp(params[0], "MANAGER")) eb.context = E_BINDING_CONTEXT_MANAGER;
else if (!strcmp(params[0], "ANY")) eb.context = E_BINDING_CONTEXT_ANY;
else
{
printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
" NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
exit(-1);
}
eb.key = params[1];
/* M1[|M2...] */
{
char *p, *pp;
eb.modifiers = 0;
pp = params[2];
for (;;)
{
p = strchr(pp, '|');
if (p)
{
if (!strncmp(pp, "SHIFT|", 6)) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strncmp(pp, "CTRL|", 5)) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strncmp(pp, "ALT|", 4)) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strncmp(pp, "WIN|", 4)) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
pp = p + 1;
}
else
{
if (!strcmp(pp, "SHIFT")) eb.modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strcmp(pp, "CTRL")) eb.modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strcmp(pp, "ALT")) eb.modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strcmp(pp, "WIN")) eb.modifiers |= E_BINDING_MODIFIER_WIN;
else if (!strcmp(pp, "NONE")) eb.modifiers = E_BINDING_MODIFIER_NONE;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
break;
}
}
}
eb.any_mod = atoi(params[3]);
eb.action = params[4];
eb.params = params[5];
REQ_3INT_3STRING_END(eb.context, eb.modifiers, eb.any_mod, eb.key, eb.action, eb.params, HDL);
#elif (TYPE == E_WM_IN)
/* e_ipc decode request and do action */
INT3_STRING3(v, HDL)
E_Config_Binding_Key bind, *eb;
bind.context = v->val1;
bind.modifiers = v->val2;
bind.any_mod = v->val3;
bind.key = v->str1;
bind.action = v->str2;
bind.params = v->str3;
eb = e_config_binding_key_match(&bind);
if (eb)
{
e_config->key_bindings = evas_list_remove(e_config->key_bindings, eb);
IF_FREE(eb->key);
IF_FREE(eb->action);
IF_FREE(eb->params);
IF_FREE(eb);
e_managers_keys_ungrab();
e_bindings_key_del(bind.context, bind.key, bind.modifiers,
bind.any_mod, bind.action, bind.params);
e_managers_keys_grab();
e_config_save_queue();
}
END_INT3_STRING3(v);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/*****/
#if 0
}
#endif

View File

@ -267,736 +267,3 @@ _e_help(void)
}
#if 0
typedef struct _E_IPC_Opt_Handler E_IPC_Opt_Handler;
struct _E_IPC_Opt_Handler
{
char *option;
char *desc;
int num_params;
int replies;
int type;
int simple_request_id;
void (*func) (char **params);
};
/* local subsystem functions */
static int _e_cb_signal_exit(void *data, int ev_type, void *ev);
static int _e_ipc_init(void);
static void _e_ipc_shutdown(void);
static int _e_ipc_cb_server_add(void *data, int type, void *event);
static int _e_ipc_cb_server_del(void *data, int type, void *event);
static int _e_ipc_cb_server_data(void *data, int type, void *event);
static void _e_help(void);
static const char *_e_ipc_context_str(int context);
static const char *_e_ipc_modifier_str(int mod);
/* local subsystem globals */
static Ecore_Ipc_Server *_e_ipc_server = NULL;
static const char *display_name = NULL;
static int reply_count = 0;
static int reply_expect = 0;
static void
_e_opt_binding_mouse_parse(E_Config_Binding_Mouse *eb, char **params)
{
if (!strcmp(params[0], "NONE")) eb->context = E_BINDING_CONTEXT_NONE;
else if (!strcmp(params[0], "UNKNOWN")) eb->context = E_BINDING_CONTEXT_UNKNOWN;
else if (!strcmp(params[0], "BORDER")) eb->context = E_BINDING_CONTEXT_BORDER;
else if (!strcmp(params[0], "ZONE")) eb->context = E_BINDING_CONTEXT_ZONE;
else if (!strcmp(params[0], "MANAGER")) eb->context = E_BINDING_CONTEXT_MANAGER;
else if (!strcmp(params[0], "ANY")) eb->context = E_BINDING_CONTEXT_ANY;
else
{
printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
" NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
exit(-1);
}
eb->button = atoi(params[1]);
/* M1[|M2...] */
{
char *p, *pp;
eb->modifiers = 0;
pp = params[2];
for (;;)
{
p = strchr(pp, '|');
if (p)
{
if (!strncmp(pp, "SHIFT|", 6)) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strncmp(pp, "CTRL|", 5)) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strncmp(pp, "ALT|", 4)) eb->modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strncmp(pp, "WIN|", 4)) eb->modifiers |= E_BINDING_MODIFIER_WIN;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
pp = p + 1;
}
else
{
if (!strcmp(pp, "SHIFT")) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strcmp(pp, "CTRL")) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strcmp(pp, "ALT")) eb->modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strcmp(pp, "WIN")) eb->modifiers |= E_BINDING_MODIFIER_WIN;
else if (!strcmp(pp, "NONE")) eb->modifiers = E_BINDING_MODIFIER_NONE;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
break;
}
}
}
eb->any_mod = atoi(params[3]);
eb->action = params[4];
eb->params = params[5];
}
static void
_e_opt_binding_mouse_add(char **params)
{
E_Config_Binding_Mouse bind;
int bytes;
char *data;
_e_opt_binding_mouse_parse(&bind, params);
data = _e_ipc_mouse_binding_enc(&bind, &bytes);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
E_IPC_OP_BINDING_MOUSE_ADD,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
static void
_e_opt_binding_mouse_del(char **params)
{
E_Config_Binding_Mouse bind;
int bytes;
char *data;
_e_opt_binding_mouse_parse(&bind, params);
data = _e_ipc_mouse_binding_enc(&bind, &bytes);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
E_IPC_OP_BINDING_MOUSE_DEL,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
static void
_e_opt_binding_key_parse(E_Config_Binding_Key *eb, char **params)
{
if (!strcmp(params[0], "NONE")) eb->context = E_BINDING_CONTEXT_NONE;
else if (!strcmp(params[0], "UNKNOWN")) eb->context = E_BINDING_CONTEXT_UNKNOWN;
else if (!strcmp(params[0], "BORDER")) eb->context = E_BINDING_CONTEXT_BORDER;
else if (!strcmp(params[0], "ZONE")) eb->context = E_BINDING_CONTEXT_ZONE;
else if (!strcmp(params[0], "MANAGER")) eb->context = E_BINDING_CONTEXT_MANAGER;
else if (!strcmp(params[0], "ANY")) eb->context = E_BINDING_CONTEXT_ANY;
else
{
printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
" NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
exit(-1);
}
eb->key = params[1];
/* M1[|M2...] */
{
char *p, *pp;
eb->modifiers = 0;
pp = params[2];
for (;;)
{
p = strchr(pp, '|');
if (p)
{
if (!strncmp(pp, "SHIFT|", 6)) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strncmp(pp, "CTRL|", 5)) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strncmp(pp, "ALT|", 4)) eb->modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strncmp(pp, "WIN|", 4)) eb->modifiers |= E_BINDING_MODIFIER_WIN;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
pp = p + 1;
}
else
{
if (!strcmp(pp, "SHIFT")) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
else if (!strcmp(pp, "CTRL")) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
else if (!strcmp(pp, "ALT")) eb->modifiers |= E_BINDING_MODIFIER_ALT;
else if (!strcmp(pp, "WIN")) eb->modifiers |= E_BINDING_MODIFIER_WIN;
else if (!strcmp(pp, "NONE")) eb->modifiers = E_BINDING_MODIFIER_NONE;
else if (strlen(pp) > 0)
{
printf("OPT3 moidifier unknown. Must be or mask of:\n"
" SHIFT CTRL ALT WIN (eg SHIFT|CTRL or ALT|SHIFT|CTRL or ALT or just NONE)\n");
exit(-1);
}
break;
}
}
}
eb->any_mod = atoi(params[3]);
eb->action = params[4];
eb->params = params[5];
}
static void
_e_opt_binding_key_add(char **params)
{
E_Config_Binding_Key bind;
int bytes;
char *data;
_e_opt_binding_key_parse(&bind, params);
data = _e_ipc_key_binding_enc(&bind, &bytes);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
E_IPC_OP_BINDING_KEY_ADD,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
static void
_e_opt_binding_key_del(char **params)
{
E_Config_Binding_Key bind;
int bytes;
char *data;
_e_opt_binding_key_parse(&bind, params);
data = _e_ipc_key_binding_enc(&bind, &bytes);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
E_IPC_OP_BINDING_KEY_DEL,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
data, bytes);
free(data);
}
static void
_e_opt_focus_policy_set(char **params)
{
int bytes;
char *data;
int value;
value = 0;
if (!strcmp(params[0], "MOUSE")) value = E_FOCUS_MOUSE;
else if (!strcmp(params[0], "CLICK")) value = E_FOCUS_CLICK;
else if (!strcmp(params[0], "SLOPPY")) value = E_FOCUS_SLOPPY;
else
{
printf("focus must be MOUSE, CLICK or SLOPPY\n");
exit(-1);
}
data = e_ipc_codec_int_enc(value, &bytes);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
E_IPC_OP_FOCUS_POLICY_SET,
0, 0, 0,
data, bytes);
free(data);
}
#define SIMPLE_REQ 0
#define SIMPLE_STR_REQ 1
#define FULL_FUNC 2
#define MULTI_STR_REQ 3
#define SIMPLE_INT_REQ 4
#define SIMPLE_DBL_REQ 5
#define SIMPLE_2INT_REQ 6
#define OREQ(opt, desc, ipc, rep) {opt, desc, 0, rep, SIMPLE_REQ, ipc, NULL}
#define OSTR(opt, desc, ipc, rep) {opt, desc, 1, rep, SIMPLE_STR_REQ, ipc, NULL}
#define OFNC(opt, desc, param, fn, rep) {opt, desc, param, rep, FULL_FUNC, 0, fn}
#define OMUL(opt, desc, ipc, rep, argc) {opt, desc, argc, rep, MULTI_STR_REQ, ipc, NULL}
#define OINT(opt, desc, ipc, rep) {opt, desc, 1, rep, SIMPLE_INT_REQ, ipc, NULL}
#define ODBL(opt, desc, ipc, rep) {opt, desc, 1, rep, SIMPLE_DBL_REQ, ipc, NULL}
#define O2INT(opt, desc, ipc, rep) {opt, desc, 2, rep, SIMPLE_2INT_REQ, ipc, NULL}
E_IPC_Opt_Handler handlers[] =
{
OREQ("-binding-mouse-list", "List all mouse bindings", E_IPC_OP_BINDING_MOUSE_LIST, 1),
OFNC("-binding-mouse-add", "Add an existing mouse binding. OPT1 = Context, OPT2 = button, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 6, _e_opt_binding_mouse_add, 0),
OFNC("-binding-mouse-del", "Delete an existing mouse binding. OPT1 = Context, OPT2 = button, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 6, _e_opt_binding_mouse_del, 0),
OREQ("-binding-key-list", "List all key bindings", E_IPC_OP_BINDING_KEY_LIST, 1),
OFNC("-binding-key-add", "Add an existing key binding. OPT1 = Context, OPT2 = key, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 6, _e_opt_binding_key_add, 0),
OFNC("-binding-key-del", "Delete an existing key binding. OPT1 = Context, OPT2 = key, OPT3 = modifiers, OPT4 = any modifier ok, OPT5 = action, OPT6 = action parameters", 6, _e_opt_binding_key_del, 0),
};
/* externally accessible functions */
int
main(int argc, char **argv)
{
int i;
char *s, buf[1024];
/* fix up DISPLAY to be :N.0 if no .screen is in it */
s = getenv("DISPLAY");
if (s)
{
char *p;
p = strrchr(s, ':');
if (!p)
{
snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s);
putenv(strdup(buf));
}
else
{
p = strrchr(p, '.');
if (!p)
{
snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s);
putenv(strdup(buf));
}
}
}
/* handle some command-line parameters */
display_name = (const char *)getenv("DISPLAY");
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
{
i++;
display_name = argv[i];
}
else if ((!strcmp(argv[i], "-h")) ||
(!strcmp(argv[i], "-help")) ||
(!strcmp(argv[i], "--h")) ||
(!strcmp(argv[i], "--help")))
{
_e_help();
exit(0);
}
}
/* basic ecore init */
if (!ecore_init())
{
printf("ERROR: Enlightenment_remote cannot Initialize Ecore!\n"
"Perhaps you are out of memory?\n");
exit(-1);
}
ecore_app_args_set((int)argc, (const char **)argv);
/* setup a handler for when e is asked to exit via a system signal */
if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _e_cb_signal_exit, NULL))
{
printf("ERROR: Enlightenment_remote cannot set up an exit signal handler.\n"
"Perhaps you are out of memory?\n");
exit(-1);
}
/* init ipc */
if (!ecore_ipc_init())
{
printf("ERROR: Enlightenment_remote cannot initialize the ipc system.\n"
"Perhaps you are out of memory?\n");
exit(-1);
}
/* setup e ipc service */
if (!_e_ipc_init())
{
printf("ERROR: Enlightenment_remote cannot set up the IPC socket.\n"
"Maybe try the '-display :0.0' option?\n");
exit(-1);
}
e_ipc_codec_init();
/* start our main loop */
ecore_main_loop_begin();
e_ipc_codec_shutdown();
_e_ipc_shutdown();
ecore_ipc_shutdown();
ecore_shutdown();
/* just return 0 to keep the compiler quiet */
return 0;
}
/* local subsystem functions */
static int
_e_cb_signal_exit(void *data, int ev_type, void *ev)
{
/* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
ecore_main_loop_quit();
return 1;
}
static int
_e_ipc_init(void)
{
char buf[1024];
char *disp;
disp = (char *)display_name;
if (!disp) disp = ":0";
snprintf(buf, sizeof(buf), "enlightenment-(%s)", disp);
_e_ipc_server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, buf, 0, NULL);
/* FIXME: we shoudl also try the generic ":0" if the display is ":0.0" */
/* similar... */
if (!_e_ipc_server) return 0;
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, _e_ipc_cb_server_add, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, _e_ipc_cb_server_del, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, _e_ipc_cb_server_data, NULL);
return 1;
}
static void
_e_ipc_shutdown(void)
{
if (_e_ipc_server)
{
ecore_ipc_server_del(_e_ipc_server);
_e_ipc_server = NULL;
}
}
static int
_e_ipc_cb_server_add(void *data, int type, void *event)
{
Ecore_Ipc_Event_Server_Add *e;
int argc;
char **argv;
int i;
int process_count = 0;
e = event;
ecore_app_args_get(&argc, &argv);
for (i = 1; i < argc; i++)
{
char *v, *p;
int j;
int k;
int data_size;
for (j = 0; j < (int)(sizeof(handlers) / sizeof(E_IPC_Opt_Handler)); j++)
{
E_IPC_Opt_Handler *handler;
handler = &handlers[j];
if (!strcmp(handler->option, argv[i]))
{
if (i >= (argc - handler->num_params))
{
printf("ERROR: option %s expects %i parameters\n",
handler->option, handler->num_params);
exit(-1);
}
else
{
switch (handler->type)
{
case SIMPLE_REQ:
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
handler->simple_request_id,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
NULL, 0);
break;
case SIMPLE_STR_REQ:
v = e_ipc_codec_str_enc(argv[i + 1], &data_size);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
handler->simple_request_id,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
v, data_size);
free(v);
break;
case MULTI_STR_REQ:
/* pack up the data "<str>0<str>0" */
data_size = 0;
for (k = 0; k < handler->num_params; k++)
{
data_size += strlen(argv[ i + 1 + k ]);
data_size++; /* NULL Pad */
}
v = malloc(data_size);
p = v;
for (k = 0; k < handler->num_params; k++)
{
strcpy(p, argv[ i + 1 + k]);
p += strlen(argv[ i + 1 + k]);
*p = 0;
p++;
}
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
handler->simple_request_id,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
v, data_size);
free(v);
break;
case FULL_FUNC:
handler->func(argv + i + 1);
break;
case SIMPLE_INT_REQ:
v = e_ipc_codec_int_enc(atoi(argv[i + 1]),
&data_size);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
handler->simple_request_id,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
v, data_size);
free(v);
break;
case SIMPLE_DBL_REQ:
v = e_ipc_codec_double_enc(atof(argv[i + 1]),
&data_size);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
handler->simple_request_id,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
v, data_size);
free(v);
break;
case SIMPLE_2INT_REQ:
v = e_ipc_codec_2int_enc(atoi(argv[i + 1]),
atoi(argv[i + 2]),
&data_size);
ecore_ipc_server_send(_e_ipc_server,
E_IPC_DOMAIN_REQUEST,
handler->simple_request_id,
0/*ref*/, 0/*ref_to*/, 0/*response*/,
v, data_size);
free(v);
break;
default:
break;
}
process_count++;
reply_expect += handler->replies;
i += handler->num_params;
break;
}
}
}
}
if (process_count <= 0)
_e_help();
if (reply_count >= reply_expect) ecore_main_loop_quit();
return 1;
}
static int
_e_ipc_cb_server_del(void *data, int type, void *event)
{
Ecore_Ipc_Event_Server_Del *e;
e = event;
return 1;
}
static int
_e_ipc_cb_server_data(void *data, int type, void *event)
{
Ecore_Ipc_Event_Server_Data *e;
e = event;
/* FIXME: should make this function/callback based in a table like the */
/* option handlers... */
printf("REPLY: BEGIN\n");
switch (e->minor)
{
case E_IPC_OP_BINDING_MOUSE_LIST_REPLY:
if (e->data)
{
Evas_List *bindings;
E_Config_Binding_Mouse *eb;
bindings = _e_ipc_mouse_binding_list_dec(e->data, e->size);
while (bindings)
{
eb = bindings->data;
printf("REPLY: BINDING CONTEXT=%s MODIFIERS=%s BUTTON=%i ANY_MOD=%i ACTION=\"%s\" PARAMS=\"%s\"\n",
_e_ipc_context_str(eb->context),
_e_ipc_modifier_str(eb->modifiers),
eb->button,
eb->any_mod,
eb->action,
eb->params
);
bindings = evas_list_remove_list(bindings, bindings);
E_FREE(eb);
}
}
else
printf("REPLY: AVAILABLE NONE\n");
break;
case E_IPC_OP_BINDING_KEY_LIST_REPLY:
if (e->data)
{
Evas_List *bindings;
E_Config_Binding_Key *eb;
bindings = _e_ipc_key_binding_list_dec(e->data, e->size);
while (bindings)
{
eb = bindings->data;
printf("REPLY: BINDING CONTEXT=%s MODIFIERS=%s KEY=\"%s\" ANY_MOD=%i ACTION=\"%s\" PARAMS=\"%s\"\n",
_e_ipc_context_str(eb->context),
_e_ipc_modifier_str(eb->modifiers),
eb->key,
eb->any_mod,
eb->action,
eb->params
);
bindings = evas_list_remove_list(bindings, bindings);
E_FREE(eb);
}
}
else
printf("REPLY: AVAILABLE NONE\n");
break;
default:
break;
}
printf("REPLY: END\n");
reply_count++;
printf("%i == %i\n", reply_count, reply_expect);
if (reply_count >= reply_expect) ecore_main_loop_quit();
return 1;
}
static void
_e_help(void)
{
int j, k, l;
E_IPC_Opt_Handler *handler;
char buf[128];
int parsize = 0, opsize = 0;
printf("OPTIONS:\n");
for (j = 0; j < (int)(sizeof(handlers) / sizeof(E_IPC_Opt_Handler)); j++)
{
handler = &handlers[j];
if ((int)strlen(handler->option) > parsize) parsize = strlen(handler->option);
l = 0;
for (k = 0; k < handler->num_params; k++)
{
snprintf(buf, sizeof(buf), " OPT%i", k + 1);
l += strlen(buf);
}
if (l > opsize) opsize = l;
}
for (j = 0; j < (int)(sizeof(handlers) / sizeof(E_IPC_Opt_Handler)); j++)
{
handler = &handlers[j];
printf(" %s", handler->option);
l = parsize - strlen(handler->option);
for (k = 0; k < l; k++) printf(" ");
l = 0;
for (k = 0; k < handler->num_params; k++)
{
snprintf(buf, sizeof(buf), " OPT%i", k + 1);
printf("%s", buf);
l += strlen(buf);
}
while (l < opsize)
{
printf(" ");
l++;
}
printf(" - %s\n", handler->desc);
}
}
/* generic encoding functions */
static const char *
_e_ipc_context_str(int context)
{
if (context == E_BINDING_CONTEXT_NONE) return "NONE";
if (context == E_BINDING_CONTEXT_UNKNOWN) return "UNKNOWN";
if (context == E_BINDING_CONTEXT_BORDER) return "BORDER";
if (context == E_BINDING_CONTEXT_ZONE) return "ZONE";
if (context == E_BINDING_CONTEXT_MANAGER) return "MANAGER";
if (context == E_BINDING_CONTEXT_ANY) return "ANY";
return "";
}
static char _mod_buf[256];
static const char *
_e_ipc_modifier_str(int mod)
{
_mod_buf[0] = 0;
if (mod & E_BINDING_MODIFIER_SHIFT)
{
if (_mod_buf[0] != 0) strcat(_mod_buf, "|");
strcat(_mod_buf, "SHIFT");
}
if (mod & E_BINDING_MODIFIER_CTRL)
{
if (_mod_buf[0] != 0) strcat(_mod_buf, "|");
strcat(_mod_buf, "CTRL");
}
if (mod & E_BINDING_MODIFIER_ALT)
{
if (_mod_buf[0] != 0) strcat(_mod_buf, "|");
strcat(_mod_buf, "ALT");
}
if (mod & E_BINDING_MODIFIER_WIN)
{
if (_mod_buf[0] != 0) strcat(_mod_buf, "|");
strcat(_mod_buf, "WIN");
}
if (mod == E_BINDING_MODIFIER_NONE)
strcpy(_mod_buf, "NONE");
return _mod_buf;
}
#endif