2004-12-28 15:46:49 -08:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
2009-05-12 14:21:21 -07:00
|
|
|
* Copyright (C) 2004-2009 Kim Woelders
|
2004-12-28 15:46:49 -08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include "E.h"
|
2005-11-27 05:11:06 -08:00
|
|
|
#include "aclass.h"
|
2004-12-28 15:46:49 -08:00
|
|
|
#include "conf.h"
|
2006-11-19 13:55:52 -08:00
|
|
|
#include "cursors.h"
|
2006-02-18 00:30:09 -08:00
|
|
|
#include "e16-ecore_list.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "emodule.h"
|
|
|
|
#include "ewins.h"
|
2006-07-24 14:10:59 -07:00
|
|
|
#include "file.h"
|
2006-11-19 13:55:52 -08:00
|
|
|
#include "grabs.h"
|
2008-12-30 08:19:33 -08:00
|
|
|
#include "timers.h"
|
2006-03-11 00:43:15 -08:00
|
|
|
#include <ctype.h>
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
typedef struct _actiontype {
|
2004-12-28 15:46:49 -08:00
|
|
|
char *params;
|
|
|
|
struct _actiontype *next;
|
2008-03-23 04:54:24 -07:00
|
|
|
} ActionType;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
struct _action {
|
2004-12-28 15:46:49 -08:00
|
|
|
char event;
|
|
|
|
char anymodifier;
|
|
|
|
int modifiers;
|
|
|
|
char anybutton;
|
|
|
|
int button;
|
|
|
|
char anykey;
|
|
|
|
KeyCode key;
|
|
|
|
char *key_str;
|
|
|
|
char *tooltipstring;
|
|
|
|
ActionType *action;
|
|
|
|
};
|
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
struct _actionclass {
|
2004-12-28 15:46:49 -08:00
|
|
|
char *name;
|
|
|
|
int num;
|
|
|
|
Action **list;
|
|
|
|
char *tooltipstring;
|
|
|
|
unsigned int ref_count;
|
2006-03-30 13:30:50 -08:00
|
|
|
char global;
|
2004-12-28 15:46:49 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void UnGrabActionKey(Action * aa);
|
|
|
|
static void GrabActionKey(Action * aa);
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static Ecore_List *aclass_list = NULL;
|
|
|
|
static Ecore_List *aclass_list_global = NULL;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static char mode_action_destroy = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
RemoveActionType(ActionType * ActionTypeToRemove)
|
|
|
|
{
|
|
|
|
ActionType *ptr, *pp;
|
|
|
|
|
|
|
|
ptr = ActionTypeToRemove;
|
|
|
|
while (ptr)
|
|
|
|
{
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(ptr->params);
|
2004-12-28 15:46:49 -08:00
|
|
|
pp = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
Efree(pp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Action *
|
|
|
|
ActionCreate(char event, char anymod, int mod, int anybut, int but,
|
|
|
|
char anykey, const char *key, const char *tooltipstring)
|
|
|
|
{
|
|
|
|
Action *aa;
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
aa = EMALLOC(Action, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
aa->action = NULL;
|
|
|
|
aa->event = event;
|
|
|
|
aa->anymodifier = anymod;
|
|
|
|
aa->modifiers = mod;
|
|
|
|
aa->anybutton = anybut;
|
|
|
|
aa->button = but;
|
|
|
|
aa->anykey = anykey;
|
|
|
|
if (!key || !key[0] || (event != EVENT_KEY_DOWN && event != EVENT_KEY_UP))
|
|
|
|
aa->key = 0;
|
|
|
|
else
|
2008-03-30 05:13:16 -07:00
|
|
|
aa->key = EKeynameToKeycode(key);
|
2004-12-28 15:46:49 -08:00
|
|
|
aa->key_str = (aa->key) ? Estrdup(key) : NULL;
|
|
|
|
aa->tooltipstring =
|
2005-08-14 14:25:46 -07:00
|
|
|
(tooltipstring) ? Estrdup((tooltipstring[0]) ? tooltipstring : "?!?") :
|
2004-12-28 15:46:49 -08:00
|
|
|
NULL;
|
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return aa;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ActionDestroy(Action * aa)
|
|
|
|
{
|
|
|
|
if (!aa)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if ((aa->event == EVENT_KEY_DOWN) || (aa->event == EVENT_KEY_UP))
|
|
|
|
UnGrabActionKey(aa);
|
|
|
|
if (aa->action)
|
|
|
|
RemoveActionType(aa->action);
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(aa->tooltipstring);
|
|
|
|
Efree(aa->key_str);
|
2004-12-28 15:46:49 -08:00
|
|
|
Efree(aa);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ActionAddTo(Action * aa, const char *params)
|
|
|
|
{
|
|
|
|
ActionType *pptr, *ptr, *at;
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
at = EMALLOC(ActionType, 1);
|
2005-10-30 11:40:49 -08:00
|
|
|
if (!at)
|
|
|
|
return;
|
2007-02-25 12:44:22 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
at->next = NULL;
|
2007-02-25 12:44:22 -08:00
|
|
|
at->params = (params && *params) ? Estrdup(params) : NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!aa->action)
|
|
|
|
{
|
|
|
|
aa->action = at;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-30 11:40:49 -08:00
|
|
|
pptr = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
ptr = aa->action;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
pptr = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
2005-10-30 11:40:49 -08:00
|
|
|
if (pptr)
|
|
|
|
pptr->next = at;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ActionclassAddAction(ActionClass * ac, Action * aa)
|
|
|
|
{
|
|
|
|
ac->num++;
|
2007-01-16 17:10:44 -08:00
|
|
|
ac->list = EREALLOC(Action *, ac->list, ac->num);
|
2004-12-28 15:46:49 -08:00
|
|
|
ac->list[ac->num - 1] = aa;
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionClass *
|
|
|
|
ActionclassCreate(const char *name, int global)
|
|
|
|
{
|
|
|
|
ActionClass *ac;
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
ac = ECALLOC(ActionClass, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
ac->name = Estrdup(name);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
|
|
|
if (global)
|
|
|
|
{
|
|
|
|
if (!aclass_list_global)
|
|
|
|
aclass_list_global = ecore_list_new();
|
|
|
|
ecore_list_prepend(aclass_list_global, ac);
|
2006-03-30 13:30:50 -08:00
|
|
|
ac->global = 1;
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!aclass_list)
|
|
|
|
aclass_list = ecore_list_new();
|
|
|
|
ecore_list_prepend(aclass_list, ac);
|
|
|
|
}
|
2005-01-25 13:58:28 -08:00
|
|
|
|
|
|
|
return ac;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2008-02-23 04:13:28 -08:00
|
|
|
static void
|
2008-12-14 08:44:39 -08:00
|
|
|
ActionclassEmpty(ActionClass * ac)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-12-14 08:44:39 -08:00
|
|
|
for (i = 0; i < ac->num; i++)
|
|
|
|
ActionDestroy(ac->list[i]);
|
|
|
|
ac->num = 0;
|
|
|
|
_EFREE(ac->list);
|
|
|
|
_EFREE(ac->tooltipstring);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ActionclassDestroy(ActionClass * ac)
|
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!ac)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (ac->ref_count > 0)
|
|
|
|
{
|
2006-12-09 13:32:03 -08:00
|
|
|
DialogOK("ActionClass Error!", _("%u references remain\n"),
|
2004-12-28 15:46:49 -08:00
|
|
|
ac->ref_count);
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2007-07-25 13:02:57 -07:00
|
|
|
ecore_list_node_remove(aclass_list, ac);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-12-14 08:44:39 -08:00
|
|
|
ActionclassEmpty(ac);
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(ac->name);
|
2008-02-23 04:13:28 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Efree(ac);
|
|
|
|
mode_action_destroy = 1;
|
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static int
|
|
|
|
_ActionclassMatchName(const void *data, const void *match)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
return strcmp(((const ActionClass *)data)->name, (const char *)match);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
static ActionClass *
|
|
|
|
ActionclassFindGlobal(const char *name)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
return (ActionClass *) ecore_list_find(aclass_list_global,
|
|
|
|
_ActionclassMatchName, name);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
ActionClass *
|
|
|
|
ActionclassFind(const char *name)
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
if (!name)
|
|
|
|
return NULL;
|
2007-01-16 17:10:44 -08:00
|
|
|
return (ActionClass *) ecore_list_find(aclass_list, _ActionclassMatchName,
|
|
|
|
name);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
static ActionClass *
|
|
|
|
ActionclassFindAny(const char *name)
|
|
|
|
{
|
|
|
|
ActionClass *ac;
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
ac = (ActionClass *) ecore_list_find(aclass_list_global,
|
|
|
|
_ActionclassMatchName, name);
|
2006-03-30 13:30:50 -08:00
|
|
|
if (ac)
|
|
|
|
return ac;
|
2007-01-16 17:10:44 -08:00
|
|
|
return (ActionClass *) ecore_list_find(aclass_list, _ActionclassMatchName,
|
|
|
|
name);
|
2006-03-30 13:30:50 -08:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
int
|
|
|
|
AclassConfigLoad(FILE * fs)
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
ActionClass *ac = NULL;
|
|
|
|
Action *aa = NULL;
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
char s2[FILEPATH_LEN_MAX];
|
2007-07-27 09:59:50 -07:00
|
|
|
char *p2;
|
|
|
|
int i1, i2;
|
2004-12-28 15:46:49 -08:00
|
|
|
char event = 0;
|
|
|
|
char anymod = 0;
|
|
|
|
int mod = 0;
|
|
|
|
int anybut = 0;
|
|
|
|
int but = 0;
|
|
|
|
int first = 1;
|
|
|
|
char anykey = 0;
|
2007-07-27 09:59:50 -07:00
|
|
|
char key[64];
|
2004-12-28 15:46:49 -08:00
|
|
|
char *aclass_tooltipstring = NULL;
|
|
|
|
char *action_tooltipstring = NULL;
|
|
|
|
char global = 0;
|
2007-07-27 09:59:50 -07:00
|
|
|
|
|
|
|
key[0] = '\0';
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
while (GetLine(s, sizeof(s), fs))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
i1 = ConfigParseline1(s, s2, &p2, NULL);
|
|
|
|
i2 = atoi(s2);
|
2004-12-28 15:46:49 -08:00
|
|
|
switch (i1)
|
|
|
|
{
|
|
|
|
case CONFIG_VERSION:
|
|
|
|
break;
|
|
|
|
case CONFIG_ACTIONCLASS:
|
|
|
|
err = -1;
|
2007-07-27 09:59:50 -07:00
|
|
|
if (i2 != CONFIG_OPEN)
|
2004-12-28 15:46:49 -08:00
|
|
|
goto done;
|
|
|
|
ac = NULL;
|
|
|
|
aa = NULL;
|
|
|
|
event = 0;
|
|
|
|
anymod = anybut = anykey = 0;
|
|
|
|
mod = 0;
|
|
|
|
but = 0;
|
|
|
|
first = 1;
|
2007-07-27 09:59:50 -07:00
|
|
|
key[0] = '\0';
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_CLOSE:
|
|
|
|
ac->tooltipstring =
|
|
|
|
(aclass_tooltipstring) ? Estrdup((aclass_tooltipstring[0]) ?
|
2005-08-14 14:25:46 -07:00
|
|
|
aclass_tooltipstring :
|
2004-12-28 15:46:49 -08:00
|
|
|
"?!?") : NULL;
|
|
|
|
err = 0;
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
case CONFIG_CLASSNAME:
|
|
|
|
case ACLASS_NAME:
|
2008-12-14 08:44:39 -08:00
|
|
|
ac = ActionclassFindAny(s2);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (ac)
|
|
|
|
{
|
|
|
|
if (!strcmp(s2, "KEYBINDINGS"))
|
|
|
|
Mode.keybinds_changed = 1;
|
2008-12-14 08:44:39 -08:00
|
|
|
ActionclassEmpty(ac);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ac = ActionclassCreate(s2, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONFIG_TYPE:
|
|
|
|
case ACLASS_TYPE:
|
2007-07-27 09:59:50 -07:00
|
|
|
if (i2 == ACLASS_TYPE_ACLASS)
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
2007-07-25 13:02:57 -07:00
|
|
|
ecore_list_node_remove(aclass_list, ActionclassFind(s2));
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_prepend(aclass_list_global, ac);
|
2004-12-28 15:46:49 -08:00
|
|
|
global = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case CONFIG_MODIFIER:
|
|
|
|
case ACLASS_MODIFIER:
|
|
|
|
/* These are the defines that I have listed...
|
|
|
|
* These, therefore, are the ones that I am
|
|
|
|
* going to accept by default.
|
|
|
|
* REMINDER: add and'ing in future!!!!
|
|
|
|
* #define ShiftMask (1<<0)
|
|
|
|
* #define LockMask (1<<1)
|
|
|
|
* #define ControlMask (1<<2)
|
|
|
|
* #define Mod1Mask (1<<3)
|
|
|
|
* #define Mod2Mask (1<<4)
|
|
|
|
* #define Mod3Mask (1<<5)
|
|
|
|
* #define Mod4Mask (1<<6)
|
|
|
|
* #define Mod5Mask (1<<7)
|
|
|
|
*/
|
2007-07-27 09:59:50 -07:00
|
|
|
switch (i2)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
case MASK_NONE:
|
|
|
|
mod = 0;
|
|
|
|
break;
|
|
|
|
case MASK_SHIFT:
|
|
|
|
mod |= ShiftMask;
|
|
|
|
break;
|
|
|
|
case MASK_LOCK:
|
|
|
|
mod |= LockMask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL:
|
|
|
|
mod |= ControlMask;
|
|
|
|
break;
|
|
|
|
case MASK_MOD1:
|
|
|
|
mod |= Mod1Mask;
|
|
|
|
break;
|
|
|
|
case MASK_MOD2:
|
|
|
|
mod |= Mod2Mask;
|
|
|
|
break;
|
|
|
|
case MASK_MOD3:
|
|
|
|
mod |= Mod3Mask;
|
|
|
|
break;
|
|
|
|
case MASK_MOD4:
|
|
|
|
mod |= Mod4Mask;
|
|
|
|
break;
|
|
|
|
case MASK_MOD5:
|
|
|
|
mod |= Mod5Mask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_ALT:
|
|
|
|
mod |= ControlMask | Mod1Mask;
|
|
|
|
break;
|
|
|
|
case MASK_SHIFT_ALT:
|
|
|
|
mod |= ShiftMask | Mod1Mask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_SHIFT:
|
|
|
|
mod |= ShiftMask | ControlMask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_SHIFT_ALT:
|
|
|
|
mod |= ShiftMask | ControlMask | Mod1Mask;
|
|
|
|
break;
|
|
|
|
case MASK_SHIFT_META4:
|
|
|
|
mod |= Mod4Mask | ShiftMask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_META4:
|
|
|
|
mod |= Mod4Mask | ControlMask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_META4_SHIFT:
|
|
|
|
mod |= Mod4Mask | ControlMask | ShiftMask;
|
|
|
|
break;
|
|
|
|
case MASK_SHIFT_META5:
|
|
|
|
mod |= Mod5Mask | ShiftMask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_META5:
|
|
|
|
mod |= Mod5Mask | ControlMask;
|
|
|
|
break;
|
|
|
|
case MASK_CTRL_META5_SHIFT:
|
|
|
|
mod |= Mod5Mask | ControlMask | ShiftMask;
|
|
|
|
break;
|
|
|
|
case MASK_WINDOWS_SHIFT:
|
|
|
|
mod |= Mod2Mask | ShiftMask;
|
|
|
|
break;
|
|
|
|
case MASK_WINDOWS_CTRL:
|
|
|
|
mod |= Mod2Mask | ControlMask;
|
|
|
|
break;
|
|
|
|
case MASK_WINDOWS_ALT:
|
|
|
|
mod |= Mod2Mask | Mod1Mask;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONFIG_ANYMOD:
|
|
|
|
case ACLASS_ANYMOD:
|
2007-07-27 09:59:50 -07:00
|
|
|
anymod = i2;
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_ANYBUT:
|
|
|
|
case ACLASS_ANYBUT:
|
2007-07-27 09:59:50 -07:00
|
|
|
anybut = i2;
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_BUTTON:
|
|
|
|
case ACLASS_BUT:
|
2007-07-27 09:59:50 -07:00
|
|
|
but = i2;
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_ANYKEY:
|
|
|
|
case ACLASS_ANYKEY:
|
2007-07-27 09:59:50 -07:00
|
|
|
anykey = i2;
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case ACLASS_KEY:
|
2007-07-27 09:59:50 -07:00
|
|
|
STRCPY(key, s2);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case ACLASS_EVENT_TRIGGER:
|
2007-07-27 09:59:50 -07:00
|
|
|
event = i2;
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_NEXT:
|
|
|
|
mod = 0;
|
|
|
|
anymod = 0;
|
|
|
|
anybut = 0;
|
|
|
|
first = 1;
|
|
|
|
break;
|
|
|
|
case CONFIG_ACTION:
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
aa = ActionCreate(event, anymod, mod, anybut, but, anykey,
|
|
|
|
key, action_tooltipstring);
|
|
|
|
/* the correct place to grab an action key */
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(action_tooltipstring);
|
|
|
|
action_tooltipstring = NULL;
|
2007-07-27 09:59:50 -07:00
|
|
|
key[0] = '\0';
|
2004-12-28 15:46:49 -08:00
|
|
|
if (global)
|
|
|
|
GrabActionKey(aa);
|
|
|
|
ActionclassAddAction(ac, aa);
|
|
|
|
first = 0;
|
|
|
|
}
|
2007-07-27 09:59:50 -07:00
|
|
|
ActionAddTo(aa, p2);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_ACTION_TOOLTIP:
|
2007-07-27 09:59:50 -07:00
|
|
|
action_tooltipstring = Estrdupcat2(action_tooltipstring, "\n", p2);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
case CONFIG_TOOLTIP:
|
2007-07-27 09:59:50 -07:00
|
|
|
aclass_tooltipstring = Estrdupcat2(aclass_tooltipstring, "\n", p2);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
default:
|
2007-07-27 09:59:50 -07:00
|
|
|
ConfigParseError("ActionClass", s);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ac && err)
|
|
|
|
ActionclassDestroy(ac);
|
|
|
|
|
|
|
|
done:
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(aclass_tooltipstring);
|
|
|
|
Efree(action_tooltipstring);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Action *
|
|
|
|
ActionDecode(const char *line)
|
|
|
|
{
|
|
|
|
Action *aa;
|
2005-02-12 11:44:16 -08:00
|
|
|
char ev[16], mod[16], key[128], *s;
|
2004-12-28 15:46:49 -08:00
|
|
|
int len, event, modifiers, button;
|
|
|
|
char anymod, anybut, anykey;
|
|
|
|
|
|
|
|
len = -1;
|
2005-02-12 11:44:16 -08:00
|
|
|
sscanf(line, "%15s %15s %127s %n", ev, mod, key, &len);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (len <= 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
event = -1;
|
|
|
|
if (!strcmp(ev, "KeyDown"))
|
|
|
|
event = EVENT_KEY_DOWN;
|
|
|
|
else if (!strcmp(ev, "MouseDown"))
|
|
|
|
event = EVENT_MOUSE_DOWN;
|
|
|
|
else if (!strcmp(ev, "KeyUp"))
|
|
|
|
event = EVENT_KEY_UP;
|
|
|
|
else if (!strcmp(ev, "MouseUp"))
|
|
|
|
event = EVENT_MOUSE_UP;
|
|
|
|
else if (!strcmp(ev, "MouseDouble"))
|
|
|
|
event = EVENT_DOUBLE_DOWN;
|
|
|
|
else if (!strcmp(ev, "MouseIn"))
|
|
|
|
event = EVENT_MOUSE_ENTER;
|
|
|
|
else if (!strcmp(ev, "MouseOut"))
|
|
|
|
event = EVENT_MOUSE_LEAVE;
|
2005-09-10 14:24:26 -07:00
|
|
|
else if (!strcmp(ev, "FocusIn"))
|
|
|
|
event = EVENT_FOCUS_IN;
|
|
|
|
else if (!strcmp(ev, "FocusOut"))
|
|
|
|
event = EVENT_FOCUS_OUT;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
anymod = anybut = anykey = 0;
|
|
|
|
button = 0;
|
|
|
|
|
|
|
|
modifiers = 0;
|
|
|
|
for (s = mod; *s; s++)
|
|
|
|
{
|
|
|
|
switch (*s)
|
|
|
|
{
|
|
|
|
case '*':
|
|
|
|
anymod = 1;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
modifiers |= ControlMask;
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
modifiers |= ShiftMask;
|
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
modifiers |= Mod1Mask;
|
|
|
|
break;
|
|
|
|
case '1':
|
|
|
|
modifiers |= Mod1Mask;
|
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
modifiers |= Mod2Mask;
|
|
|
|
break;
|
|
|
|
case '3':
|
|
|
|
modifiers |= Mod3Mask;
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
modifiers |= Mod4Mask;
|
|
|
|
break;
|
|
|
|
case '5':
|
|
|
|
modifiers |= Mod5Mask;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case EVENT_MOUSE_DOWN:
|
|
|
|
case EVENT_MOUSE_UP:
|
|
|
|
case EVENT_DOUBLE_DOWN:
|
|
|
|
case EVENT_MOUSE_ENTER:
|
|
|
|
case EVENT_MOUSE_LEAVE:
|
2006-03-11 00:43:15 -08:00
|
|
|
if (key[0] == '*')
|
|
|
|
anybut = 1;
|
|
|
|
else if (isdigit(key[0]))
|
|
|
|
button = atoi(key);
|
|
|
|
if (!anybut && button == 0)
|
|
|
|
return NULL; /* Invalid */
|
2004-12-28 15:46:49 -08:00
|
|
|
key[0] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aa =
|
|
|
|
ActionCreate(event, anymod, modifiers, anybut, button, anykey, key, NULL);
|
|
|
|
ActionAddTo(aa, line + len);
|
|
|
|
|
|
|
|
return aa;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ActionEncode(Action * aa, char *buf, int len)
|
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
const char *event;
|
|
|
|
char *p, mod[32], btn[32];
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
if (!aa || !aa->action)
|
2004-12-28 15:46:49 -08:00
|
|
|
return 0;
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
p = mod;
|
2004-12-28 15:46:49 -08:00
|
|
|
if (aa->anymodifier)
|
|
|
|
*p++ = '*';
|
|
|
|
if (aa->modifiers & ControlMask)
|
|
|
|
*p++ = 'C';
|
|
|
|
if (aa->modifiers & ShiftMask)
|
|
|
|
*p++ = 'S';
|
|
|
|
if (aa->modifiers & Mod1Mask)
|
|
|
|
*p++ = 'A';
|
|
|
|
if (aa->modifiers & Mod2Mask)
|
|
|
|
*p++ = '2';
|
|
|
|
if (aa->modifiers & Mod3Mask)
|
|
|
|
*p++ = '3';
|
|
|
|
if (aa->modifiers & Mod4Mask)
|
|
|
|
*p++ = '4';
|
|
|
|
if (aa->modifiers & Mod5Mask)
|
|
|
|
*p++ = '5';
|
2006-03-30 13:30:50 -08:00
|
|
|
if (p == mod)
|
2004-12-28 15:46:49 -08:00
|
|
|
*p++ = '-';
|
|
|
|
*p++ = '\0';
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
switch (aa->event)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
case EVENT_KEY_DOWN:
|
|
|
|
event = "KeyDown";
|
|
|
|
goto encode_kb;
|
|
|
|
case EVENT_KEY_UP:
|
|
|
|
event = "KeyUp";
|
|
|
|
goto encode_kb;
|
2006-04-09 02:26:15 -07:00
|
|
|
encode_kb:
|
2006-03-30 13:30:50 -08:00
|
|
|
if (!aa->key_str)
|
|
|
|
return 0;
|
|
|
|
len = Esnprintf(buf, len, "%-7s %4s %8s %s\n", event, mod, aa->key_str,
|
|
|
|
(aa->action->params) ? aa->action->params : "");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_MOUSE_DOWN:
|
|
|
|
event = "MouseDown";
|
|
|
|
goto encode_mb;
|
|
|
|
case EVENT_MOUSE_UP:
|
|
|
|
event = "MouseUp";
|
|
|
|
goto encode_mb;
|
|
|
|
case EVENT_DOUBLE_DOWN:
|
|
|
|
event = "MouseDouble";
|
|
|
|
goto encode_mb;
|
|
|
|
case EVENT_MOUSE_ENTER:
|
|
|
|
event = "MouseIn";
|
|
|
|
goto encode_mb;
|
|
|
|
case EVENT_MOUSE_LEAVE:
|
|
|
|
event = "MouseOut";
|
|
|
|
goto encode_mb;
|
|
|
|
encode_mb:
|
|
|
|
if (aa->anybutton)
|
|
|
|
strcpy(btn, "*");
|
|
|
|
else
|
|
|
|
sprintf(btn, "%u", aa->button);
|
|
|
|
len = Esnprintf(buf, len, "%-11s %4s %s %s\n", event, mod, btn,
|
|
|
|
(aa->action->params) ? aa->action->params : "");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_FOCUS_IN:
|
|
|
|
event = "FocusIn";
|
|
|
|
goto encode_fc;
|
|
|
|
case EVENT_FOCUS_OUT:
|
|
|
|
event = "FocusOut";
|
|
|
|
goto encode_fc;
|
|
|
|
encode_fc:
|
|
|
|
break;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
static int
|
|
|
|
AclassEncodeTT(const char *str, char *buf, int len)
|
|
|
|
{
|
|
|
|
char **lst;
|
|
|
|
int i, num, l, nw;
|
|
|
|
|
|
|
|
lst = StrlistFromString(str, '\n', &num);
|
|
|
|
nw = 0;
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
l = Esnprintf(buf, len, "Tooltip %s\n", lst[i]);
|
|
|
|
nw += l;
|
|
|
|
len -= l;
|
|
|
|
buf += l;
|
|
|
|
}
|
|
|
|
StrlistFree(lst, num);
|
|
|
|
return nw;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
AclassConfigLoad2(FILE * fs)
|
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX], *ss;
|
|
|
|
char prm1[128], prm2[128], prm3[128];
|
|
|
|
ActionClass *ac = NULL;
|
|
|
|
Action *aa = NULL;
|
2007-02-25 12:44:22 -08:00
|
|
|
int len, len2;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ss = fgets(s, sizeof(s), fs);
|
|
|
|
if (!ss)
|
|
|
|
break;
|
|
|
|
|
2005-02-06 11:13:34 -08:00
|
|
|
len = strcspn(s, "#\r\n");
|
|
|
|
if (len <= 0)
|
|
|
|
continue;
|
2004-12-28 15:46:49 -08:00
|
|
|
s[len] = '\0';
|
|
|
|
|
|
|
|
prm3[0] = '\0';
|
2007-02-25 12:44:22 -08:00
|
|
|
len2 = 0;
|
|
|
|
len = sscanf(s, "%16s %n%128s %16s", prm1, &len2, prm2, prm3);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (len < 2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strcmp(prm1, "Aclass"))
|
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
if (!strcmp(prm2, "KEYBINDINGS_UNCHANGABLE"))
|
|
|
|
{
|
|
|
|
/* No more "unchangable" keybindings. */
|
|
|
|
ac = ActionclassFindGlobal("KEYBINDINGS");
|
|
|
|
prm2[11] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-14 08:44:39 -08:00
|
|
|
ac = ActionclassFindAny(prm2);
|
2006-03-30 13:30:50 -08:00
|
|
|
if (ac)
|
2008-12-14 08:44:39 -08:00
|
|
|
ActionclassEmpty(ac);
|
2006-03-30 13:30:50 -08:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!ac)
|
2006-03-30 13:30:50 -08:00
|
|
|
ac = ActionclassCreate(prm2, prm3[0] == 'g');
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
aa = NULL;
|
|
|
|
}
|
|
|
|
else if (!strncmp(prm1, "Key", 3) || !strncmp(prm1, "Mouse", 5))
|
|
|
|
{
|
|
|
|
if (!ac)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
aa = ActionDecode(s);
|
|
|
|
if (!aa)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ActionclassAddAction(ac, aa);
|
|
|
|
GrabActionKey(aa);
|
|
|
|
}
|
|
|
|
else if (!strcmp(prm1, "Tooltip"))
|
|
|
|
{
|
2005-01-02 02:05:28 -08:00
|
|
|
/* FIXME - Multiple line strings may break */
|
2004-12-28 15:46:49 -08:00
|
|
|
if (aa)
|
2005-01-02 02:05:28 -08:00
|
|
|
{
|
2005-08-14 14:25:46 -07:00
|
|
|
aa->tooltipstring =
|
2007-02-25 12:44:22 -08:00
|
|
|
Estrdupcat2(aa->tooltipstring, "\n", s + len2);
|
2005-01-02 02:05:28 -08:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
else if (ac)
|
2005-01-02 02:05:28 -08:00
|
|
|
{
|
2005-08-14 14:25:46 -07:00
|
|
|
ac->tooltipstring =
|
2007-02-25 12:44:22 -08:00
|
|
|
Estrdupcat2(ac->tooltipstring, "\n", s + len2);
|
2005-01-02 02:05:28 -08:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-30 13:30:50 -08:00
|
|
|
AclassConfigLoadConfig(const char *name)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
FILE *fs;
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
file = ConfigFileFind(name, NULL, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!file)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fs = fopen(file, "r");
|
|
|
|
Efree(file);
|
|
|
|
if (!fs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
AclassConfigLoad2(fs);
|
|
|
|
|
|
|
|
fclose(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-30 13:30:50 -08:00
|
|
|
AclassConfigWrite(const ActionClass * ac, void (*prf) (const char *fmt, ...))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
Action *aa;
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
if (!ac || ac->num <= 0)
|
|
|
|
return;
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
prf("Aclass %s %s\n", ac->name, (ac->global)? "global" : "normal");
|
|
|
|
if (ac->tooltipstring)
|
|
|
|
{
|
|
|
|
len = AclassEncodeTT(ac->tooltipstring, s, sizeof(s));
|
|
|
|
prf(s);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < ac->num; i++)
|
|
|
|
{
|
|
|
|
aa = ac->list[i];
|
|
|
|
len = ActionEncode(aa, s, sizeof(s));
|
|
|
|
if (len <= 0)
|
|
|
|
continue;
|
2006-03-30 13:30:50 -08:00
|
|
|
prf(s);
|
|
|
|
if (aa->tooltipstring)
|
|
|
|
{
|
|
|
|
len = AclassEncodeTT(aa->tooltipstring, s, sizeof(s));
|
|
|
|
prf(s);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2006-03-30 13:30:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static FILE *_ac_fs = NULL; /* Ugly! Yeah well... */
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ac_prf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
len = vfprintf(_ac_fs, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BindingsSave(void)
|
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX];
|
|
|
|
FILE *fs;
|
|
|
|
|
|
|
|
if (!Mode.keybinds_changed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Etmp(ss);
|
|
|
|
fs = fopen(ss, "w");
|
|
|
|
if (!fs)
|
|
|
|
return;
|
|
|
|
_ac_fs = fs;
|
|
|
|
|
|
|
|
AclassConfigWrite(ActionclassFind("BUTTONBINDINGS"), _ac_prf);
|
|
|
|
AclassConfigWrite(ActionclassFind("DESKBINDINGS"), _ac_prf);
|
|
|
|
AclassConfigWrite(ActionclassFindGlobal("KEYBINDINGS"), _ac_prf);
|
|
|
|
AclassConfigWrite(ActionclassFindGlobal("KEYBINDINGS_UNCHANGABLE"), _ac_prf);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
fclose(fs);
|
2006-03-30 13:30:50 -08:00
|
|
|
_ac_fs = NULL;
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s/bindings.cfg", EDirUser());
|
|
|
|
E_mv(ss, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ActionclassSetTooltipString(ActionClass * ac, const char *tts)
|
|
|
|
{
|
|
|
|
_EFDUP(ac->tooltipstring, tts);
|
|
|
|
}
|
|
|
|
|
2007-07-27 09:59:50 -07:00
|
|
|
ActionClass *
|
|
|
|
ActionclassAlloc(const char *name)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
ActionClass *ac;
|
|
|
|
|
|
|
|
if (!name || !name[0])
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ac = ActionclassFind(name);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (ac)
|
|
|
|
ac->ref_count++;
|
2007-07-27 09:59:50 -07:00
|
|
|
|
|
|
|
return ac;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-27 09:59:50 -07:00
|
|
|
ActionclassFree(ActionClass * ac)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
if (ac)
|
|
|
|
ac->ref_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
ActionclassGetName(ActionClass * ac)
|
|
|
|
{
|
|
|
|
return (ac) ? ac->name : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
ActionclassGetTooltipString(ActionClass * ac)
|
|
|
|
{
|
|
|
|
return (ac) ? ac->tooltipstring : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ActionclassGetActionCount(ActionClass * ac)
|
|
|
|
{
|
|
|
|
return (ac) ? ac->num : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Action *
|
|
|
|
ActionclassGetAction(ActionClass * ac, int ix)
|
|
|
|
{
|
|
|
|
return (ac && ix < ac->num) ? ac->list[ix] : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
ActionGetTooltipString(Action * aa)
|
|
|
|
{
|
|
|
|
return (aa) ? aa->tooltipstring : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ActionGetEvent(Action * aa)
|
|
|
|
{
|
|
|
|
return (aa) ? aa->event : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ActionGetAnybutton(Action * aa)
|
|
|
|
{
|
|
|
|
return (aa) ? aa->anybutton : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ActionGetButton(Action * aa)
|
|
|
|
{
|
|
|
|
return (aa) ? aa->button : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ActionGetModifiers(Action * aa)
|
|
|
|
{
|
|
|
|
return (aa) ? aa->modifiers : 0;
|
|
|
|
}
|
|
|
|
|
2004-12-31 00:49:12 -08:00
|
|
|
static void
|
2004-12-28 15:46:49 -08:00
|
|
|
handleAction(EWin * ewin, ActionType * action)
|
|
|
|
{
|
2009-04-13 08:52:42 -07:00
|
|
|
if (ewin)
|
|
|
|
ewin->state.in_action = 1;
|
2005-06-09 11:28:13 -07:00
|
|
|
EFunc(ewin, action->params);
|
2009-04-13 08:52:42 -07:00
|
|
|
if (ewin)
|
2009-06-07 13:00:53 -07:00
|
|
|
{
|
|
|
|
if (!EwinFindByPtr(ewin))
|
|
|
|
return; /* ewin has been destroyed */
|
|
|
|
ewin->state.in_action = 0;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Did we just hose ourselves? if so, we'd best not stick around here */
|
|
|
|
if (mode_action_destroy)
|
2004-12-31 00:49:12 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* If there is another action in this series, (now that
|
|
|
|
* we're sure we didn't already die) perform it
|
|
|
|
*/
|
2004-12-31 00:49:12 -08:00
|
|
|
if (action->next)
|
|
|
|
handleAction(ewin, action->next);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-06-30 05:37:43 -07:00
|
|
|
ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
KeyCode key;
|
|
|
|
int i, type, button, modifiers, ok, mouse, mask, val = 0;
|
|
|
|
Action *aa;
|
|
|
|
|
2005-07-08 09:48:19 -07:00
|
|
|
if (Mode.action_inhibit || (ewin && ewin->state.inhibit_actions))
|
2005-01-25 13:58:28 -08:00
|
|
|
return 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
key = type = button = modifiers = mouse = 0;
|
|
|
|
|
2007-01-31 17:23:40 -08:00
|
|
|
mask = Mode.masks.mod_key_mask;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
switch (ev->type)
|
|
|
|
{
|
|
|
|
case KeyPress:
|
|
|
|
type = EVENT_KEY_DOWN;
|
|
|
|
key = ev->xkey.keycode;
|
|
|
|
modifiers = ev->xbutton.state & mask;
|
|
|
|
mouse = 0;
|
|
|
|
break;
|
|
|
|
case KeyRelease:
|
|
|
|
type = EVENT_KEY_UP;
|
|
|
|
key = ev->xkey.keycode;
|
|
|
|
modifiers = ev->xbutton.state & mask;
|
|
|
|
mouse = 0;
|
|
|
|
break;
|
|
|
|
case ButtonPress:
|
2005-12-23 16:39:29 -08:00
|
|
|
if (Mode.events.double_click)
|
2004-12-28 15:46:49 -08:00
|
|
|
type = EVENT_DOUBLE_DOWN;
|
|
|
|
else
|
|
|
|
type = EVENT_MOUSE_DOWN;
|
|
|
|
button = ev->xbutton.button;
|
|
|
|
modifiers = ev->xbutton.state & mask;
|
|
|
|
mouse = 1;
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
type = EVENT_MOUSE_UP;
|
|
|
|
button = ev->xbutton.button;
|
|
|
|
modifiers = ev->xbutton.state & mask;
|
|
|
|
mouse = 1;
|
|
|
|
break;
|
|
|
|
case EnterNotify:
|
|
|
|
type = EVENT_MOUSE_ENTER;
|
|
|
|
button = -1;
|
|
|
|
modifiers = ev->xcrossing.state & mask;
|
|
|
|
mouse = 1;
|
|
|
|
break;
|
|
|
|
case LeaveNotify:
|
|
|
|
/* If frame window, quit if pointer is still inside */
|
2006-04-18 09:26:51 -07:00
|
|
|
if (ewin && ev->xcrossing.window == EoGetXwin(ewin) &&
|
2004-12-28 15:46:49 -08:00
|
|
|
(ev->xcrossing.x >= 0 && ev->xcrossing.x < EoGetW(ewin) &&
|
|
|
|
ev->xcrossing.y >= 0 && ev->xcrossing.y < EoGetH(ewin)))
|
2005-01-25 13:58:28 -08:00
|
|
|
return 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
type = EVENT_MOUSE_LEAVE;
|
|
|
|
button = -1;
|
|
|
|
modifiers = ev->xcrossing.state & mask;
|
|
|
|
mouse = 1;
|
|
|
|
break;
|
2005-08-10 12:33:33 -07:00
|
|
|
case FocusIn:
|
|
|
|
type = EVENT_FOCUS_IN;
|
|
|
|
button = -1;
|
|
|
|
mouse = 1;
|
|
|
|
break;
|
|
|
|
case FocusOut:
|
|
|
|
type = EVENT_FOCUS_OUT;
|
|
|
|
button = -1;
|
|
|
|
mouse = 1;
|
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mode_action_destroy = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ac->num; i++)
|
|
|
|
{
|
|
|
|
if (!mode_action_destroy)
|
|
|
|
{
|
|
|
|
aa = ac->list[i];
|
|
|
|
ok = 0;
|
|
|
|
if ((aa->event == type) && (aa->action))
|
|
|
|
{
|
|
|
|
if (mouse)
|
|
|
|
{
|
|
|
|
if (button < 0)
|
|
|
|
{
|
|
|
|
if (aa->anymodifier)
|
|
|
|
ok = 1;
|
|
|
|
else if (aa->modifiers == modifiers)
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (aa->anymodifier)
|
|
|
|
{
|
|
|
|
if (aa->anybutton)
|
|
|
|
ok = 1;
|
|
|
|
else if (aa->button == button)
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
else if (aa->modifiers == modifiers)
|
|
|
|
{
|
|
|
|
if (aa->anybutton)
|
|
|
|
ok = 1;
|
|
|
|
else if (aa->button == button)
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (aa->anymodifier)
|
|
|
|
{
|
|
|
|
if (aa->anykey)
|
|
|
|
ok = 1;
|
|
|
|
else if (aa->key == key)
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
else if (aa->modifiers == modifiers)
|
|
|
|
{
|
|
|
|
if (aa->anykey)
|
|
|
|
ok = 1;
|
|
|
|
else if (aa->key == key)
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
handleAction(ewin, aa->action);
|
|
|
|
val = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mode_action_destroy)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mode_action_destroy = 0;
|
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return val;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-06-30 05:37:43 -07:00
|
|
|
int
|
2005-09-10 14:24:26 -07:00
|
|
|
ActionclassesGlobalEvent(XEvent * ev)
|
2005-06-30 05:37:43 -07:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
ActionClass *ac;
|
|
|
|
int match;
|
2005-06-30 05:37:43 -07:00
|
|
|
|
|
|
|
match = 0;
|
2006-03-30 13:30:50 -08:00
|
|
|
ECORE_LIST_FOR_EACH(aclass_list_global, ac)
|
2006-02-18 00:30:09 -08:00
|
|
|
match |= ActionclassEvent(ac, ev, GetFocusEwin());
|
2005-06-30 05:37:43 -07:00
|
|
|
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
2009-03-22 05:40:23 -07:00
|
|
|
static Timer *ac_reload_timer = NULL;
|
|
|
|
|
2008-12-30 08:19:33 -08:00
|
|
|
static int
|
|
|
|
_ac_reload(void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
AclassConfigLoadConfig("bindings.cfg");
|
2009-03-22 05:40:23 -07:00
|
|
|
ac_reload_timer = NULL;
|
2008-12-30 08:19:33 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ActionclassesReload(void)
|
|
|
|
{
|
|
|
|
TIMER_DEL(ac_reload_timer);
|
|
|
|
TIMER_ADD(ac_reload_timer, 0.2, _ac_reload, NULL);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* Actions module
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
AclassSighan(int sig, void *prm __UNUSED__)
|
|
|
|
{
|
|
|
|
switch (sig)
|
|
|
|
{
|
|
|
|
case ESIGNAL_INIT:
|
2006-03-30 13:30:50 -08:00
|
|
|
AclassConfigLoadConfig("bindings.cfg");
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
AclassIpc(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
char cmd[128], prm[4096];
|
2006-03-30 13:30:50 -08:00
|
|
|
int len;
|
2006-02-18 00:30:09 -08:00
|
|
|
ActionClass *ac;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
cmd[0] = prm[0] = '\0';
|
|
|
|
p = params;
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
len = 0;
|
|
|
|
sscanf(p, "%100s %4000s %n", cmd, prm, &len);
|
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
if (!p || cmd[0] == '\0' || cmd[0] == '?')
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
}
|
2005-02-17 13:35:06 -08:00
|
|
|
else if (!strncmp(cmd, "kb", 2))
|
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
AclassConfigWrite(ActionclassFindGlobal("KEYBINDINGS"), IpcPrintf);
|
2005-02-17 13:35:06 -08:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
else if (!strncmp(cmd, "list", 2))
|
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
if (prm[0] == '\0')
|
|
|
|
{
|
|
|
|
IpcPrintf("Normal:\n");
|
|
|
|
ECORE_LIST_FOR_EACH(aclass_list, ac) IpcPrintf("%s\n", ac->name);
|
|
|
|
IpcPrintf("Global:\n");
|
|
|
|
ECORE_LIST_FOR_EACH(aclass_list_global, ac) IpcPrintf("%s\n",
|
|
|
|
ac->name);
|
|
|
|
}
|
|
|
|
else if (!strcmp(prm, "all"))
|
|
|
|
{
|
|
|
|
ECORE_LIST_FOR_EACH(aclass_list, ac)
|
|
|
|
{
|
|
|
|
IpcPrintf("\n");
|
|
|
|
AclassConfigWrite(ac, IpcPrintf);
|
|
|
|
}
|
|
|
|
ECORE_LIST_FOR_EACH(aclass_list_global, ac)
|
|
|
|
{
|
|
|
|
IpcPrintf("\n");
|
|
|
|
AclassConfigWrite(ac, IpcPrintf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AclassConfigWrite(ActionclassFindAny(prm), IpcPrintf);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2006-03-30 13:30:50 -08:00
|
|
|
else if (!strcmp(cmd, "load"))
|
2005-02-06 00:18:50 -08:00
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
if (*prm == '\0')
|
|
|
|
AclassConfigLoadConfig("bindings.cfg");
|
|
|
|
else
|
|
|
|
AclassConfigLoadConfig(prm);
|
2005-02-06 00:18:50 -08:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
/* Should only be used via e16keyedit */
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
IPC_KeybindingsGet(const char *params __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
ActionClass *ac;
|
|
|
|
Action *aa;
|
|
|
|
int i, mod;
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
ac = ActionclassFindGlobal("KEYBINDINGS");
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!ac)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < ac->num; i++)
|
|
|
|
{
|
|
|
|
aa = ac->list[i];
|
|
|
|
if ((aa) && (aa->action) && (aa->event == EVENT_KEY_DOWN))
|
|
|
|
{
|
2008-03-30 05:13:16 -07:00
|
|
|
const char *key;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
key = EKeycodeToString(aa->key, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!key)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mod = 0;
|
|
|
|
if (aa->modifiers == (ControlMask))
|
|
|
|
mod = 1;
|
|
|
|
else if (aa->modifiers == (Mod1Mask))
|
|
|
|
mod = 2;
|
|
|
|
else if (aa->modifiers == (ShiftMask))
|
|
|
|
mod = 3;
|
|
|
|
else if (aa->modifiers == (ControlMask | Mod1Mask))
|
|
|
|
mod = 4;
|
|
|
|
else if (aa->modifiers == (ShiftMask | ControlMask))
|
|
|
|
mod = 5;
|
|
|
|
else if (aa->modifiers == (ShiftMask | Mod1Mask))
|
|
|
|
mod = 6;
|
|
|
|
else if (aa->modifiers == (ShiftMask | ControlMask | Mod1Mask))
|
|
|
|
mod = 7;
|
|
|
|
else if (aa->modifiers == (Mod2Mask))
|
|
|
|
mod = 8;
|
|
|
|
else if (aa->modifiers == (Mod3Mask))
|
|
|
|
mod = 9;
|
|
|
|
else if (aa->modifiers == (Mod4Mask))
|
|
|
|
mod = 10;
|
|
|
|
else if (aa->modifiers == (Mod5Mask))
|
|
|
|
mod = 11;
|
|
|
|
else if (aa->modifiers == (Mod2Mask | ShiftMask))
|
|
|
|
mod = 12;
|
|
|
|
else if (aa->modifiers == (Mod2Mask | ControlMask))
|
|
|
|
mod = 13;
|
|
|
|
else if (aa->modifiers == (Mod2Mask | Mod1Mask))
|
|
|
|
mod = 14;
|
|
|
|
else if (aa->modifiers == (Mod4Mask | ShiftMask))
|
|
|
|
mod = 15;
|
|
|
|
else if (aa->modifiers == (Mod4Mask | ControlMask))
|
|
|
|
mod = 16;
|
|
|
|
else if (aa->modifiers == (Mod4Mask | ControlMask | ShiftMask))
|
|
|
|
mod = 17;
|
|
|
|
else if (aa->modifiers == (Mod5Mask | ShiftMask))
|
|
|
|
mod = 18;
|
|
|
|
else if (aa->modifiers == (Mod5Mask | ControlMask))
|
|
|
|
mod = 19;
|
|
|
|
else if (aa->modifiers == (Mod5Mask | ControlMask | ShiftMask))
|
|
|
|
mod = 20;
|
|
|
|
|
|
|
|
if (aa->action->params)
|
|
|
|
IpcPrintf("%s %i %i %s\n", key, mod, 0, aa->action->params);
|
|
|
|
else
|
|
|
|
IpcPrintf("%s %i %i\n", key, mod, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
/* Should only be used via e16keyedit */
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
IPC_KeybindingsSet(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
ActionClass *ac;
|
|
|
|
Action *aa;
|
|
|
|
int i, l;
|
|
|
|
char buf[FILEPATH_LEN_MAX];
|
|
|
|
const char *sp, *ss;
|
|
|
|
|
2007-02-25 12:44:22 -08:00
|
|
|
ss = params;
|
|
|
|
if (!ss || !ss[0])
|
|
|
|
return;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Mode.keybinds_changed = 1;
|
|
|
|
|
2008-12-14 08:44:39 -08:00
|
|
|
ac = ActionclassFindGlobal("KEYBINDINGS");
|
2004-12-28 15:46:49 -08:00
|
|
|
if (ac)
|
2008-12-14 08:44:39 -08:00
|
|
|
ActionclassEmpty(ac);
|
|
|
|
else
|
|
|
|
ac = ActionclassCreate("KEYBINDINGS", 1);
|
2007-02-25 12:44:22 -08:00
|
|
|
if (!ac)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
l = strlen(ss);
|
|
|
|
while (i < l)
|
|
|
|
{
|
|
|
|
char key[256];
|
|
|
|
int mod = 0;
|
|
|
|
int act_id = 0;
|
2007-02-25 12:44:22 -08:00
|
|
|
int j = 0, len;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* put line in buf */
|
|
|
|
sp = &(ss[i]);
|
|
|
|
while ((sp[j]) && (sp[j] != '\n'))
|
|
|
|
{
|
|
|
|
buf[j] = sp[j];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
buf[j] = 0;
|
|
|
|
if (sp[j] == '\n')
|
|
|
|
j++;
|
|
|
|
i += j;
|
|
|
|
|
|
|
|
/* parse the line */
|
2007-02-25 12:44:22 -08:00
|
|
|
len = 0;
|
|
|
|
sscanf(buf, "%250s %i %i %n", key, &mod, &act_id, &len);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (mod == 0)
|
|
|
|
mod = 0;
|
|
|
|
else if (mod == 1)
|
|
|
|
mod = ControlMask;
|
|
|
|
else if (mod == 2)
|
|
|
|
mod = Mod1Mask;
|
|
|
|
else if (mod == 3)
|
|
|
|
mod = ShiftMask;
|
|
|
|
else if (mod == 4)
|
|
|
|
mod = ControlMask | Mod1Mask;
|
|
|
|
else if (mod == 5)
|
|
|
|
mod = ShiftMask | ControlMask;
|
|
|
|
else if (mod == 6)
|
|
|
|
mod = ShiftMask | Mod1Mask;
|
|
|
|
else if (mod == 7)
|
|
|
|
mod = ShiftMask | ControlMask | Mod1Mask;
|
|
|
|
else if (mod == 8)
|
|
|
|
mod = Mod2Mask;
|
|
|
|
else if (mod == 9)
|
|
|
|
mod = Mod3Mask;
|
|
|
|
else if (mod == 10)
|
|
|
|
mod = Mod4Mask;
|
|
|
|
else if (mod == 11)
|
|
|
|
mod = Mod5Mask;
|
|
|
|
else if (mod == 12)
|
|
|
|
mod = Mod2Mask | ShiftMask;
|
|
|
|
else if (mod == 13)
|
|
|
|
mod = Mod2Mask | ControlMask;
|
|
|
|
else if (mod == 14)
|
|
|
|
mod = Mod2Mask | Mod1Mask;
|
|
|
|
else if (mod == 15)
|
|
|
|
mod = Mod4Mask | ShiftMask;
|
|
|
|
else if (mod == 16)
|
|
|
|
mod = Mod4Mask | ControlMask;
|
|
|
|
else if (mod == 17)
|
|
|
|
mod = Mod4Mask | ControlMask | ShiftMask;
|
|
|
|
else if (mod == 18)
|
|
|
|
mod = Mod5Mask | ShiftMask;
|
|
|
|
else if (mod == 19)
|
|
|
|
mod = Mod5Mask | ControlMask;
|
|
|
|
else if (mod == 20)
|
|
|
|
mod = Mod5Mask | ControlMask | ShiftMask;
|
|
|
|
|
|
|
|
aa = ActionCreate(4, 0, mod, 0, 0, 0, key, NULL);
|
|
|
|
ActionclassAddAction(ac, aa);
|
2007-02-25 12:44:22 -08:00
|
|
|
ActionAddTo(aa, buf + len);
|
2004-12-28 15:46:49 -08:00
|
|
|
GrabActionKey(aa);
|
|
|
|
}
|
|
|
|
|
2006-03-30 13:30:50 -08:00
|
|
|
BindingsSave();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static const IpcItem AclassIpcArray[] = {
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
AclassIpc,
|
|
|
|
"aclass", "ac",
|
|
|
|
"Action class functions",
|
2005-02-17 13:35:06 -08:00
|
|
|
" aclass kb List key bindings\n"
|
2006-03-30 13:30:50 -08:00
|
|
|
" aclass list [name/all] List action class[es]\n"
|
|
|
|
" aclass load [name] Reload action classes (default is bindings.cfg)\n"}
|
2004-12-28 15:46:49 -08:00
|
|
|
,
|
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
IPC_KeybindingsGet, "get_keybindings", NULL,
|
|
|
|
"List keybindings (deprecated)", NULL}
|
2004-12-28 15:46:49 -08:00
|
|
|
,
|
|
|
|
{
|
2006-03-30 13:30:50 -08:00
|
|
|
IPC_KeybindingsSet, "set_keybindings", NULL, "Set keybindings (deprecated)",
|
|
|
|
NULL}
|
2004-12-28 15:46:49 -08:00
|
|
|
,
|
|
|
|
};
|
|
|
|
#define N_IPC_FUNCS (sizeof(AclassIpcArray)/sizeof(IpcItem))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Module descriptor
|
|
|
|
*/
|
2007-01-16 17:10:44 -08:00
|
|
|
extern const EModule ModAclass;
|
2006-04-21 15:52:59 -07:00
|
|
|
const EModule ModAclass = {
|
2004-12-28 15:46:49 -08:00
|
|
|
"aclass", "ac",
|
|
|
|
AclassSighan,
|
2008-12-14 08:44:39 -08:00
|
|
|
{N_IPC_FUNCS, AclassIpcArray},
|
2004-12-28 15:46:49 -08:00
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2008-11-27 12:15:23 -08:00
|
|
|
GrabButtonGrabs(Win win)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
ActionClass *ac;
|
|
|
|
int j;
|
|
|
|
Action *aa;
|
|
|
|
unsigned int mod, button, mask;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
ac = ActionclassFind("BUTTONBINDINGS");
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!ac)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ac->ref_count++;
|
|
|
|
for (j = 0; j < ac->num; j++)
|
|
|
|
{
|
|
|
|
aa = ac->list[j];
|
2008-12-14 08:44:39 -08:00
|
|
|
if ((!aa) || ((aa->event != EVENT_MOUSE_DOWN) &&
|
|
|
|
(aa->event != EVENT_MOUSE_UP)))
|
2004-12-28 15:46:49 -08:00
|
|
|
continue;
|
|
|
|
|
2007-01-31 17:23:40 -08:00
|
|
|
mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
|
|
|
|
button = (aa->anybutton) ? AnyButton : aa->button;
|
2004-12-28 15:46:49 -08:00
|
|
|
mask = ButtonPressMask | ButtonReleaseMask;
|
|
|
|
|
2008-11-27 12:15:23 -08:00
|
|
|
GrabButtonSet(button, mod, win, mask, ECSR_PGRAB, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-11-27 12:15:23 -08:00
|
|
|
UnGrabButtonGrabs(Win win)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
ActionClass *ac;
|
|
|
|
int j;
|
|
|
|
Action *aa;
|
|
|
|
unsigned int mod, button;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
ac = ActionclassFind("BUTTONBINDINGS");
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!ac)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ac->ref_count--;
|
|
|
|
for (j = 0; j < ac->num; j++)
|
|
|
|
{
|
|
|
|
aa = ac->list[j];
|
|
|
|
if ((!aa) || ((aa->event != EVENT_MOUSE_DOWN)
|
|
|
|
&& (aa->event != EVENT_MOUSE_UP)))
|
|
|
|
continue;
|
|
|
|
|
2007-01-31 17:23:40 -08:00
|
|
|
mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
|
|
|
|
button = (aa->anybutton) ? AnyButton : aa->button;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-11-27 12:15:23 -08:00
|
|
|
GrabButtonRelease(button, mod, win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GrabActionKey(Action * aa)
|
|
|
|
{
|
|
|
|
int mod;
|
|
|
|
|
|
|
|
if (!aa->key)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-01-31 17:23:40 -08:00
|
|
|
mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-24 04:12:40 -07:00
|
|
|
GrabKeySet(aa->key, mod, VROOT);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
UnGrabActionKey(Action * aa)
|
|
|
|
{
|
|
|
|
int mod;
|
|
|
|
|
|
|
|
if (!aa->key)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-01-31 17:23:40 -08:00
|
|
|
mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-24 04:12:40 -07:00
|
|
|
GrabKeyRelease(aa->key, mod, VROOT);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|