From: Kristian Høgsberg Date: Wed, 9 May 2012 13:05:00 +0000 (-0400) Subject: Use our own keysyms X-Git-Tag: xkbcommon-0.2.0~592^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ace1e5df6d2f9cd7ecf5fa5088d5c79fbd1edd64;p=platform%2Fupstream%2Flibxkbcommon.git Use our own keysyms --- diff --git a/Makefile.am b/Makefile.am index dcd9f24..c50880b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -93,7 +93,7 @@ makekeys_makekeys_CFLAGS = $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) makekeys_makekeys_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD) src/ks_tables.h: $(KEYSYMDEFS) $(top_builddir)/makekeys/makekeys$(EXEEXT) - $(top_builddir)/makekeys/makekeys $(KEYSYMDEFS) > $@ + $(top_builddir)/makekeys/makekeys $(top_srcdir)/include/xkbcommon/xkbcommon-keysyms.h > $@ # Tests diff --git a/include/xkbcommon/xkbcommon.h b/include/xkbcommon/xkbcommon.h index c80fad8..2c7ad22 100644 --- a/include/xkbcommon/xkbcommon.h +++ b/include/xkbcommon/xkbcommon.h @@ -85,6 +85,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include +#define XKB_KEY_NoSymbol 0L /* special KeySym */ + typedef uint32_t xkb_keycode_t; typedef uint32_t xkb_keysym_t; typedef uint32_t xkb_mod_index_t; @@ -97,8 +99,6 @@ typedef uint32_t xkb_led_index_t; #define XKB_KEYCODE_INVALID (0xffffffff) #define XKB_LED_INVALID (0xffffffff) -#define XKB_KEYSYM_NO_SYMBOL 0 - #define XKB_KEYCODE_MAX (0xffffffff - 1) #define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX) #define xkb_keycode_is_legal_x11(kc) (kc <= XKB_KEYCODE_MAX) diff --git a/makekeys/makekeys.c b/makekeys/makekeys.c index 1b873aa..9d77cdf 100644 --- a/makekeys/makekeys.c +++ b/makekeys/makekeys.c @@ -32,8 +32,8 @@ from The Open Group. */ #include "xkbcommon/xkbcommon.h" +#include "xkbcommon/xkbcommon-keysyms.h" -#include #include #include #include @@ -62,40 +62,19 @@ parse_line(const char *buf, char *key, xkb_keysym_t *val, char *prefix) { int i; char alias[128]; - char *tmp, *tmpa; /* See if we can catch a straight XK_foo 0x1234-style definition first; * the trickery around tmp is to account for prefices. */ i = sscanf(buf, "#define %127s 0x%"SCNx32, key, val); - if (i == 2 && (tmp = strstr(key, "XK_"))) { - memcpy(prefix, key, tmp - key); - prefix[tmp - key] = '\0'; - tmp += 3; - memmove(key, tmp, strlen(tmp) + 1); + if (i == 2 && strncmp(key, "XKB_KEY_", 8) == 0) { + prefix[0] = '\0'; + memmove(key, key + 8, strlen(key + 8) + 1); return 1; } - /* Now try to catch alias (XK_foo XK_bar) definitions, and resolve them - * immediately: if the target is in the form XF86XK_foo, we need to - * canonicalise this to XF86foo before we do the lookup. */ i = sscanf(buf, "#define %127s %127s", key, alias); - if (i == 2 && (tmp = strstr(key, "XK_")) && (tmpa = strstr(alias, "XK_"))) { - memcpy(prefix, key, tmp - key); - prefix[tmp - key] = '\0'; - tmp += 3; - memmove(key, tmp, strlen(tmp) + 1); - memmove(tmpa, tmpa + 3, strlen(tmpa + 3) + 1); - - for (i = ksnum - 1; i >= 0; i--) { - if (strcmp(info[i].name, alias) == 0) { - *val = info[i].val; - return 1; - } - } - - fprintf(stderr, "can't find matching definition %s for keysym %s%s\n", - alias, prefix, key); - } + if (i == 2) + fprintf(stderr, "can't parse keysym definition: %s", buf); return 0; } @@ -128,7 +107,7 @@ main(int argc, char *argv[]) if (!parse_line(buf, key, &val, prefix)) continue; - if (val == XK_VoidSymbol) + if (val == XKB_KEY_VoidSymbol) val = 0; if (val > 0x1fffffff) { fprintf(stderr, "ignoring illegal keysym (%s, %"PRIx32")\n", key, @@ -154,9 +133,9 @@ main(int argc, char *argv[]) fclose(fptr); } - /* Special case XKB_KEYSYM_NO_SYMBOL. */ + /* Special case XKB_KEY_NoSymbol. */ info[ksnum].name = strdup("NoSymbol"); - info[ksnum].val = XKB_KEYSYM_NO_SYMBOL; + info[ksnum].val = XKB_KEY_NoSymbol; ksnum++; printf("/* This file is generated from keysymdef.h. */\n"); diff --git a/src/keysym.c b/src/keysym.c index 5079419..1a9c7ec 100644 --- a/src/keysym.c +++ b/src/keysym.c @@ -28,7 +28,6 @@ authorization from the authors. #include #include #include -#include #include "ks_tables.h" #include "xkbmisc.h" @@ -47,7 +46,7 @@ xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size) } /* Not listed in keysymdef.h for hysterical raisins. */ - if (ks == XKB_KEYSYM_NO_SYMBOL) { + if (ks == XKB_KEY_NoSymbol) { snprintf(buffer, size, "NoSymbol"); return; } @@ -117,7 +116,7 @@ xkb_string_to_keysym(const char *s) val = (entry[2] << 24) | (entry[3] << 16) | (entry[4] << 8) | entry[5]; if (!val) - val = XK_VoidSymbol; + val = XKB_KEY_VoidSymbol; return val; } @@ -132,20 +131,20 @@ xkb_string_to_keysym(const char *s) if (*s == 'U') { val = strtoul(&s[1], &tmp, 16); if (tmp && *tmp != '\0') - return XKB_KEYSYM_NO_SYMBOL; + return XKB_KEY_NoSymbol; if (val < 0x20 || (val > 0x7e && val < 0xa0)) - return XKB_KEYSYM_NO_SYMBOL; + return XKB_KEY_NoSymbol; if (val < 0x100) return val; if (val > 0x10ffff) - return XKB_KEYSYM_NO_SYMBOL; + return XKB_KEY_NoSymbol; return val | 0x01000000; } else if (s[0] == '0' && s[1] == 'x') { val = strtoul(&s[2], &tmp, 16); if (tmp && *tmp != '\0') - return XKB_KEYSYM_NO_SYMBOL; + return XKB_KEY_NoSymbol; return val; } @@ -157,12 +156,12 @@ xkb_string_to_keysym(const char *s) xkb_keysym_t ret; tmp = strdup(s); if (!tmp) - return XKB_KEYSYM_NO_SYMBOL; + return XKB_KEY_NoSymbol; memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1); ret = xkb_string_to_keysym(tmp); free(tmp); return ret; } - return XKB_KEYSYM_NO_SYMBOL; + return XKB_KEY_NoSymbol; } diff --git a/src/misc.c b/src/misc.c index f15631e..c2d17d5 100644 --- a/src/misc.c +++ b/src/misc.c @@ -28,7 +28,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xkbmisc.h" #include "xkbcommon/xkbcommon.h" #include "XKBcommonint.h" -#include #define mapSize(m) (sizeof(m) / sizeof(struct xkb_kt_map_entry)) static struct xkb_kt_map_entry map2Level[]= { @@ -192,69 +191,69 @@ _XkbcKSCheckCase(xkb_keysym_t ks) switch (set) { case 0: /* latin 1 */ - if ((ks >= XK_A && ks <= XK_Z) || - (ks >= XK_Agrave && ks <= XK_THORN && ks != XK_multiply)) + if ((ks >= XKB_KEY_A && ks <= XKB_KEY_Z) || + (ks >= XKB_KEY_Agrave && ks <= XKB_KEY_THORN && ks != XKB_KEY_multiply)) rtrn |= _XkbKSUpper; - if ((ks >= XK_a && ks <= XK_z) || - (ks >= XK_agrave && ks <= XK_ydiaeresis)) + if ((ks >= XKB_KEY_a && ks <= XKB_KEY_z) || + (ks >= XKB_KEY_agrave && ks <= XKB_KEY_ydiaeresis)) rtrn |= _XkbKSLower; break; case 1: /* latin 2 */ - if ((ks >= XK_Aogonek && ks <= XK_Zabovedot && ks != XK_breve) || - (ks >= XK_Racute && ks<=XK_Tcedilla)) + if ((ks >= XKB_KEY_Aogonek && ks <= XKB_KEY_Zabovedot && ks != XKB_KEY_breve) || + (ks >= XKB_KEY_Racute && ks<=XKB_KEY_Tcedilla)) rtrn |= _XkbKSUpper; - if ((ks >= XK_aogonek && ks <= XK_zabovedot && ks != XK_caron) || - (ks >= XK_racute && ks <= XK_tcedilla)) + if ((ks >= XKB_KEY_aogonek && ks <= XKB_KEY_zabovedot && ks != XKB_KEY_caron) || + (ks >= XKB_KEY_racute && ks <= XKB_KEY_tcedilla)) rtrn |= _XkbKSLower; break; case 2: /* latin 3 */ - if ((ks >= XK_Hstroke && ks <= XK_Jcircumflex) || - (ks >= XK_Cabovedot && ks <= XK_Scircumflex)) + if ((ks >= XKB_KEY_Hstroke && ks <= XKB_KEY_Jcircumflex) || + (ks >= XKB_KEY_Cabovedot && ks <= XKB_KEY_Scircumflex)) rtrn |= _XkbKSUpper; - if ((ks >= XK_hstroke && ks <= XK_jcircumflex) || - (ks >= XK_cabovedot && ks <= XK_scircumflex)) + if ((ks >= XKB_KEY_hstroke && ks <= XKB_KEY_jcircumflex) || + (ks >= XKB_KEY_cabovedot && ks <= XKB_KEY_scircumflex)) rtrn |= _XkbKSLower; break; case 3: /* latin 4 */ - if ((ks >= XK_Rcedilla && ks <= XK_Tslash) || - (ks == XK_ENG) || - (ks >= XK_Amacron && ks <= XK_Umacron)) + if ((ks >= XKB_KEY_Rcedilla && ks <= XKB_KEY_Tslash) || + (ks == XKB_KEY_ENG) || + (ks >= XKB_KEY_Amacron && ks <= XKB_KEY_Umacron)) rtrn |= _XkbKSUpper; - if ((ks >= XK_rcedilla && ks <= XK_tslash) || - (ks == XK_eng) || - (ks >= XK_amacron && ks <= XK_umacron)) + if ((ks >= XKB_KEY_rcedilla && ks <= XKB_KEY_tslash) || + (ks == XKB_KEY_eng) || + (ks >= XKB_KEY_amacron && ks <= XKB_KEY_umacron)) rtrn |= _XkbKSLower; break; case 18: /* latin 8 */ - if ((ks == XK_Wcircumflex) || - (ks == XK_Ycircumflex) || - (ks == XK_Babovedot) || - (ks == XK_Dabovedot) || - (ks == XK_Fabovedot) || - (ks == XK_Mabovedot) || - (ks == XK_Pabovedot) || - (ks == XK_Sabovedot) || - (ks == XK_Tabovedot) || - (ks == XK_Wdiaeresis) || - (ks == XK_Ygrave)) + if ((ks == XKB_KEY_Wcircumflex) || + (ks == XKB_KEY_Ycircumflex) || + (ks == XKB_KEY_Babovedot) || + (ks == XKB_KEY_Dabovedot) || + (ks == XKB_KEY_Fabovedot) || + (ks == XKB_KEY_Mabovedot) || + (ks == XKB_KEY_Pabovedot) || + (ks == XKB_KEY_Sabovedot) || + (ks == XKB_KEY_Tabovedot) || + (ks == XKB_KEY_Wdiaeresis) || + (ks == XKB_KEY_Ygrave)) rtrn |= _XkbKSUpper; - if ((ks == XK_wcircumflex) || - (ks == XK_ycircumflex) || - (ks == XK_babovedot) || - (ks == XK_dabovedot) || - (ks == XK_fabovedot) || - (ks == XK_mabovedot) || - (ks == XK_pabovedot) || - (ks == XK_sabovedot) || - (ks == XK_tabovedot) || - (ks == XK_wdiaeresis) || - (ks == XK_ygrave)) + if ((ks == XKB_KEY_wcircumflex) || + (ks == XKB_KEY_ycircumflex) || + (ks == XKB_KEY_babovedot) || + (ks == XKB_KEY_dabovedot) || + (ks == XKB_KEY_fabovedot) || + (ks == XKB_KEY_mabovedot) || + (ks == XKB_KEY_pabovedot) || + (ks == XKB_KEY_sabovedot) || + (ks == XKB_KEY_tabovedot) || + (ks == XKB_KEY_wdiaeresis) || + (ks == XKB_KEY_ygrave)) rtrn |= _XkbKSLower; break; case 19: /* latin 9 */ - if (ks == XK_OE || ks == XK_Ydiaeresis) + if (ks == XKB_KEY_OE || ks == XKB_KEY_Ydiaeresis) rtrn |= _XkbKSUpper; - if (ks == XK_oe) + if (ks == XKB_KEY_oe) rtrn |= _XkbKSLower; break; } diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 18d1615..13c1ede 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -777,8 +777,8 @@ CopyInterps(CompatInfo * info, for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next) { if (((si->interp.match & XkbSI_OpMask) != pred) || - (needSymbol && (si->interp.sym == XKB_KEYSYM_NO_SYMBOL)) || - ((!needSymbol) && (si->interp.sym != XKB_KEYSYM_NO_SYMBOL))) + (needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) || + ((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol))) continue; if (compat->num_si >= compat->size_si) { @@ -892,7 +892,7 @@ UpdateActionMods(struct xkb_keymap *xkb, union xkb_action *act, uint32_t rmodmas /** * Find an interpretation which applies to this particular level, either by * finding an exact match for the symbol and modifier combination, or a - * generic XKB_KEYSYM_NO_SYMBOL match. + * generic XKB_KEY_NoSymbol match. */ static struct xkb_sym_interpret * FindInterpForKey(struct xkb_keymap *xkb, xkb_keycode_t key, uint32_t group, uint32_t level) @@ -912,7 +912,7 @@ FindInterpForKey(struct xkb_keymap *xkb, xkb_keycode_t key, uint32_t group, uint bool found; if ((num_syms > 1 || interp->sym != syms[0]) && - interp->sym != XKB_KEYSYM_NO_SYMBOL) + interp->sym != XKB_KEY_NoSymbol) continue; if (level == 0 || !(interp->match & XkbSI_LevelOneOnly)) @@ -941,7 +941,7 @@ FindInterpForKey(struct xkb_keymap *xkb, xkb_keycode_t key, uint32_t group, uint break; } - if (found && interp->sym != XKB_KEYSYM_NO_SYMBOL) + if (found && interp->sym != XKB_KEY_NoSymbol) return interp; else if (found && !ret) ret = interp; diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index c33e78e..6078429 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -985,7 +985,7 @@ ExprResolveKeySym(ExprDef * expr, str = XkbcAtomText(expr->value.str); if (str) { sym = xkb_string_to_keysym(str); - if (sym != XKB_KEYSYM_NO_SYMBOL) { + if (sym != XKB_KEY_NoSymbol) { val_rtrn->uval = sym; return true; } diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index 06183c5..637a667 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -29,8 +29,6 @@ #include "xkbpath.h" #include "xkbparse.h" -#include - ParseCommon * AppendStmt(ParseCommon * to, ParseCommon * append) { @@ -540,17 +538,17 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn) if ((!str) || (strcasecmp(str, "any") == 0) || (strcasecmp(str, "nosymbol") == 0)) { - *sym_rtrn = XKB_KEYSYM_NO_SYMBOL; + *sym_rtrn = XKB_KEY_NoSymbol; return 1; } else if ((strcasecmp(str, "none") == 0) || (strcasecmp(str, "voidsymbol") == 0)) { - *sym_rtrn = XK_VoidSymbol; + *sym_rtrn = XKB_KEY_VoidSymbol; return 1; } sym = xkb_string_to_keysym(str); - if (sym != XKB_KEYSYM_NO_SYMBOL) + if (sym != XKB_KEY_NoSymbol) { *sym_rtrn = sym; return 1; diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 9582d8e..07adbb5 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -30,7 +30,6 @@ #include "expr.h" #include "parseutils.h" -#include #include #include "expr.h" @@ -1079,7 +1078,7 @@ AddSymbolsToKey(KeyInfo * key, value->value.list.syms[i], longText(key->name), ndx + 1, XkbcAtomText(info->groupNames[ndx]), nSyms); while (--j >= 0) - key->syms[ndx][key->symsMapIndex[ndx][i] + j] = NoSymbol; + key->syms[ndx][key->symsMapIndex[ndx][i] + j] = XKB_KEY_NoSymbol; key->symsMapIndex[ndx][i] = -1; key->symsMapNumEntries[ndx][i] = 0; break; diff --git a/src/xkbcomp/xkbparse.y b/src/xkbcomp/xkbparse.y index ffccc75..0245792 100644 --- a/src/xkbcomp/xkbparse.y +++ b/src/xkbcomp/xkbparse.y @@ -31,7 +31,6 @@ #include "parseutils.h" #include "xkbmisc.h" -#include #include extern int yylex(union YYSTYPE *val, struct YYLTYPE *loc, void *scanner); diff --git a/src/xkbmisc.h b/src/xkbmisc.h index b9b9a39..eac6e57 100644 --- a/src/xkbmisc.h +++ b/src/xkbmisc.h @@ -64,7 +64,7 @@ _XkbcKSCheckCase(xkb_keysym_t sym); #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbKSLower) #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbKSUpper) -#define XkbKSIsKeypad(k) (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal)) +#define XkbKSIsKeypad(k) (((k) >= XKB_KEY_KP_Space) && ((k) <= XKB_KEY_KP_Equal)) /***====================================================================***/ diff --git a/test/state.c b/test/state.c index d698476..14c5229 100644 --- a/test/state.c +++ b/test/state.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "xkbcommon/xkbcommon.h" @@ -135,7 +134,7 @@ test_update_key(struct xkb_keymap *xkb) XKB_STATE_LOCKED)); assert(xkb_state_led_name_is_active(state, "Caps Lock")); num_syms = xkb_key_get_syms(state, KEY_Q + EVDEV_OFFSET, &syms); - assert(num_syms == 1 && syms[0] == XK_Q); + assert(num_syms == 1 && syms[0] == XKB_KEY_Q); /* Caps unlocked */ xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_DOWN); @@ -144,7 +143,7 @@ test_update_key(struct xkb_keymap *xkb) XKB_STATE_EFFECTIVE)); assert(!xkb_state_led_name_is_active(state, "Caps Lock")); num_syms = xkb_key_get_syms(state, KEY_Q + EVDEV_OFFSET, &syms); - assert(num_syms == 1 && syms[0] == XK_q); + assert(num_syms == 1 && syms[0] == XKB_KEY_q); xkb_state_unref(state); } diff --git a/test/xkey.c b/test/xkey.c index 3024a4d..68ffa71 100644 --- a/test/xkey.c +++ b/test/xkey.c @@ -35,7 +35,7 @@ int main(void) { assert(test_string("Undo", 0xFF65)); - assert(test_string("ThisKeyShouldNotExist", XKB_KEYSYM_NO_SYMBOL)); + assert(test_string("ThisKeyShouldNotExist", XKB_KEY_NoSymbol)); assert(test_string("XF86_Switch_VT_5", 0x1008FE05)); assert(test_string("VoidSymbol", 0xFFFFFF)); assert(test_string("U4567", 0x1004567));