Allow applications to examine the symbol associated with a key stroke.

IMHO this makes more sense if you want things to work on different -
keyboard layouts. Try generating a e->key "=" on a Japanese keyboard.
The old code also works, so it shoulnd't break anything.


SVN revision: 6879
This commit is contained in:
Horms 2003-04-26 04:22:37 +00:00
parent ee6ab155c5
commit 9fd93e9a6f
3 changed files with 23 additions and 5 deletions

View File

@ -221,6 +221,7 @@ extern "C"
Window win, root;
Ecore_Event_Key_Modifiers mods;
char *key;
char *symbol;
char *compose;
Time time;
} Ecore_Event_Key_Down;
@ -230,6 +231,7 @@ extern "C"
Window win, root;
Ecore_Event_Key_Modifiers mods;
char *key;
char *symbol;
char *compose;
Time time;
} Ecore_Event_Key_Up;
@ -710,6 +712,7 @@ extern "C"
KeySym ecore_key_get_keysym_from_keycode(KeyCode keycode);
char *ecore_key_get_string_from_keycode(KeyCode keycode);
char *ecore_key_get_string_from_keysym(KeySym keysym);
void ecore_key_grab(char *key, Ecore_Event_Key_Modifiers mods,
int anymod, int sync);
void ecore_key_ungrab(char *key,

View File

@ -200,6 +200,7 @@ ecore_event_key_down_free(void *event)
e = (Ecore_Event_Key_Down *) event;
IF_FREE(e->key);
IF_FREE(e->symbol);
IF_FREE(e->compose);
FREE(e);
}
@ -211,6 +212,7 @@ ecore_event_key_up_free(void *event)
e = (Ecore_Event_Key_Up *) event;
IF_FREE(e->key);
IF_FREE(e->symbol);
IF_FREE(e->compose);
FREE(e);
}
@ -304,11 +306,12 @@ ecore_event_x_handle_keypress(XEvent * xevent)
val = XLookupString((XKeyEvent *) xevent, buf, sizeof(buf), &sym, &stat);
if (val > 0)
{
buf[val] = 0;
e->compose = strdup(buf);
buf[val] = 0;
e->compose = strdup(buf);
}
else
e->compose = NULL;
e->symbol = ecore_key_get_string_from_keysym(sym);
}
ecore_add_event(ECORE_EVENT_KEY_DOWN, e, ecore_event_key_down_free);
}
@ -342,11 +345,12 @@ ecore_event_x_handle_keyrelease(XEvent * xevent)
val = XLookupString((XKeyEvent *) xevent, buf, sizeof(buf), &sym, &stat);
if (val > 0)
{
buf[val] = 0;
e->compose = strdup(buf);
buf[val] = 0;
e->compose = strdup(buf);
}
else
e->compose = NULL;
e->symbol = ecore_key_get_string_from_keysym(sym);
}
ecore_add_event(ECORE_EVENT_KEY_UP, e, ecore_event_key_up_free);
}

View File

@ -951,13 +951,24 @@ ecore_key_get_string_from_keycode(KeyCode keycode)
{
char *str;
if (!disp) return strdup("");
if (!disp) return strdup("");
str = XKeysymToString(ecore_key_get_keysym_from_keycode(keycode));
if (!str)
return strdup("");
return strdup(str);
}
char *
ecore_key_get_string_from_keysym(KeySym keysym)
{
char *str;
if(keysym == NoSymbol) return strdup("");
str = XKeysymToString(keysym);
if(!str) str="(no name)";
return strdup(str);
}
void
ecore_event_allow(int mode, Time t)
{