diff options
| author | Dana Jansens <danakj@orodu.net> | 2010-02-11 15:05:16 -0500 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2010-02-11 15:07:08 -0500 |
| commit | 096dad0c6c027100494ede811b33cb8558d32e25 (patch) | |
| tree | 0e7799172d90d81a03632b186bf80cbeb26496e6 /obt | |
| parent | 6c760c5a63a2e49bc2a5a4f39f8b4b9ed285bd7e (diff) | |
make control keys work in menus/dialogs/etc with the new obt code, using XLookup stuff
Diffstat (limited to 'obt')
| -rw-r--r-- | obt/keyboard.c | 28 | ||||
| -rw-r--r-- | obt/keyboard.h | 7 |
2 files changed, 28 insertions, 7 deletions
diff --git a/obt/keyboard.c b/obt/keyboard.c index 82161e59..5e218429 100644 --- a/obt/keyboard.c +++ b/obt/keyboard.c @@ -281,7 +281,7 @@ KeyCode* obt_keyboard_keysym_to_keycode(KeySym sym) return ret; } -gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev) +gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XEvent *ev) { gunichar unikey = 0; KeySym sym; @@ -290,6 +290,8 @@ gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev) gint len, bufsz; gboolean got_string = FALSE; + g_return_val_if_fail(ev->type == KeyPress, 0); + if (!ic) g_warning("Using obt_keyboard_keypress_to_unichar() without an " "Input Context. No i18n support!"); @@ -299,9 +301,9 @@ gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev) bufsz = sizeof(fixbuf); #ifdef X_HAVE_UTF8_STRING - len = Xutf8LookupString(ic->xic, ev, buf, bufsz, &sym, &status); + len = Xutf8LookupString(ic->xic, &ev->xkey, buf, bufsz, &sym, &status); #else - len = XmbLookupString(ic->xic, ev, buf, bufsz, &sym, &status); + len = XmbLookupString(ic->xic, &ev->xkey, buf, bufsz, &sym, &status); #endif if (status == XBufferOverflow) { @@ -309,9 +311,11 @@ gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev) bufsz = len; #ifdef X_HAVE_UTF8_STRING - len = Xutf8LookupString(ic->xic, ev, buf, bufsz, &sym, &status); + len = Xutf8LookupString(ic->xic, &ev->xkey, buf, bufsz, &sym, + &status); #else - len = XmbLookupString(ic->xic, ev, buf, bufsz, &sym, &status); + len = XmbLookupString(ic->xic, &ev->xkey, buf, bufsz, &sym, + &status); #endif } @@ -338,7 +342,7 @@ gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev) else { buf = fixbuf; bufsz = sizeof(fixbuf); - len = XLookupString(ev, buf, bufsz, &sym, NULL); + len = XLookupString(&ev->xkey, buf, bufsz, &sym, NULL); if ((guchar)buf[0] >= 32) /* not an ascii control character */ got_string = TRUE; } @@ -354,6 +358,18 @@ gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev) return unikey; } +KeySym obt_keyboard_keypress_to_keysym(XEvent *ev) +{ + KeySym sym; + gint r; + + g_return_val_if_fail(ev->type == KeyPress, None); + + sym = None; + r = XLookupString(&ev->xkey, NULL, 0, &sym, NULL); + return sym; +} + void obt_keyboard_context_renew(ObtIC *ic) { if (ic->xic) { diff --git a/obt/keyboard.h b/obt/keyboard.h index 902f95b8..143921ff 100644 --- a/obt/keyboard.h +++ b/obt/keyboard.h @@ -21,6 +21,7 @@ #include <glib.h> #include <X11/Xlib.h> +#include <X11/keysym.h> G_BEGIN_DECLS @@ -60,7 +61,11 @@ guint obt_keyboard_modkey_to_modmask(ObtModkeysKey key); KeyCode* obt_keyboard_keysym_to_keycode(KeySym sym); /*! Translate a KeyPress event to the unicode character it represents */ -gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XKeyPressedEvent *ev); +gunichar obt_keyboard_keypress_to_unichar(ObtIC *ic, XEvent *ev); + +/*! Translate a KeyPress event to the KeySym that it represents. Use this + for control keys, not for getting text input! */ +KeySym obt_keyboard_keypress_to_keysym(XEvent *ev); /*! Create an input context for a window. @client The top-level client window for the input context. |
