Cosmetics (key->keycode).

This commit is contained in:
Kim Woelders 2014-04-23 06:31:51 +02:00
parent d1f00956aa
commit 9d9fa0edf5
5 changed files with 39 additions and 39 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2013 Kim Woelders * Copyright (C) 2004-2014 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -45,7 +45,7 @@ struct _action {
char anybutton; char anybutton;
int button; int button;
char anykey; char anykey;
KeyCode key; KeyCode keycode;
char *key_str; char *key_str;
char *tooltipstring; char *tooltipstring;
ActionType *action; ActionType *action;
@ -104,10 +104,10 @@ ActionCreate(char event, char anymod, int mod, int anybut, int but,
aa->button = but; aa->button = but;
aa->anykey = anykey; aa->anykey = anykey;
if (!key || !key[0] || (event != EVENT_KEY_DOWN && event != EVENT_KEY_UP)) if (!key || !key[0] || (event != EVENT_KEY_DOWN && event != EVENT_KEY_UP))
aa->key = 0; aa->keycode = 0;
else else
aa->key = EKeynameToKeycode(key); aa->keycode = EKeynameToKeycode(key);
aa->key_str = (aa->key) ? Estrdup(key) : NULL; aa->key_str = (aa->keycode) ? Estrdup(key) : NULL;
aa->tooltipstring = aa->tooltipstring =
(tooltipstring) ? Estrdup((tooltipstring[0]) ? tooltipstring : "?!?") : (tooltipstring) ? Estrdup((tooltipstring[0]) ? tooltipstring : "?!?") :
NULL; NULL;
@ -989,14 +989,14 @@ handleAction(EWin * ewin, ActionType * action)
int int
ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin) ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin)
{ {
KeyCode key; KeyCode keycode;
int i, type, button, modifiers, ok, mouse, mask, val = 0; int i, type, button, modifiers, ok, mouse, mask, val = 0;
Action *aa; Action *aa;
if (ewin && ewin->state.inhibit_actions) if (ewin && ewin->state.inhibit_actions)
return 0; return 0;
key = type = button = modifiers = mouse = 0; keycode = type = button = modifiers = mouse = 0;
mask = Mode.masks.mod_key_mask; mask = Mode.masks.mod_key_mask;
@ -1004,13 +1004,13 @@ ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin)
{ {
case KeyPress: case KeyPress:
type = EVENT_KEY_DOWN; type = EVENT_KEY_DOWN;
key = ev->xkey.keycode; keycode = ev->xkey.keycode;
modifiers = ev->xbutton.state & mask; modifiers = ev->xbutton.state & mask;
mouse = 0; mouse = 0;
break; break;
case KeyRelease: case KeyRelease:
type = EVENT_KEY_UP; type = EVENT_KEY_UP;
key = ev->xkey.keycode; keycode = ev->xkey.keycode;
modifiers = ev->xbutton.state & mask; modifiers = ev->xbutton.state & mask;
mouse = 0; mouse = 0;
break; break;
@ -1103,14 +1103,14 @@ ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin)
{ {
if (aa->anykey) if (aa->anykey)
ok = 1; ok = 1;
else if (aa->key == key) else if (aa->keycode == keycode)
ok = 1; ok = 1;
} }
else if (aa->modifiers == modifiers) else if (aa->modifiers == modifiers)
{ {
if (aa->anykey) if (aa->anykey)
ok = 1; ok = 1;
else if (aa->key == key) else if (aa->keycode == keycode)
ok = 1; ok = 1;
} }
} }
@ -1324,12 +1324,12 @@ GrabActionKey(Action * aa)
{ {
int mod; int mod;
if (!aa || !aa->key) if (!aa || !aa->keycode)
return; return;
mod = (aa->anymodifier) ? AnyModifier : aa->modifiers; mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
GrabKeySet(aa->key, mod, VROOT); GrabKeySet(aa->keycode, mod, VROOT);
} }
static void static void
@ -1337,10 +1337,10 @@ UnGrabActionKey(Action * aa)
{ {
int mod; int mod;
if (!aa->key) if (!aa->keycode)
return; return;
mod = (aa->anymodifier) ? AnyModifier : aa->modifiers; mod = (aa->anymodifier) ? AnyModifier : aa->modifiers;
GrabKeyRelease(aa->key, mod, VROOT); GrabKeyRelease(aa->keycode, mod, VROOT);
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2013 Kim Woelders * Copyright (C) 2004-2014 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -181,7 +181,7 @@ ShowAlert(const char *title,
Colormap cmap; Colormap cmap;
int cnum, fh, x, y, ww, hh, bw, bh; int cnum, fh, x, y, ww, hh, bw, bh;
char *str1, *str2, *str3, *p; char *str1, *str2, *str3, *p;
KeyCode key; KeyCode keycode;
int button; int button;
char **missing_charset_list_return, *def_string_return; char **missing_charset_list_return, *def_string_return;
int missing_charset_count_return; int missing_charset_count_return;
@ -386,8 +386,8 @@ ShowAlert(const char *title,
switch (ev.type) switch (ev.type)
{ {
case KeyPress: case KeyPress:
key = XKeysymToKeycode(dd, XK_F1); keycode = XKeysymToKeycode(dd, XK_F1);
if (key == ev.xkey.keycode) if (keycode == ev.xkey.keycode)
{ {
DRAW_BOX_IN(dd, gc, b1, 0, 0, bw, bh); DRAW_BOX_IN(dd, gc, b1, 0, 0, bw, bh);
XSync(dd, False); XSync(dd, False);
@ -396,8 +396,8 @@ ShowAlert(const char *title,
button = 1; button = 1;
goto do_sync; goto do_sync;
} }
key = XKeysymToKeycode(dd, XK_F2); keycode = XKeysymToKeycode(dd, XK_F2);
if (key == ev.xkey.keycode) if (keycode == ev.xkey.keycode)
{ {
DRAW_BOX_IN(dd, gc, b2, 0, 0, bw, bh); DRAW_BOX_IN(dd, gc, b2, 0, 0, bw, bh);
XSync(dd, False); XSync(dd, False);
@ -406,8 +406,8 @@ ShowAlert(const char *title,
button = 2; button = 2;
goto do_sync; goto do_sync;
} }
key = XKeysymToKeycode(dd, XK_F3); keycode = XKeysymToKeycode(dd, XK_F3);
if (key == ev.xkey.keycode) if (keycode == ev.xkey.keycode)
{ {
DRAW_BOX_IN(dd, gc, b3, 0, 0, bw, bh); DRAW_BOX_IN(dd, gc, b3, 0, 0, bw, bh);
XSync(dd, False); XSync(dd, False);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2013 Kim Woelders * Copyright (C) 2004-2014 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -144,7 +144,7 @@ struct _ditem {
}; };
typedef struct { typedef struct {
KeyCode key; KeyCode keycode;
DialogCallbackFunc *func; DialogCallbackFunc *func;
int val; int val;
void *data; void *data;
@ -208,7 +208,7 @@ DialogBindKey(Dialog * d, const char *key, DialogCallbackFunc * func, int val,
d->keybindings[d->num_bindings - 1].val = val; d->keybindings[d->num_bindings - 1].val = val;
d->keybindings[d->num_bindings - 1].func = func; d->keybindings[d->num_bindings - 1].func = func;
d->keybindings[d->num_bindings - 1].data = data; d->keybindings[d->num_bindings - 1].data = data;
d->keybindings[d->num_bindings - 1].key = EKeynameToKeycode(key); d->keybindings[d->num_bindings - 1].keycode = EKeynameToKeycode(key);
} }
void void
@ -1865,7 +1865,7 @@ DialogEventKeyPress(Dialog * d, XEvent * ev)
for (i = 0; i < d->num_bindings; i++) for (i = 0; i < d->num_bindings; i++)
{ {
if (ev->xkey.keycode != d->keybindings[i].key) if (ev->xkey.keycode != d->keybindings[i].keycode)
continue; continue;
d->keybindings[i].func(d, d->keybindings[i].val, d->keybindings[i].func(d, d->keybindings[i].val,
d->keybindings[i].data); d->keybindings[i].data);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2013 Kim Woelders * Copyright (C) 2004-2014 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -251,7 +251,7 @@ GrabButtonRelease(unsigned int button, unsigned int modifiers, Win win)
} }
void void
GrabKeySet(unsigned int key, unsigned int modifiers, Win win) GrabKeySet(unsigned int keycode, unsigned int modifiers, Win win)
{ {
Bool owner_events = False; Bool owner_events = False;
int pointer_mode = GrabModeAsync; int pointer_mode = GrabModeAsync;
@ -284,14 +284,14 @@ GrabKeySet(unsigned int key, unsigned int modifiers, Win win)
num_modifiers++; num_modifiers++;
} }
} }
XIGrabKeycode(disp, DEV_KBD, key, WinGetXwin(win), XIGrabKeycode(disp, DEV_KBD, keycode, WinGetXwin(win),
keyboard_mode, pointer_mode, owner_events, keyboard_mode, pointer_mode, owner_events,
&em.em, num_modifiers, modifiers_inouts); &em.em, num_modifiers, modifiers_inouts);
#else #else
if (modifiers == AnyModifier) if (modifiers == AnyModifier)
{ {
XGrabKey(disp, key, modifiers, WinGetXwin(win), owner_events, XGrabKey(disp, keycode, modifiers, WinGetXwin(win), owner_events,
pointer_mode, keyboard_mode); pointer_mode, keyboard_mode);
return; return;
} }
@ -300,14 +300,14 @@ GrabKeySet(unsigned int key, unsigned int modifiers, Win win)
{ {
if (i && !Mode.masks.mod_combos[i]) if (i && !Mode.masks.mod_combos[i])
continue; continue;
XGrabKey(disp, key, modifiers | Mode.masks.mod_combos[i], XGrabKey(disp, keycode, modifiers | Mode.masks.mod_combos[i],
WinGetXwin(win), owner_events, pointer_mode, keyboard_mode); WinGetXwin(win), owner_events, pointer_mode, keyboard_mode);
} }
#endif #endif
} }
void void
GrabKeyRelease(unsigned int key, unsigned int modifiers, Win win) GrabKeyRelease(unsigned int keycode, unsigned int modifiers, Win win)
{ {
int i; int i;
@ -334,13 +334,13 @@ GrabKeyRelease(unsigned int key, unsigned int modifiers, Win win)
num_modifiers++; num_modifiers++;
} }
} }
XIUngrabKeycode(disp, DEV_KBD, key, WinGetXwin(win), XIUngrabKeycode(disp, DEV_KBD, keycode, WinGetXwin(win),
num_modifiers, modifiers_inouts); num_modifiers, modifiers_inouts);
#else #else
if (modifiers == AnyModifier) if (modifiers == AnyModifier)
{ {
XUngrabKey(disp, key, modifiers, WinGetXwin(win)); XUngrabKey(disp, keycode, modifiers, WinGetXwin(win));
return; return;
} }
@ -348,7 +348,7 @@ GrabKeyRelease(unsigned int key, unsigned int modifiers, Win win)
{ {
if (i && !Mode.masks.mod_combos[i]) if (i && !Mode.masks.mod_combos[i])
continue; continue;
XUngrabKey(disp, key, modifiers | Mode.masks.mod_combos[i], XUngrabKey(disp, keycode, modifiers | Mode.masks.mod_combos[i],
WinGetXwin(win)); WinGetXwin(win));
} }
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2006-2012 Kim Woelders * Copyright (C) 2006-2014 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -37,9 +37,9 @@ void GrabButtonSet(unsigned int button, unsigned int modifiers,
unsigned int csr, int confine); unsigned int csr, int confine);
void GrabButtonRelease(unsigned int button, void GrabButtonRelease(unsigned int button,
unsigned int modifiers, Win win); unsigned int modifiers, Win win);
void GrabKeySet(unsigned int key, unsigned int modifiers, void GrabKeySet(unsigned int keycode, unsigned int modifiers,
Win win); Win win);
void GrabKeyRelease(unsigned int key, unsigned int modifiers, void GrabKeyRelease(unsigned int keycode, unsigned int modifiers,
Win win); Win win);
#endif /* _GRABS_H_ */ #endif /* _GRABS_H_ */