Define our own NoSymbol value and use it
Since we have our own xkb_keysym_t type, it makes sense to have our own NoSymbol value instead of the one from X11/X.h. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
d3908b631c
commit
602e87805b
|
@ -97,6 +97,8 @@ 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)
|
||||
|
|
|
@ -26,7 +26,10 @@ from The Open Group.
|
|||
|
||||
*/
|
||||
|
||||
/* Constructs hash tables for XStringToKeysym and XKeysymToString. */
|
||||
/*
|
||||
* Constructs hash tables for xkb_keysym_to_string and
|
||||
* xkb_string_from_keysym.
|
||||
*/
|
||||
|
||||
#include "xkbcommon/xkbcommon.h"
|
||||
|
||||
|
@ -151,9 +154,9 @@ main(int argc, char *argv[])
|
|||
fclose(fptr);
|
||||
}
|
||||
|
||||
/* Special case NoSymbol. */
|
||||
/* Special case XKB_KEYSYM_NO_SYMBOL. */
|
||||
info[ksnum].name = strdup("NoSymbol");
|
||||
info[ksnum].val = 0L;
|
||||
info[ksnum].val = XKB_KEYSYM_NO_SYMBOL;
|
||||
ksnum++;
|
||||
|
||||
printf("/* This file is generated from keysymdef.h. */\n");
|
||||
|
|
11
src/keysym.c
11
src/keysym.c
|
@ -28,7 +28,6 @@ authorization from the authors.
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <X11/X.h>
|
||||
#include <X11/keysymdef.h>
|
||||
#include "xkbmisc.h"
|
||||
#include "xkbcommon/xkbcommon.h"
|
||||
|
@ -50,7 +49,7 @@ xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size)
|
|||
}
|
||||
|
||||
/* Not listed in keysymdef.h for hysterical raisins. */
|
||||
if (ks == NoSymbol) {
|
||||
if (ks == XKB_KEYSYM_NO_SYMBOL) {
|
||||
snprintf(buffer, size, "NoSymbol");
|
||||
return;
|
||||
}
|
||||
|
@ -135,11 +134,11 @@ xkb_string_to_keysym(const char *s)
|
|||
val = strtoul(&s[1], NULL, 16);
|
||||
|
||||
if (val < 0x20 || (val > 0x7e && val < 0xa0))
|
||||
return NoSymbol;
|
||||
return XKB_KEYSYM_NO_SYMBOL;
|
||||
if (val < 0x100)
|
||||
return val;
|
||||
if (val > 0x10ffff)
|
||||
return NoSymbol;
|
||||
return XKB_KEYSYM_NO_SYMBOL;
|
||||
return val | 0x01000000;
|
||||
}
|
||||
else if (s[0] == '0' && s[1] == 'x') {
|
||||
|
@ -153,12 +152,12 @@ xkb_string_to_keysym(const char *s)
|
|||
xkb_keysym_t ret;
|
||||
char *tmp = strdup(s);
|
||||
if (!tmp)
|
||||
return NoSymbol;
|
||||
return XKB_KEYSYM_NO_SYMBOL;
|
||||
memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
|
||||
ret = xkb_string_to_keysym(tmp);
|
||||
free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return NoSymbol;
|
||||
return XKB_KEYSYM_NO_SYMBOL;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
|
|||
return BadAlloc;
|
||||
}
|
||||
map->num_syms = 1;
|
||||
map->syms[0] = NoSymbol;
|
||||
map->syms[0] = XKB_KEYSYM_NO_SYMBOL;
|
||||
}
|
||||
|
||||
if (!map->key_sym_map) {
|
||||
|
@ -295,7 +295,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
|
|||
if (!newSyms)
|
||||
return NULL;
|
||||
|
||||
newSyms[0] = NoSymbol;
|
||||
newSyms[0] = XKB_KEYSYM_NO_SYMBOL;
|
||||
nSyms = 1;
|
||||
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
|
||||
uint32_t nCopy;
|
||||
|
|
|
@ -305,7 +305,7 @@ xkb_key_get_syms_by_level(struct xkb_desc *xkb, xkb_keycode_t key, unsigned int
|
|||
unsigned int level, xkb_keysym_t **syms_out)
|
||||
{
|
||||
*syms_out = &(XkbKeySymEntry(xkb, key, level, group));
|
||||
if (**syms_out == NoSymbol)
|
||||
if (**syms_out == XKB_KEYSYM_NO_SYMBOL)
|
||||
goto err;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -27,7 +27,6 @@ authorization from the authors.
|
|||
#ifndef _XKBALLOC_H_
|
||||
#define _XKBALLOC_H_
|
||||
|
||||
#include <X11/Xdefs.h>
|
||||
#include <X11/X.h>
|
||||
#include "xkbcommon/xkbcommon.h"
|
||||
#include "XKBcommonint.h"
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
********************************************************/
|
||||
|
||||
#include <X11/X.h>
|
||||
|
||||
#include "xkbcomp.h"
|
||||
#include "xkbmisc.h"
|
||||
#include "expr.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
********************************************************/
|
||||
|
||||
#include <X11/Xos.h>
|
||||
#include "xkbcomp.h"
|
||||
#include "xkballoc.h"
|
||||
#include "xkbmisc.h"
|
||||
|
@ -778,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 == NoSymbol)) ||
|
||||
((!needSymbol) && (si->interp.sym != NoSymbol)))
|
||||
(needSymbol && (si->interp.sym == XKB_KEYSYM_NO_SYMBOL)) ||
|
||||
((!needSymbol) && (si->interp.sym != XKB_KEYSYM_NO_SYMBOL)))
|
||||
continue;
|
||||
if (compat->num_si >= compat->size_si)
|
||||
{
|
||||
|
@ -894,7 +893,7 @@ UpdateActionMods(struct xkb_desc *xkb, union xkb_action *act, uint32_t rmodmask)
|
|||
/**
|
||||
* Find an interpretation which applies to this particular level, either by
|
||||
* finding an exact match for the symbol and modifier combination, or a
|
||||
* generic NoSymbol match.
|
||||
* generic XKB_KEYSYM_NO_SYMBOL match.
|
||||
*/
|
||||
static struct xkb_sym_interpret *
|
||||
FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32_t level)
|
||||
|
@ -914,7 +913,7 @@ FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32
|
|||
Bool found;
|
||||
|
||||
if ((num_syms != 1 || interp->sym != syms[0]) &&
|
||||
interp->sym != NoSymbol)
|
||||
interp->sym != XKB_KEYSYM_NO_SYMBOL)
|
||||
continue;
|
||||
|
||||
if (level == 0 || !(interp->match & XkbSI_LevelOneOnly))
|
||||
|
@ -943,7 +942,7 @@ FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32
|
|||
break;
|
||||
}
|
||||
|
||||
if (found && interp->sym != NoSymbol)
|
||||
if (found && interp->sym != XKB_KEYSYM_NO_SYMBOL)
|
||||
return interp;
|
||||
else if (found && !ret)
|
||||
ret = interp;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "vmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <X11/X.h>
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
|
@ -985,12 +984,14 @@ ExprResolveKeySym(ExprDef * expr,
|
|||
{
|
||||
const char *str;
|
||||
str = XkbcAtomText(expr->value.str);
|
||||
if ((str != NULL) && ((sym = xkb_string_to_keysym(str)) != NoSymbol))
|
||||
{
|
||||
if (str) {
|
||||
sym = xkb_string_to_keysym(str);
|
||||
if (sym != XKB_KEYSYM_NO_SYMBOL) {
|
||||
val_rtrn->uval = sym;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
}
|
||||
ok = ExprResolveInteger(expr, val_rtrn);
|
||||
if ((ok) && (val_rtrn->uval < 10))
|
||||
val_rtrn->uval += '0';
|
||||
|
|
|
@ -440,7 +440,7 @@ LookupKeysym(char *str, xkb_keysym_t * sym_rtrn)
|
|||
if ((!str) || (strcasecmp(str, "any") == 0) ||
|
||||
(strcasecmp(str, "nosymbol") == 0))
|
||||
{
|
||||
*sym_rtrn = NoSymbol;
|
||||
*sym_rtrn = XKB_KEYSYM_NO_SYMBOL;
|
||||
return 1;
|
||||
}
|
||||
else if ((strcasecmp(str, "none") == 0) ||
|
||||
|
@ -450,7 +450,7 @@ LookupKeysym(char *str, xkb_keysym_t * sym_rtrn)
|
|||
return 1;
|
||||
}
|
||||
sym = xkb_string_to_keysym(str);
|
||||
if (sym != NoSymbol)
|
||||
if (sym != XKB_KEYSYM_NO_SYMBOL)
|
||||
{
|
||||
*sym_rtrn = sym;
|
||||
return 1;
|
||||
|
|
|
@ -358,14 +358,14 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
if (from->syms[group] && (i < from->numLevels[group]))
|
||||
fromSym = from->syms[group][i];
|
||||
else
|
||||
fromSym = NoSymbol;
|
||||
fromSym = XKB_KEYSYM_NO_SYMBOL;
|
||||
if (into->syms[group] && (i < into->numLevels[group]))
|
||||
toSym = into->syms[group][i];
|
||||
else
|
||||
toSym = NoSymbol;
|
||||
if ((fromSym == NoSymbol) || (fromSym == toSym))
|
||||
toSym = XKB_KEYSYM_NO_SYMBOL;
|
||||
if ((fromSym == XKB_KEYSYM_NO_SYMBOL) || (fromSym == toSym))
|
||||
resultSyms[i] = toSym;
|
||||
else if (toSym == NoSymbol)
|
||||
else if (toSym == XKB_KEYSYM_NO_SYMBOL)
|
||||
resultSyms[i] = fromSym;
|
||||
else
|
||||
{
|
||||
|
@ -927,11 +927,11 @@ AddSymbolsToKey(KeyInfo * key,
|
|||
WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
|
||||
value->value.list.syms[i], longText(key->name), ndx + 1,
|
||||
XkbcAtomText(info->groupNames[ndx]), nSyms);
|
||||
key->syms[ndx][i] = NoSymbol;
|
||||
key->syms[ndx][i] = XKB_KEYSYM_NO_SYMBOL;
|
||||
}
|
||||
}
|
||||
for (j = key->numLevels[ndx] - 1;
|
||||
(j >= 0) && (key->syms[ndx][j] == NoSymbol); j--)
|
||||
(j >= 0) && (key->syms[ndx][j] == XKB_KEYSYM_NO_SYMBOL); j--)
|
||||
{
|
||||
key->numLevels[ndx]--;
|
||||
}
|
||||
|
@ -1878,7 +1878,7 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
|
|||
if (tmp < key->numLevels[i])
|
||||
outSyms[tmp] = key->syms[i][tmp];
|
||||
else
|
||||
outSyms[tmp] = NoSymbol;
|
||||
outSyms[tmp] = XKB_KEYSYM_NO_SYMBOL;
|
||||
if ((outActs != NULL) && (key->acts[i] != NULL))
|
||||
{
|
||||
if (tmp < key->numLevels[i])
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#define _XKBPATH_H_ 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xdefs.h>
|
||||
|
||||
extern const char *XkbDirectoryForInclude(unsigned /* type */
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <X11/Xos.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "parseutils.h"
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/X.h>
|
||||
|
||||
static void print_keysym(const char *s)
|
||||
{
|
||||
xkb_keysym_t ks = xkb_string_to_keysym(s);
|
||||
if (ks == NoSymbol)
|
||||
if (ks == XKB_KEYSYM_NO_SYMBOL)
|
||||
printf("NoSymbol\n");
|
||||
else
|
||||
printf("0x%lX\n", ks);
|
||||
|
|
Loading…
Reference in New Issue