Merge remote-tracking branch 'krh/keysyms'

Conflicts:
	src/keysym.c
	src/misc.c
	src/text.h
	src/xkbcomp/expr.c
	src/xkbcomp/parser.y
	src/xkbcomp/parseutils.c
	src/xkbcomp/symbols.c

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-05-09 20:12:12 +01:00
commit 6433d72e7c
13 changed files with 3079 additions and 105 deletions

View File

@ -90,7 +90,7 @@ BUILT_SOURCES = \
CLEANFILES = $(BUILT_SOURCES)
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 > $@
$(top_builddir)/makekeys/makekeys$(EXEEXT): $(top_srcdir)/makekeys/makekeys.c
$(MAKE) -C makekeys
@ -120,3 +120,11 @@ test_context_LDADD = $(TESTS_LDADD)
check_PROGRAMS = $(TESTS)
EXTRA_DIST = test/data
# This sed script strips out lines that start with '#define _' which
# removes #define _OSF_Keysyms and such. The XK_Ydiaeresis case is to
# handle a duplicate definition in HPkeysyms.h which kicks in if it's
# not already defined.
update-keysyms:
sed -e '/XK_Ydiaeresis\s*0x100000ee/d; /#define _/d; s/#define\s*\(\w*\)XK_/#define XKB_KEY_\1/; /\(#ifdef\|#ifndef\|#endif\)/d' $(KEYSYMDEFS) > include/xkbcommon/xkbcommon-keysyms.h

File diff suppressed because it is too large Load Diff

View File

@ -83,6 +83,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include <xkbcommon/xkbcommon-keysyms.h>
#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;
@ -95,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)

View File

@ -33,7 +33,6 @@ from The Open Group.
#include "xkbcommon/xkbcommon.h"
#include <X11/keysymdef.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
@ -62,40 +61,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 +106,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 +132,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");

View File

@ -28,7 +28,6 @@ authorization from the authors.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <X11/keysym.h>
#include "xkb-priv.h"
#include "ks_tables.h"
@ -46,7 +45,7 @@ xkb_keysym_get_name(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;
}
@ -116,7 +115,7 @@ xkb_keysym_from_name(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;
}
@ -131,20 +130,20 @@ xkb_keysym_from_name(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;
}
@ -156,12 +155,12 @@ xkb_keysym_from_name(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_keysym_from_name(tmp);
free(tmp);
return ret;
}
return XKB_KEYSYM_NO_SYMBOL;
return XKB_KEY_NoSymbol;
}

View File

@ -24,8 +24,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
#include <X11/keysym.h>
#include "xkb-priv.h"
#include "alloc.h"
@ -143,69 +141,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;
}

View File

@ -463,6 +463,6 @@ _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))
#endif /* XKB_PRIV_H */

View File

@ -773,8 +773,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)
{
@ -886,7 +886,7 @@ UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
/**
* 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 *keymap, xkb_keycode_t key,
@ -907,7 +907,7 @@ FindInterpForKey(struct xkb_keymap *keymap, xkb_keycode_t key,
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))
@ -936,7 +936,7 @@ FindInterpForKey(struct xkb_keymap *keymap, xkb_keycode_t key,
break;
}
if (found && interp->sym != XKB_KEYSYM_NO_SYMBOL)
if (found && interp->sym != XKB_KEY_NoSymbol)
return interp;
else if (found && !ret)
ret = interp;

View File

@ -988,7 +988,7 @@ ExprResolveKeySym(struct xkb_ctx *ctx, ExprDef *expr,
str = xkb_atom_text(ctx, expr->value.str);
if (str) {
sym = xkb_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL) {
if (sym != XKB_KEY_NoSymbol) {
val_rtrn->uval = sym;
return true;
}

View File

@ -26,8 +26,6 @@
#include "parseutils.h"
#include <X11/keysym.h>
ParseCommon *
AppendStmt(ParseCommon * to, ParseCommon * append)
{
@ -537,17 +535,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_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL)
if (sym != XKB_KEY_NoSymbol)
{
*sym_rtrn = sym;
return 1;

View File

@ -24,8 +24,6 @@
********************************************************/
#include <X11/keysym.h>
#include "xkbcomp-priv.h"
#include "parseutils.h"
#include "action.h"
@ -1072,7 +1070,7 @@ AddSymbolsToKey(KeyInfo *key, struct xkb_keymap *keymap,
value->value.list.syms[i], longText(key->name), ndx + 1,
xkb_atom_text(keymap->ctx, 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;

View File

@ -26,7 +26,6 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/keysym.h>
#include <linux/input.h>
#include "xkbcommon/xkbcommon.h"
@ -155,7 +154,7 @@ test_update_key(struct xkb_keymap *keymap)
XKB_STATE_LOCKED));
assert(xkb_state_led_name_is_active(state, XKB_MOD_NAME_CAPS));
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);
@ -164,7 +163,7 @@ test_update_key(struct xkb_keymap *keymap)
XKB_STATE_EFFECTIVE));
assert(!xkb_state_led_name_is_active(state, XKB_MOD_NAME_CAPS));
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);
}

View File

@ -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));