summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-05-05 06:45:47 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-05-05 06:45:47 +0000
commit4c91972c078df348d23c176e118ed706842c712e (patch)
tree3f4a5ab468ca3406a693d95aae4d23be06ecf192 /src/bin
parent9a8fe8a324ec7762c2e256f4939df02817a7b4fd (diff)
key and mouse bindings are configurable via ipc. now. :)
SVN revision: 14608
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/e_border.c28
-rw-r--r--src/bin/e_border.h3
-rw-r--r--src/bin/e_config.c42
-rw-r--r--src/bin/e_config.h3
-rw-r--r--src/bin/e_ipc.c81
-rw-r--r--src/bin/e_remote_main.c194
6 files changed, 350 insertions, 1 deletions
diff --git a/src/bin/e_border.c b/src/bin/e_border.c
index f5d5dee..7eb8c4b 100644
--- a/src/bin/e_border.c
+++ b/src/bin/e_border.c
@@ -1308,6 +1308,34 @@ e_border_act_kill_begin(E_Border *bd)
1308 e_object_del(E_OBJECT(bd)); 1308 e_object_del(E_OBJECT(bd));
1309} 1309}
1310 1310
1311void
1312e_border_button_bindings_ungrab_all(void)
1313{
1314 Evas_List *l;
1315
1316 for (l = borders; l; l = l->next)
1317 {
1318 E_Border *bd;
1319
1320 bd = l->data;
1321 e_bindings_mouse_ungrab(E_BINDING_CONTEXT_BORDER, bd->win);
1322 }
1323}
1324
1325void
1326e_border_button_bindings_grab_all(void)
1327{
1328 Evas_List *l;
1329
1330 for (l = borders; l; l = l->next)
1331 {
1332 E_Border *bd;
1333
1334 bd = l->data;
1335 e_bindings_mouse_grab(E_BINDING_CONTEXT_BORDER, bd->win);
1336 }
1337}
1338
1311/* local subsystem functions */ 1339/* local subsystem functions */
1312static void 1340static void
1313_e_border_free(E_Border *bd) 1341_e_border_free(E_Border *bd)
diff --git a/src/bin/e_border.h b/src/bin/e_border.h
index c496728..cd69087 100644
--- a/src/bin/e_border.h
+++ b/src/bin/e_border.h
@@ -357,6 +357,9 @@ EAPI void e_border_act_resize_end(E_Border *bd, Ecore_X_Event_Mouse_Button_Up *e
357EAPI void e_border_act_menu_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev, int key); 357EAPI void e_border_act_menu_begin(E_Border *bd, Ecore_X_Event_Mouse_Button_Down *ev, int key);
358EAPI void e_border_act_close_begin(E_Border *bd); 358EAPI void e_border_act_close_begin(E_Border *bd);
359EAPI void e_border_act_kill_begin(E_Border *bd); 359EAPI void e_border_act_kill_begin(E_Border *bd);
360
361EAPI void e_border_button_bindings_ungrab_all(void);
362EAPI void e_border_button_bindings_grab_all(void);
360 363
361extern EAPI int E_EVENT_BORDER_RESIZE; 364extern EAPI int E_EVENT_BORDER_RESIZE;
362extern EAPI int E_EVENT_BORDER_MOVE; 365extern EAPI int E_EVENT_BORDER_MOVE;
diff --git a/src/bin/e_config.c b/src/bin/e_config.c
index e4fe08d..8a08d11 100644
--- a/src/bin/e_config.c
+++ b/src/bin/e_config.c
@@ -732,6 +732,48 @@ e_config_domain_save(char *domain, E_Config_DD *edd, void *data)
732 return ok; 732 return ok;
733} 733}
734 734
735E_Config_Binding_Mouse *
736e_config_binding_mouse_match(E_Config_Binding_Mouse *eb_in)
737{
738 Evas_List *l;
739
740 for (l = e_config->mouse_bindings; l; l = l->next)
741 {
742 E_Config_Binding_Mouse *eb;
743
744 eb = l->data;
745 if ((eb->context == eb_in->context) &&
746 (eb->button == eb_in->button) &&
747 (eb->modifiers == eb_in->modifiers) &&
748 (eb->any_mod == eb_in->any_mod) &&
749 (!strcmp(eb->action, eb_in->action)) &&
750 (!strcmp(eb->action, eb_in->action)))
751 return eb;
752 }
753 return NULL;
754}
755
756E_Config_Binding_Key *
757e_config_binding_key_match(E_Config_Binding_Key *eb_in)
758{
759 Evas_List *l;
760
761 for (l = e_config->key_bindings; l; l = l->next)
762 {
763 E_Config_Binding_Key *eb;
764
765 eb = l->data;
766 if ((eb->context == eb_in->context) &&
767 (eb->modifiers == eb_in->modifiers) &&
768 (eb->any_mod == eb_in->any_mod) &&
769 (!strcmp(eb->key, eb_in->key)) &&
770 (!strcmp(eb->action, eb_in->action)) &&
771 (!strcmp(eb->action, eb_in->action)))
772 return eb;
773 }
774 return NULL;
775}
776
735/* local subsystem functions */ 777/* local subsystem functions */
736static void 778static void
737_e_config_save_cb(void *data) 779_e_config_save_cb(void *data)
diff --git a/src/bin/e_config.h b/src/bin/e_config.h
index c81019a..42a6e12 100644
--- a/src/bin/e_config.h
+++ b/src/bin/e_config.h
@@ -108,6 +108,9 @@ EAPI int e_config_save(void);
108EAPI void e_config_save_flush(void); 108EAPI void e_config_save_flush(void);
109EAPI void e_config_save_queue(void); 109EAPI void e_config_save_queue(void);
110 110
111EAPI E_Config_Binding_Mouse *e_config_binding_mouse_match(E_Config_Binding_Mouse *eb_in);
112EAPI E_Config_Binding_Key *e_config_binding_key_match(E_Config_Binding_Key *eb_in);
113
111extern EAPI E_Config *e_config; 114extern EAPI E_Config *e_config;
112 115
113#endif 116#endif
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
index 7f57c24..cc99c20 100644
--- a/src/bin/e_ipc.c
+++ b/src/bin/e_ipc.c
@@ -471,10 +471,50 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
471 break; 471 break;
472 case E_IPC_OP_BINDING_MOUSE_ADD: 472 case E_IPC_OP_BINDING_MOUSE_ADD:
473 { 473 {
474 E_Config_Binding_Mouse bind, *eb;
475
476 _e_ipc_mouse_binding_dec(e->data, e->size, &bind);
477 {
478 eb = e_config_binding_mouse_match(&bind);
479 if (!eb)
480 {
481 eb = E_NEW(E_Config_Binding_Key, 1);
482 e_config->mouse_bindings = evas_list_append(e_config->mouse_bindings, eb);
483 eb->context = bind.context;
484 eb->button = bind.button;
485 eb->modifiers = bind.modifiers;
486 eb->any_mod = bind.any_mod;
487 eb->action = strdup(bind.action);
488 eb->params = strdup(bind.params);
489 e_border_button_bindings_ungrab_all();
490 e_bindings_mouse_add(bind.context, bind.button, bind.modifiers,
491 bind.any_mod, bind.action, bind.params);
492 e_border_button_bindings_grab_all();
493 e_config_save_queue();
494 }
495 }
474 } 496 }
475 break; 497 break;
476 case E_IPC_OP_BINDING_MOUSE_DEL: 498 case E_IPC_OP_BINDING_MOUSE_DEL:
477 { 499 {
500 E_Config_Binding_Mouse bind, *eb;
501
502 _e_ipc_mouse_binding_dec(e->data, e->size, &bind);
503 {
504 eb = e_config_binding_mouse_match(&bind);
505 if (eb)
506 {
507 e_config->mouse_bindings = evas_list_remove(e_config->mouse_bindings, eb);
508 IF_FREE(eb->action);
509 IF_FREE(eb->params);
510 IF_FREE(eb);
511 e_border_button_bindings_ungrab_all();
512 e_bindings_mouse_del(bind.context, bind.button, bind.modifiers,
513 bind.any_mod, bind.action, bind.params);
514 e_border_button_bindings_grab_all();
515 e_config_save_queue();
516 }
517 }
478 } 518 }
479 break; 519 break;
480 case E_IPC_OP_BINDING_KEY_LIST: 520 case E_IPC_OP_BINDING_KEY_LIST:
@@ -495,10 +535,51 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
495 break; 535 break;
496 case E_IPC_OP_BINDING_KEY_ADD: 536 case E_IPC_OP_BINDING_KEY_ADD:
497 { 537 {
538 E_Config_Binding_Key bind, *eb;
539
540 _e_ipc_key_binding_dec(e->data, e->size, &bind);
541 {
542 eb = e_config_binding_key_match(&bind);
543 if (!eb)
544 {
545 eb = E_NEW(E_Config_Binding_Key, 1);
546 e_config->key_bindings = evas_list_append(e_config->key_bindings, eb);
547 eb->context = bind.context;
548 eb->modifiers = bind.modifiers;
549 eb->any_mod = bind.any_mod;
550 eb->key = strdup(bind.key);
551 eb->action = strdup(bind.action);
552 eb->params = strdup(bind.params);
553 e_managers_keys_ungrab();
554 e_bindings_key_add(bind.context, bind.key, bind.modifiers,
555 bind.any_mod, bind.action, bind.params);
556 e_managers_keys_grab();
557 e_config_save_queue();
558 }
559 }
498 } 560 }
499 break; 561 break;
500 case E_IPC_OP_BINDING_KEY_DEL: 562 case E_IPC_OP_BINDING_KEY_DEL:
501 { 563 {
564 E_Config_Binding_Key bind, *eb;
565
566 _e_ipc_key_binding_dec(e->data, e->size, &bind);
567 {
568 eb = e_config_binding_key_match(&bind);
569 if (eb)
570 {
571 e_config->key_bindings = evas_list_remove(e_config->key_bindings, eb);
572 IF_FREE(eb->key);
573 IF_FREE(eb->action);
574 IF_FREE(eb->params);
575 IF_FREE(eb);
576 e_managers_keys_ungrab();
577 e_bindings_key_del(bind.context, bind.key, bind.modifiers,
578 bind.any_mod, bind.action, bind.params);
579 e_managers_keys_grab();
580 e_config_save_queue();
581 }
582 }
502 } 583 }
503 break; 584 break;
504 default: 585 default:
diff --git a/src/bin/e_remote_main.c b/src/bin/e_remote_main.c
index 53011fe..4b90d08 100644
--- a/src/bin/e_remote_main.c
+++ b/src/bin/e_remote_main.c
@@ -49,6 +49,194 @@ static const char *display_name = NULL;
49static int reply_count = 0; 49static int reply_count = 0;
50static int reply_expect = 0; 50static int reply_expect = 0;
51 51
52static void
53_e_opt_binding_mouse_parse(E_Config_Binding_Mouse *eb, char **params)
54{
55 if (!strcmp(params[0], "NONE")) eb->context = E_BINDING_CONTEXT_NONE;
56 else if (!strcmp(params[0], "UNKNOWN")) eb->context = E_BINDING_CONTEXT_UNKNOWN;
57 else if (!strcmp(params[0], "BORDER")) eb->context = E_BINDING_CONTEXT_BORDER;
58 else if (!strcmp(params[0], "ZONE")) eb->context = E_BINDING_CONTEXT_ZONE;
59 else if (!strcmp(params[0], "MANAGER")) eb->context = E_BINDING_CONTEXT_MANAGER;
60 else if (!strcmp(params[0], "ANY")) eb->context = E_BINDING_CONTEXT_ANY;
61 else
62 {
63 printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
64 " NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
65 exit(-1);
66 }
67 eb->button = atoi(params[1]);
68 /* M1[|M2...] */
69 {
70 char *p, *pp;
71
72 eb->modifiers = 0;
73 pp = params[2];
74 for (;;)
75 {
76 p = strchr(pp, '|');
77 if (p)
78 {
79 if (!strncmp(pp, "SHIFT|", 6)) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
80 else if (!strncmp(pp, "CTRL|", 5)) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
81 else if (!strncmp(pp, "ALT|", 4)) eb->modifiers |= E_BINDING_MODIFIER_ALT;
82 else if (!strncmp(pp, "WIN|", 4)) eb->modifiers |= E_BINDING_MODIFIER_WIN;
83 else
84 {
85 printf("OPT3 moidifier unknonw. Must be or mask of:\n"
86 " SHIFT CTRL ALT WIN\n");
87 exit(-1);
88 }
89 pp = p + 1;
90 }
91 else
92 {
93 if (!strcmp(pp, "SHIFT")) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
94 else if (!strcmp(pp, "CTRL")) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
95 else if (!strcmp(pp, "ALT")) eb->modifiers |= E_BINDING_MODIFIER_ALT;
96 else if (!strcmp(pp, "WIN")) eb->modifiers |= E_BINDING_MODIFIER_WIN;
97 else
98 {
99 printf("OPT3 moidifier unknonw. Must be or mask of:\n"
100 " SHIFT CTRL ALT WIN\n");
101 exit(-1);
102 }
103 break;
104 }
105 }
106 }
107 eb->any_mod = atoi(params[3]);
108 eb->action = params[4];
109 eb->params = params[5];
110}
111
112static void
113_e_opt_binding_mouse_add(char **params)
114{
115 E_Config_Binding_Mouse bind;
116 int bytes;
117 char *data;
118
119 _e_opt_binding_mouse_parse(&bind, params);
120 data = _e_ipc_mouse_binding_enc(&bind, &bytes);
121 ecore_ipc_server_send(_e_ipc_server,
122 E_IPC_DOMAIN_REQUEST,
123 E_IPC_OP_BINDING_MOUSE_ADD,
124 0/*ref*/, 0/*ref_to*/, 0/*response*/,
125 data, bytes);
126 free(data);
127}
128
129static void
130_e_opt_binding_mouse_del(char **params)
131{
132 E_Config_Binding_Mouse bind;
133 int bytes;
134 char *data;
135
136 _e_opt_binding_mouse_parse(&bind, params);
137 data = _e_ipc_mouse_binding_enc(&bind, &bytes);
138 ecore_ipc_server_send(_e_ipc_server,
139 E_IPC_DOMAIN_REQUEST,
140 E_IPC_OP_BINDING_MOUSE_DEL,
141 0/*ref*/, 0/*ref_to*/, 0/*response*/,
142 data, bytes);
143 free(data);
144}
145
146static void
147_e_opt_binding_key_parse(E_Config_Binding_Key *eb, char **params)
148{
149 if (!strcmp(params[0], "NONE")) eb->context = E_BINDING_CONTEXT_NONE;
150 else if (!strcmp(params[0], "UNKNOWN")) eb->context = E_BINDING_CONTEXT_UNKNOWN;
151 else if (!strcmp(params[0], "BORDER")) eb->context = E_BINDING_CONTEXT_BORDER;
152 else if (!strcmp(params[0], "ZONE")) eb->context = E_BINDING_CONTEXT_ZONE;
153 else if (!strcmp(params[0], "MANAGER")) eb->context = E_BINDING_CONTEXT_MANAGER;
154 else if (!strcmp(params[0], "ANY")) eb->context = E_BINDING_CONTEXT_ANY;
155 else
156 {
157 printf("OPT1 (CONTEXT) is not a valid context. Must be:\n"
158 " NONE UNKNOWN BORDER ZONE MANAGER ANY\n");
159 exit(-1);
160 }
161 eb->key = params[1];
162 /* M1[|M2...] */
163 {
164 char *p, *pp;
165
166 eb->modifiers = 0;
167 pp = params[2];
168 for (;;)
169 {
170 p = strchr(pp, '|');
171 if (p)
172 {
173 if (!strncmp(pp, "SHIFT|", 6)) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
174 else if (!strncmp(pp, "CTRL|", 5)) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
175 else if (!strncmp(pp, "ALT|", 4)) eb->modifiers |= E_BINDING_MODIFIER_ALT;
176 else if (!strncmp(pp, "WIN|", 4)) eb->modifiers |= E_BINDING_MODIFIER_WIN;
177 else
178 {
179 printf("OPT3 moidifier unknonw. Must be or mask of:\n"
180 " SHIFT CTRL ALT WIN\n");
181 exit(-1);
182 }
183 pp = p + 1;
184 }
185 else
186 {
187 if (!strcmp(pp, "SHIFT")) eb->modifiers |= E_BINDING_MODIFIER_SHIFT;
188 else if (!strcmp(pp, "CTRL")) eb->modifiers |= E_BINDING_MODIFIER_CTRL;
189 else if (!strcmp(pp, "ALT")) eb->modifiers |= E_BINDING_MODIFIER_ALT;
190 else if (!strcmp(pp, "WIN")) eb->modifiers |= E_BINDING_MODIFIER_WIN;
191 else
192 {
193 printf("OPT3 moidifier unknonw. Must be or mask of:\n"
194 " SHIFT CTRL ALT WIN\n");
195 exit(-1);
196 }
197 break;
198 }
199 }
200 }
201 eb->any_mod = atoi(params[3]);
202 eb->action = params[4];
203 eb->params = params[5];
204}
205
206static void
207_e_opt_binding_key_add(char **params)
208{
209 E_Config_Binding_Key bind;
210 int bytes;
211 char *data;
212
213 _e_opt_binding_key_parse(&bind, params);
214 data = _e_ipc_key_binding_enc(&bind, &bytes);
215 ecore_ipc_server_send(_e_ipc_server,
216 E_IPC_DOMAIN_REQUEST,
217 E_IPC_OP_BINDING_KEY_ADD,
218 0/*ref*/, 0/*ref_to*/, 0/*response*/,
219 data, bytes);
220 free(data);
221}
222
223static void
224_e_opt_binding_key_del(char **params)
225{
226 E_Config_Binding_Key bind;
227 int bytes;
228 char *data;
229
230 _e_opt_binding_key_parse(&bind, params);
231 data = _e_ipc_key_binding_enc(&bind, &bytes);
232 ecore_ipc_server_send(_e_ipc_server,
233 E_IPC_DOMAIN_REQUEST,
234 E_IPC_OP_BINDING_KEY_DEL,
235 0/*ref*/, 0/*ref_to*/, 0/*response*/,
236 data, bytes);
237 free(data);
238}
239
52#define SIMPLE_REQ 0 240#define SIMPLE_REQ 0
53#define SIMPLE_STR_REQ 1 241#define SIMPLE_STR_REQ 1
54#define FULL_FUNC 2 242#define FULL_FUNC 2
@@ -87,7 +275,11 @@ E_IPC_Opt_Handler handlers[] =
87 OREQ("-lang-list", "List all available languages", E_IPC_OP_LANG_LIST, 1), 275 OREQ("-lang-list", "List all available languages", E_IPC_OP_LANG_LIST, 1),
88 OSTR("-lang-set", "Set the current language", E_IPC_OP_LANG_SET, 0), 276 OSTR("-lang-set", "Set the current language", E_IPC_OP_LANG_SET, 0),
89 OREQ("-binding-mouse-list", "List all mouse bindings", E_IPC_OP_BINDING_MOUSE_LIST, 1), 277 OREQ("-binding-mouse-list", "List all mouse bindings", E_IPC_OP_BINDING_MOUSE_LIST, 1),
90 OREQ("-binding-key-list", "List all key bindings", E_IPC_OP_BINDING_KEY_LIST, 1) 278 OFNC("-binding-mouse-add", "Add or replace 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),
279 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),
280 OREQ("-binding-key-list", "List all key bindings", E_IPC_OP_BINDING_KEY_LIST, 1),
281 OFNC("-binding-key-add", "Add or replace 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),
282 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)
91}; 283};
92 284
93/* externally accessible functions */ 285/* externally accessible functions */