2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2009 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "e16-ecore_list.h"
36 typedef struct _actiontype {
38 struct _actiontype *next;
59 unsigned int ref_count;
63 static void UnGrabActionKey(Action * aa);
64 static void GrabActionKey(Action * aa);
66 static Ecore_List *aclass_list = NULL;
67 static Ecore_List *aclass_list_global = NULL;
69 static char mode_action_destroy = 0;
72 RemoveActionType(ActionType * ActionTypeToRemove)
76 ptr = ActionTypeToRemove;
87 ActionCreate(char event, char anymod, int mod, int anybut, int but,
88 char anykey, const char *key, const char *tooltipstring)
92 aa = EMALLOC(Action, 1);
95 aa->anymodifier = anymod;
97 aa->anybutton = anybut;
100 if (!key || !key[0] || (event != EVENT_KEY_DOWN && event != EVENT_KEY_UP))
103 aa->key = EKeynameToKeycode(key);
104 aa->key_str = (aa->key) ? Estrdup(key) : NULL;
106 (tooltipstring) ? Estrdup((tooltipstring[0]) ? tooltipstring : "?!?") :
113 ActionDestroy(Action * aa)
118 if ((aa->event == EVENT_KEY_DOWN) || (aa->event == EVENT_KEY_UP))
121 RemoveActionType(aa->action);
122 Efree(aa->tooltipstring);
128 ActionAddTo(Action * aa, const char *params)
130 ActionType *pptr, *ptr, *at;
132 at = EMALLOC(ActionType, 1);
137 at->params = (params && *params) ? Estrdup(params) : NULL;
157 ActionclassAddAction(ActionClass * ac, Action * aa)
160 ac->list = EREALLOC(Action *, ac->list, ac->num);
161 ac->list[ac->num - 1] = aa;
165 ActionclassCreate(const char *name, int global)
169 ac = ECALLOC(ActionClass, 1);
170 ac->name = Estrdup(name);
174 if (!aclass_list_global)
175 aclass_list_global = ecore_list_new();
176 ecore_list_prepend(aclass_list_global, ac);
182 aclass_list = ecore_list_new();
183 ecore_list_prepend(aclass_list, ac);
190 ActionclassEmpty(ActionClass * ac)
194 for (i = 0; i < ac->num; i++)
195 ActionDestroy(ac->list[i]);
198 _EFREE(ac->tooltipstring);
202 ActionclassDestroy(ActionClass * ac)
207 if (ac->ref_count > 0)
209 DialogOK("ActionClass Error!", _("%u references remain\n"),
214 ecore_list_node_remove(aclass_list, ac);
216 ActionclassEmpty(ac);
220 mode_action_destroy = 1;
224 _ActionclassMatchName(const void *data, const void *match)
226 return strcmp(((const ActionClass *)data)->name, (const char *)match);
230 ActionclassFindGlobal(const char *name)
232 return (ActionClass *) ecore_list_find(aclass_list_global,
233 _ActionclassMatchName, name);
237 ActionclassFind(const char *name)
241 return (ActionClass *) ecore_list_find(aclass_list, _ActionclassMatchName,
246 ActionclassFindAny(const char *name)
250 ac = (ActionClass *) ecore_list_find(aclass_list_global,
251 _ActionclassMatchName, name);
254 return (ActionClass *) ecore_list_find(aclass_list, _ActionclassMatchName,
259 AclassConfigLoad(FILE * fs)
262 ActionClass *ac = NULL;
264 char s[FILEPATH_LEN_MAX];
265 char s2[FILEPATH_LEN_MAX];
276 char *aclass_tooltipstring = NULL;
277 char *action_tooltipstring = NULL;
282 while (GetLine(s, sizeof(s), fs))
284 i1 = ConfigParseline1(s, s2, &p2, NULL);
290 case CONFIG_ACTIONCLASS:
292 if (i2 != CONFIG_OPEN)
297 anymod = anybut = anykey = 0;
305 (aclass_tooltipstring) ? Estrdup((aclass_tooltipstring[0]) ?
306 aclass_tooltipstring :
311 case CONFIG_CLASSNAME:
313 ac = ActionclassFindAny(s2);
316 if (!strcmp(s2, "KEYBINDINGS"))
317 Mode.keybinds_changed = 1;
318 ActionclassEmpty(ac);
322 ac = ActionclassCreate(s2, 0);
327 if (i2 == ACLASS_TYPE_ACLASS)
329 ecore_list_node_remove(aclass_list, ActionclassFind(s2));
330 ecore_list_prepend(aclass_list_global, ac);
334 case CONFIG_MODIFIER:
335 case ACLASS_MODIFIER:
336 /* These are the defines that I have listed...
337 * These, therefore, are the ones that I am
338 * going to accept by default.
339 * REMINDER: add and'ing in future!!!!
340 * #define ShiftMask (1<<0)
341 * #define LockMask (1<<1)
342 * #define ControlMask (1<<2)
343 * #define Mod1Mask (1<<3)
344 * #define Mod2Mask (1<<4)
345 * #define Mod3Mask (1<<5)
346 * #define Mod4Mask (1<<6)
347 * #define Mod5Mask (1<<7)
379 mod |= ControlMask | Mod1Mask;
382 mod |= ShiftMask | Mod1Mask;
384 case MASK_CTRL_SHIFT:
385 mod |= ShiftMask | ControlMask;
387 case MASK_CTRL_SHIFT_ALT:
388 mod |= ShiftMask | ControlMask | Mod1Mask;
390 case MASK_SHIFT_META4:
391 mod |= Mod4Mask | ShiftMask;
393 case MASK_CTRL_META4:
394 mod |= Mod4Mask | ControlMask;
396 case MASK_CTRL_META4_SHIFT:
397 mod |= Mod4Mask | ControlMask | ShiftMask;
399 case MASK_SHIFT_META5:
400 mod |= Mod5Mask | ShiftMask;
402 case MASK_CTRL_META5:
403 mod |= Mod5Mask | ControlMask;
405 case MASK_CTRL_META5_SHIFT:
406 mod |= Mod5Mask | ControlMask | ShiftMask;
408 case MASK_WINDOWS_SHIFT:
409 mod |= Mod2Mask | ShiftMask;
411 case MASK_WINDOWS_CTRL:
412 mod |= Mod2Mask | ControlMask;
414 case MASK_WINDOWS_ALT:
415 mod |= Mod2Mask | Mod1Mask;
440 case ACLASS_EVENT_TRIGGER:
452 aa = ActionCreate(event, anymod, mod, anybut, but, anykey,
453 key, action_tooltipstring);
454 /* the correct place to grab an action key */
455 Efree(action_tooltipstring);
456 action_tooltipstring = NULL;
460 ActionclassAddAction(ac, aa);
465 case CONFIG_ACTION_TOOLTIP:
466 action_tooltipstring = Estrdupcat2(action_tooltipstring, "\n", p2);
469 aclass_tooltipstring = Estrdupcat2(aclass_tooltipstring, "\n", p2);
472 ConfigParseError("ActionClass", s);
478 ActionclassDestroy(ac);
481 Efree(aclass_tooltipstring);
482 Efree(action_tooltipstring);
488 ActionDecode(const char *line)
491 char ev[16], mod[16], key[128], *s;
492 int len, event, modifiers, button;
493 char anymod, anybut, anykey;
496 sscanf(line, "%15s %15s %127s %n", ev, mod, key, &len);
501 if (!strcmp(ev, "KeyDown"))
502 event = EVENT_KEY_DOWN;
503 else if (!strcmp(ev, "MouseDown"))
504 event = EVENT_MOUSE_DOWN;
505 else if (!strcmp(ev, "KeyUp"))
506 event = EVENT_KEY_UP;
507 else if (!strcmp(ev, "MouseUp"))
508 event = EVENT_MOUSE_UP;
509 else if (!strcmp(ev, "MouseDouble"))
510 event = EVENT_DOUBLE_DOWN;
511 else if (!strcmp(ev, "MouseIn"))
512 event = EVENT_MOUSE_ENTER;
513 else if (!strcmp(ev, "MouseOut"))
514 event = EVENT_MOUSE_LEAVE;
515 else if (!strcmp(ev, "FocusIn"))
516 event = EVENT_FOCUS_IN;
517 else if (!strcmp(ev, "FocusOut"))
518 event = EVENT_FOCUS_OUT;
520 anymod = anybut = anykey = 0;
524 for (s = mod; *s; s++)
532 modifiers |= ControlMask;
535 modifiers |= ShiftMask;
538 modifiers |= Mod1Mask;
541 modifiers |= Mod1Mask;
544 modifiers |= Mod2Mask;
547 modifiers |= Mod3Mask;
550 modifiers |= Mod4Mask;
553 modifiers |= Mod5Mask;
560 case EVENT_MOUSE_DOWN:
562 case EVENT_DOUBLE_DOWN:
563 case EVENT_MOUSE_ENTER:
564 case EVENT_MOUSE_LEAVE:
567 else if (isdigit(key[0]))
569 if (!anybut && button == 0)
570 return NULL; /* Invalid */
576 ActionCreate(event, anymod, modifiers, anybut, button, anykey, key, NULL);
577 ActionAddTo(aa, line + len);
583 ActionEncode(Action * aa, char *buf, int len)
586 char *p, mod[32], btn[32];
588 if (!aa || !aa->action)
594 if (aa->modifiers & ControlMask)
596 if (aa->modifiers & ShiftMask)
598 if (aa->modifiers & Mod1Mask)
600 if (aa->modifiers & Mod2Mask)
602 if (aa->modifiers & Mod3Mask)
604 if (aa->modifiers & Mod4Mask)
606 if (aa->modifiers & Mod5Mask)
625 len = Esnprintf(buf, len, "%-7s %4s %8s %s\n", event, mod, aa->key_str,
626 (aa->action->params) ? aa->action->params : "");
629 case EVENT_MOUSE_DOWN:
635 case EVENT_DOUBLE_DOWN:
636 event = "MouseDouble";
638 case EVENT_MOUSE_ENTER:
641 case EVENT_MOUSE_LEAVE:
648 sprintf(btn, "%u", aa->button);
649 len = Esnprintf(buf, len, "%-11s %4s %s %s\n", event, mod, btn,
650 (aa->action->params) ? aa->action->params : "");
656 case EVENT_FOCUS_OUT:
667 AclassEncodeTT(const char *str, char *buf, int len)
672 lst = StrlistFromString(str, '\n', &num);
674 for (i = 0; i < num; i++)
676 l = Esnprintf(buf, len, "Tooltip %s\n", lst[i]);
681 StrlistFree(lst, num);
686 AclassConfigLoad2(FILE * fs)
688 char s[FILEPATH_LEN_MAX], *ss;
689 char prm1[128], prm2[128], prm3[128];
690 ActionClass *ac = NULL;
696 ss = fgets(s, sizeof(s), fs);
700 len = strcspn(s, "#\r\n");
707 len = sscanf(s, "%16s %n%128s %16s", prm1, &len2, prm2, prm3);
711 if (!strcmp(prm1, "Aclass"))
713 if (!strcmp(prm2, "KEYBINDINGS_UNCHANGABLE"))
715 /* No more "unchangable" keybindings. */
716 ac = ActionclassFindGlobal("KEYBINDINGS");
721 ac = ActionclassFindAny(prm2);
723 ActionclassEmpty(ac);
727 ac = ActionclassCreate(prm2, prm3[0] == 'g');
731 else if (!strncmp(prm1, "Key", 3) || !strncmp(prm1, "Mouse", 5))
736 aa = ActionDecode(s);
740 ActionclassAddAction(ac, aa);
743 else if (!strcmp(prm1, "Tooltip"))
745 /* FIXME - Multiple line strings may break */
749 Estrdupcat2(aa->tooltipstring, "\n", s + len2);
754 Estrdupcat2(ac->tooltipstring, "\n", s + len2);
761 AclassConfigLoadConfig(const char *name)
766 file = ConfigFileFind(name, NULL, 0);
770 fs = fopen(file, "r");
775 AclassConfigLoad2(fs);
781 AclassConfigWrite(const ActionClass * ac, void (*prf) (const char *fmt, ...))
783 char s[FILEPATH_LEN_MAX];
787 if (!ac || ac->num <= 0)
790 prf("Aclass %s %s\n", ac->name, (ac->global)? "global" : "normal");
791 if (ac->tooltipstring)
793 len = AclassEncodeTT(ac->tooltipstring, s, sizeof(s));
796 for (i = 0; i < ac->num; i++)
799 len = ActionEncode(aa, s, sizeof(s));
803 if (aa->tooltipstring)
805 len = AclassEncodeTT(aa->tooltipstring, s, sizeof(s));
811 static FILE *_ac_fs = NULL; /* Ugly! Yeah well... */
814 _ac_prf(const char *fmt, ...)
820 len = vfprintf(_ac_fs, fmt, args);
827 char s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX];
830 if (!Mode.keybinds_changed)
839 AclassConfigWrite(ActionclassFind("BUTTONBINDINGS"), _ac_prf);
840 AclassConfigWrite(ActionclassFind("DESKBINDINGS"), _ac_prf);
841 AclassConfigWrite(ActionclassFindGlobal("KEYBINDINGS"), _ac_prf);
842 AclassConfigWrite(ActionclassFindGlobal("KEYBINDINGS_UNCHANGABLE"), _ac_prf);
847 Esnprintf(s, sizeof(s), "%s/bindings.cfg", EDirUser());
852 ActionclassSetTooltipString(ActionClass * ac, const char *tts)
854 _EFDUP(ac->tooltipstring, tts);
858 ActionclassAlloc(const char *name)
862 if (!name || !name[0])
865 ac = ActionclassFind(name);
873 ActionclassFree(ActionClass * ac)
880 ActionclassGetName(ActionClass * ac)
882 return (ac) ? ac->name : NULL;
886 ActionclassGetTooltipString(ActionClass * ac)
888 return (ac) ? ac->tooltipstring : NULL;
892 ActionclassGetActionCount(ActionClass * ac)
894 return (ac) ? ac->num : 0;
898 ActionclassGetAction(ActionClass * ac, int ix)
900 return (ac && ix < ac->num) ? ac->list[ix] : NULL;
904 ActionGetTooltipString(Action * aa)
906 return (aa) ? aa->tooltipstring : NULL;
910 ActionGetEvent(Action * aa)
912 return (aa) ? aa->event : 0;
916 ActionGetAnybutton(Action * aa)
918 return (aa) ? aa->anybutton : 0;
922 ActionGetButton(Action * aa)
924 return (aa) ? aa->button : 0;
928 ActionGetModifiers(Action * aa)
930 return (aa) ? aa->modifiers : 0;
934 handleAction(EWin * ewin, ActionType * action)
937 ewin->state.in_action = 1;
938 EFunc(ewin, action->params);
940 ewin->state.in_action = 0;
942 /* Did we just hose ourselves? if so, we'd best not stick around here */
943 if (mode_action_destroy)
946 /* If there is another action in this series, (now that
947 * we're sure we didn't already die) perform it
950 handleAction(ewin, action->next);
954 ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin)
957 int i, type, button, modifiers, ok, mouse, mask, val = 0;
960 if (Mode.action_inhibit || (ewin && ewin->state.inhibit_actions))
963 key = type = button = modifiers = mouse = 0;
965 mask = Mode.masks.mod_key_mask;
970 type = EVENT_KEY_DOWN;
971 key = ev->xkey.keycode;
972 modifiers = ev->xbutton.state & mask;
977 key = ev->xkey.keycode;
978 modifiers = ev->xbutton.state & mask;
982 if (Mode.events.double_click)
983 type = EVENT_DOUBLE_DOWN;
985 type = EVENT_MOUSE_DOWN;
986 button = ev->xbutton.button;
987 modifiers = ev->xbutton.state & mask;
991 type = EVENT_MOUSE_UP;
992 button = ev->xbutton.button;
993 modifiers = ev->xbutton.state & mask;
997 type = EVENT_MOUSE_ENTER;
999 modifiers = ev->xcrossing.state & mask;
1003 /* If frame window, quit if pointer is still inside */
1004 if (ewin && ev->xcrossing.window == EoGetXwin(ewin) &&
1005 (ev->xcrossing.x >= 0 && ev->xcrossing.x < EoGetW(ewin) &&
1006 ev->xcrossing.y >= 0 && ev->xcrossing.y < EoGetH(ewin)))
1008 type = EVENT_MOUSE_LEAVE;
1010 modifiers = ev->xcrossing.state & mask;
1014 type = EVENT_FOCUS_IN;
1019 type = EVENT_FOCUS_OUT;
1027 mode_action_destroy = 0;
1029 for (i = 0; i < ac->num; i++)
1031 if (!mode_action_destroy)
1035 if ((aa->event == type) && (aa->action))
1041 if (aa->anymodifier)
1043 else if (aa->modifiers == modifiers)
1048 if (aa->anymodifier)
1052 else if (aa->button == button)
1055 else if (aa->modifiers == modifiers)
1059 else if (aa->button == button)
1066 if (aa->anymodifier)
1070 else if (aa->key == key)
1073 else if (aa->modifiers == modifiers)
1077 else if (aa->key == key)
1083 handleAction(ewin, aa->action);
1088 if (mode_action_destroy)
1092 mode_action_destroy = 0;
1098 ActionclassesGlobalEvent(XEvent * ev)
1104 ECORE_LIST_FOR_EACH(aclass_list_global, ac)
1105 match |= ActionclassEvent(ac, ev, GetFocusEwin());
1110 static Timer *ac_reload_timer = NULL;
1113 _ac_reload(void *data __UNUSED__)
1115 AclassConfigLoadConfig("bindings.cfg");
1116 ac_reload_timer = NULL;
1121 ActionclassesReload(void)
1123 TIMER_DEL(ac_reload_timer);
1124 TIMER_ADD(ac_reload_timer, 0.2, _ac_reload, NULL);
1132 AclassSighan(int sig, void *prm __UNUSED__)
1137 AclassConfigLoadConfig("bindings.cfg");
1143 AclassIpc(const char *params)
1146 char cmd[128], prm[4096];
1150 cmd[0] = prm[0] = '\0';
1155 sscanf(p, "%100s %4000s %n", cmd, prm, &len);
1159 if (!p || cmd[0] == '\0' || cmd[0] == '?')
1162 else if (!strncmp(cmd, "kb", 2))
1164 AclassConfigWrite(ActionclassFindGlobal("KEYBINDINGS"), IpcPrintf);
1166 else if (!strncmp(cmd, "list", 2))
1170 IpcPrintf("Normal:\n");
1171 ECORE_LIST_FOR_EACH(aclass_list, ac) IpcPrintf("%s\n", ac->name);
1172 IpcPrintf("Global:\n");
1173 ECORE_LIST_FOR_EACH(aclass_list_global, ac) IpcPrintf("%s\n",
1176 else if (!strcmp(prm, "all"))
1178 ECORE_LIST_FOR_EACH(aclass_list, ac)
1181 AclassConfigWrite(ac, IpcPrintf);
1183 ECORE_LIST_FOR_EACH(aclass_list_global, ac)
1186 AclassConfigWrite(ac, IpcPrintf);
1191 AclassConfigWrite(ActionclassFindAny(prm), IpcPrintf);
1194 else if (!strcmp(cmd, "load"))
1197 AclassConfigLoadConfig("bindings.cfg");
1199 AclassConfigLoadConfig(prm);
1203 /* Should only be used via e16keyedit */
1205 IPC_KeybindingsGet(const char *params __UNUSED__)
1211 ac = ActionclassFindGlobal("KEYBINDINGS");
1215 for (i = 0; i < ac->num; i++)
1218 if ((aa) && (aa->action) && (aa->event == EVENT_KEY_DOWN))
1222 key = EKeycodeToString(aa->key, 0);
1227 if (aa->modifiers == (ControlMask))
1229 else if (aa->modifiers == (Mod1Mask))
1231 else if (aa->modifiers == (ShiftMask))
1233 else if (aa->modifiers == (ControlMask | Mod1Mask))
1235 else if (aa->modifiers == (ShiftMask | ControlMask))
1237 else if (aa->modifiers == (ShiftMask | Mod1Mask))
1239 else if (aa->modifiers == (ShiftMask | ControlMask | Mod1Mask))
1241 else if (aa->modifiers == (Mod2Mask))
1243 else if (aa->modifiers == (Mod3Mask))
1245 else if (aa->modifiers == (Mod4Mask))
1247 else if (aa->modifiers == (Mod5Mask))
1249 else if (aa->modifiers == (Mod2Mask | ShiftMask))
1251 else if (aa->modifiers == (Mod2Mask | ControlMask))
1253 else if (aa->modifiers == (Mod2Mask | Mod1Mask))
1255 else if (aa->modifiers == (Mod4Mask | ShiftMask))
1257 else if (aa->modifiers == (Mod4Mask | ControlMask))
1259 else if (aa->modifiers == (Mod4Mask | ControlMask | ShiftMask))
1261 else if (aa->modifiers == (Mod5Mask | ShiftMask))
1263 else if (aa->modifiers == (Mod5Mask | ControlMask))
1265 else if (aa->modifiers == (Mod5Mask | ControlMask | ShiftMask))
1268 if (aa->action->params)
1269 IpcPrintf("%s %i %i %s\n", key, mod, 0, aa->action->params);
1271 IpcPrintf("%s %i %i\n", key, mod, 0);
1276 /* Should only be used via e16keyedit */
1278 IPC_KeybindingsSet(const char *params)
1283 char buf[FILEPATH_LEN_MAX];
1284 const char *sp, *ss;
1290 Mode.keybinds_changed = 1;
1292 ac = ActionclassFindGlobal("KEYBINDINGS");
1294 ActionclassEmpty(ac);
1296 ac = ActionclassCreate("KEYBINDINGS", 1);
1309 /* put line in buf */
1311 while ((sp[j]) && (sp[j] != '\n'))
1321 /* parse the line */
1323 sscanf(buf, "%250s %i %i %n", key, &mod, &act_id, &len);
1333 mod = ControlMask | Mod1Mask;
1335 mod = ShiftMask | ControlMask;
1337 mod = ShiftMask | Mod1Mask;
1339 mod = ShiftMask | ControlMask | Mod1Mask;
1349 mod = Mod2Mask | ShiftMask;
1351 mod = Mod2Mask | ControlMask;
1353 mod = Mod2Mask | Mod1Mask;
1355 mod = Mod4Mask | ShiftMask;
1357 mod = Mod4Mask | ControlMask;
1359 mod = Mod4Mask | ControlMask | ShiftMask;
1361 mod = Mod5Mask | ShiftMask;
1363 mod = Mod5Mask | ControlMask;
1365 mod = Mod5Mask | ControlMask | ShiftMask;
1367 aa = ActionCreate(4, 0, mod, 0, 0, 0, key, NULL);
1368 ActionclassAddAction(ac, aa);
1369 ActionAddTo(aa, buf + len);
1376 static const IpcItem AclassIpcArray[] = {
1380 "Action class functions",
1381 " aclass kb List key bindings\n"
1382 " aclass list [name/all] List action class[es]\n"
1383 " aclass load [name] Reload action classes (default is bindings.cfg)\n"}
1386 IPC_KeybindingsGet, "get_keybindings", NULL,
1387 "List keybindings (deprecated)", NULL}
1390 IPC_KeybindingsSet, "set_keybindings", NULL, "Set keybindings (deprecated)",
1394 #define N_IPC_FUNCS (sizeof(AclassIpcArray)/sizeof(IpcItem))
1399 extern const EModule ModAclass;
1400 const EModule ModAclass = {
1403 {N_IPC_FUNCS, AclassIpcArray},
1408 GrabButtonGrabs(Win win)
1413 unsigned int mod, button, mask;
1415 ac = ActionclassFind("BUTTONBINDINGS");
1420 for (j = 0; j < ac->num; j++)
1423 if ((!aa) || ((aa->event != EVENT_MOUSE_DOWN) &&
1424 (aa->event != EVENT_MOUSE_UP)))
1427 mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
1428 button = (aa->anybutton) ? AnyButton : aa->button;
1429 mask = ButtonPressMask | ButtonReleaseMask;
1431 GrabButtonSet(button, mod, win, mask, ECSR_PGRAB, 1);
1436 UnGrabButtonGrabs(Win win)
1441 unsigned int mod, button;
1443 ac = ActionclassFind("BUTTONBINDINGS");
1448 for (j = 0; j < ac->num; j++)
1451 if ((!aa) || ((aa->event != EVENT_MOUSE_DOWN)
1452 && (aa->event != EVENT_MOUSE_UP)))
1455 mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
1456 button = (aa->anybutton) ? AnyButton : aa->button;
1458 GrabButtonRelease(button, mod, win);
1463 GrabActionKey(Action * aa)
1470 mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
1472 GrabKeySet(aa->key, mod, VROOT);
1476 UnGrabActionKey(Action * aa)
1483 mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
1485 GrabKeyRelease(aa->key, mod, VROOT);