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;
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!");
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) {
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
}
got_string = TRUE;
}
}
+ else if (status == XLookupKeySym)
+ /* this key doesn't have a text representation, it is a command
+ key of some sort */;
else
g_message("Bad keycode lookup. Keysym 0x%x Status: %s\n",
(guint) sym,
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;
}
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) {