Copy xkbfile IsUpper/IsLower macros
xkbcomp was using Xlib's XConvertCase to check upper/lowercase. That's a lot of code, so hopefully the xkbfile macros using _XkbKSCheckCase are good enough. This also required that <X11/keysym.h> is included to get all the XK_* definitions.master
parent
eff1c53873
commit
d43a7bf02f
|
@ -31,7 +31,7 @@ authorization from the authors.
|
|||
#include <X11/X.h>
|
||||
#include <X11/Xdefs.h>
|
||||
#include <X11/Xfuncproto.h>
|
||||
#include <X11/keysymdef.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XKBstrcommon.h>
|
||||
#include <X11/extensions/XKBgeomcommon.h>
|
||||
|
||||
|
@ -52,6 +52,11 @@ typedef struct _XkbcDesc {
|
|||
XkbGeometryPtr geom;
|
||||
} XkbcDescRec, *XkbcDescPtr;
|
||||
|
||||
#define _XkbcKSLower (1 << 0)
|
||||
#define _XkbcKSUpper (1 << 1)
|
||||
|
||||
#define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
|
||||
#define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
|
||||
#define XkbcKSIsKeypad(k) \
|
||||
(((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
|
||||
#define XkbcKSIsDeadKey(k) \
|
||||
|
@ -308,6 +313,9 @@ XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
|
|||
extern void
|
||||
XkbcEnsureSafeMapName(char *name);
|
||||
|
||||
extern unsigned
|
||||
_XkbcKSCheckCase(KeySym sym);
|
||||
|
||||
_XFUNCPROTOEND
|
||||
|
||||
#endif /* _XKBCOMMON_H_ */
|
||||
|
|
83
src/misc.c
83
src/misc.c
|
@ -184,3 +184,86 @@ XkbcEnsureSafeMapName(char *name)
|
|||
name++;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned
|
||||
_XkbcKSCheckCase(KeySym ks)
|
||||
{
|
||||
unsigned set,rtrn;
|
||||
|
||||
set= (ks & (~0xff)) >> 8;
|
||||
rtrn= 0;
|
||||
switch (set) {
|
||||
case 0: /* latin 1 */
|
||||
if (((ks>=XK_A)&&(ks<=XK_Z))||
|
||||
((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
|
||||
rtrn|= _XkbcKSUpper;
|
||||
}
|
||||
if (((ks>=XK_a)&&(ks<=XK_z))||
|
||||
((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
|
||||
rtrn|= _XkbcKSLower;
|
||||
}
|
||||
break;
|
||||
case 1: /* latin 2 */
|
||||
if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
|
||||
((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
|
||||
rtrn|= _XkbcKSUpper;
|
||||
}
|
||||
if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
|
||||
((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
|
||||
rtrn|= _XkbcKSLower;
|
||||
}
|
||||
break;
|
||||
case 2: /* latin 3 */
|
||||
if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
|
||||
((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
|
||||
rtrn|= _XkbcKSUpper;
|
||||
}
|
||||
if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
|
||||
((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
|
||||
rtrn|= _XkbcKSLower;
|
||||
}
|
||||
break;
|
||||
case 3: /* latin 4 */
|
||||
if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
|
||||
(ks==XK_ENG)||
|
||||
((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
|
||||
rtrn|= _XkbcKSUpper;
|
||||
}
|
||||
if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
|
||||
(ks==XK_eng)||
|
||||
((ks>=XK_amacron)&&(ks<=XK_umacron))) {
|
||||
rtrn|= _XkbcKSLower;
|
||||
}
|
||||
break;
|
||||
case 18: /* latin 8 */
|
||||
if ((ks==XK_Babovedot)||
|
||||
((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
|
||||
((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
|
||||
(ks==XK_Mabovedot)||
|
||||
(ks==XK_Pabovedot)||
|
||||
(ks==XK_Sabovedot)||
|
||||
(ks==XK_Wdiaeresis)||
|
||||
((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
|
||||
rtrn|= _XkbcKSUpper;
|
||||
}
|
||||
if ((ks==XK_babovedot)||
|
||||
(ks==XK_dabovedot)||
|
||||
(ks==XK_fabovedot)||
|
||||
(ks==XK_mabovedot)||
|
||||
((ks>=XK_wgrave)&&(ks<=XK_wacute))||
|
||||
(ks==XK_ygrave)||
|
||||
((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
|
||||
rtrn|= _XkbcKSLower;
|
||||
}
|
||||
break;
|
||||
case 19: /* latin 9 */
|
||||
if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
|
||||
rtrn|= _XkbcKSUpper;
|
||||
}
|
||||
if (ks==XK_oe) {
|
||||
rtrn|= _XkbcKSLower;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rtrn;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "expr.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "expr.h"
|
||||
|
@ -1748,28 +1747,6 @@ FindNamedType(XkbcDescPtr xkb, Atom name, unsigned *type_rtrn)
|
|||
return False;
|
||||
}
|
||||
|
||||
static Bool
|
||||
KSIsLower(KeySym ks)
|
||||
{
|
||||
KeySym lower, upper;
|
||||
XConvertCase(ks, &lower, &upper);
|
||||
|
||||
if (lower == upper)
|
||||
return False;
|
||||
return (ks == lower ? True : False);
|
||||
}
|
||||
|
||||
static Bool
|
||||
KSIsUpper(KeySym ks)
|
||||
{
|
||||
KeySym lower, upper;
|
||||
XConvertCase(ks, &lower, &upper);
|
||||
|
||||
if (lower == upper)
|
||||
return False;
|
||||
return (ks == upper ? True : False);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a type to the given sym and return the Atom for the type assigned.
|
||||
*
|
||||
|
@ -1798,7 +1775,7 @@ FindAutomaticType(int width, KeySym * syms, Atom * typeNameRtrn,
|
|||
}
|
||||
else if (width == 2)
|
||||
{
|
||||
if (syms && KSIsLower(syms[0]) && KSIsUpper(syms[1]))
|
||||
if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
|
||||
{
|
||||
*typeNameRtrn = XkbcInternAtom("ALPHABETIC", False);
|
||||
}
|
||||
|
@ -1815,8 +1792,8 @@ FindAutomaticType(int width, KeySym * syms, Atom * typeNameRtrn,
|
|||
}
|
||||
else if (width <= 4)
|
||||
{
|
||||
if (syms && KSIsLower(syms[0]) && KSIsUpper(syms[1]))
|
||||
if (KSIsLower(syms[2]) && KSIsUpper(syms[3]))
|
||||
if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
|
||||
if (XkbcKSIsLower(syms[2]) && XkbcKSIsUpper(syms[3]))
|
||||
*typeNameRtrn =
|
||||
XkbcInternAtom("FOUR_LEVEL_ALPHABETIC", False);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue