[PATCH 1/2] Correct compilation for ABI_XINPUT_VERSION >= 5
Paulo Cesar Pereira de Andrade
pcpa at mandriva.com.br
Wed Feb 4 12:52:20 PST 2009
This patch corrects compilation and is tested and functional.
It is a slightly modified to correct an inverted #if GET_ABI_MAJOR...
I posted at xorg at lists.freedesktop.org some time ago.
The only noticed missing feature is that autorepeat doesn't work with
ABI_XINPUT_VERSION >= 5. It also doesn't protect a lot of os-specific
code that now is a noop.
Signed-off-by: Paulo Cesar Pereira de Andrade <pcpa at mandriva.com.br>
---
src/atKeynames.h | 4 +-
src/kbd.c | 109 ++++++++++++++++++++++++++++++++++++-----------------
src/xf86OSKbd.h | 2 +
3 files changed, 79 insertions(+), 36 deletions(-)
diff --git a/src/atKeynames.h b/src/atKeynames.h
index 85f13ac..7dc2c70 100644
--- a/src/atKeynames.h
+++ b/src/atKeynames.h
@@ -67,7 +67,9 @@
#define ScrollLockMask Mod5Mask
#define KeyPressed(k) (keyc->postdown[k >> 3] & (1 << (k & 7)))
-#define ModifierDown(k) ((keyc->state & (k)) == (k))
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
+# define ModifierDown(k) ((keyc->state & (k)) == (k))
+#endif
/*
* NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
diff --git a/src/kbd.c b/src/kbd.c
index 38d6513..dd3e099 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -47,8 +47,10 @@
#include <X11/extensions/XKBsrv.h>
#endif
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
extern int XkbDfltRepeatDelay;
extern int XkbDfltRepeatInterval;
+#endif
#define CAPSFLAG 1
#define NUMFLAG 2
@@ -174,11 +176,13 @@ static const char *kbd98Defaults[] = {
NULL
};
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
const char *xkbSymbols[] = {
"XkbDfltRepeatDelay",
"XkbDfltRepeatInterval",
NULL,
};
+#endif
#ifdef XKB
static char *xkb_rules;
@@ -214,7 +218,8 @@ SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
}
-#define ModifierIsSet(k) ((modifiers & (k)) == (k))
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
+# define ModifierIsSet(k) ((modifiers & (k)) == (k))
static Bool
CommonSpecialKey(int key, Bool down, int modifiers)
@@ -244,7 +249,7 @@ CommonSpecialKey(int key, Bool down, int modifiers)
}
return FALSE;
}
-
+#endif
static InputInfoPtr
KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
@@ -290,7 +295,9 @@ KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pInfo->private = pKbd;
pKbd->PostEvent = PostKbdEvent;
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
xf86LoaderReqSymLists(xkbSymbols, NULL);
+#endif
if (!xf86OSKbdPreInit(pInfo))
return pInfo;
@@ -299,6 +306,7 @@ KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
return pInfo;
}
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
if ((s = xf86SetStrOption(pInfo->options, "AutoRepeat", NULL))) {
int delay, rate;
if (sscanf(s, "%d %d", &delay, &rate) != 2) {
@@ -311,6 +319,7 @@ KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
}
xfree(s);
}
+#endif
if ((s = xf86SetStrOption(pInfo->options, "XLeds", NULL))) {
char *l, *end;
@@ -329,7 +338,7 @@ KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
}
#ifdef XKB
-
+# if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
/* XkbDisable must be a server flag but for compatibility we check it here */
if (xf86FindOption(pInfo->options, "XkbDisable"))
@@ -340,7 +349,9 @@ KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pKbd->noXkb = noXkbExtension;
if (pKbd->noXkb) {
xf86Msg(X_CONFIG, "XKB: disabled\n");
- } else {
+ } else
+# endif
+ {
SetXkbOption(pInfo, "XkbKeymap", &xkbnames.keymap);
if (xkbnames.keymap) {
xf86Msg(X_CONFIG, "%s: XkbKeymap overrides all other XKB settings\n",
@@ -441,15 +452,18 @@ KbdCtrl( DeviceIntPtr device, KeybdCtrl *ctrl)
pKbd->keyLeds &= ~COMPOSEFLAG;
}
leds = ctrl->leds & ~(XCAPS | XNUM | XSCR); /* ??? */
-#ifdef XKB
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
+# ifdef XKB
if (pKbd->noXkb) {
-#endif
+# endif
pKbd->leds = (leds & pKbd->xledsMask) | (pKbd->leds & ~pKbd->xledsMask);
+ } else
+#endif
+ {
#ifdef XKB
- } else {
pKbd->leds = leds;
- }
#endif
+ }
pKbd->SetLeds(pInfo, pKbd->leds);
pKbd->autoRepeat = ctrl->autoRepeat;
@@ -544,8 +558,12 @@ KbdProc(DeviceIntPtr device, int what)
InputInfoPtr pInfo = device->public.devicePrivate;
KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 5
+ XkbRMLVOSet rmlvo;
+#else
KeySymsRec keySyms;
CARD8 modMap[MAP_LENGTH];
+#endif
int ret;
switch (what) {
@@ -554,18 +572,28 @@ KbdProc(DeviceIntPtr device, int what)
if (ret != Success)
return ret;
- pKbd->KbdGetMapping(pInfo, &keySyms, modMap);
-
device->public.on = FALSE;
-#ifdef XKB
+
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 5
+ rmlvo.rules = xkb_rules;
+ rmlvo.model = xkb_model;
+ rmlvo.layout = xkb_layout;
+ rmlvo.variant = xkb_variant;
+ rmlvo.options = xkb_options;
+ /* xkb is now mandatory */
+ InitKeyboardDeviceStruct(device, &rmlvo,
+ KbdBell, (KbdCtrlProcPtr)KbdCtrl);
+#else
+ pKbd->KbdGetMapping(pInfo, &keySyms, modMap);
+# ifdef XKB
if (pKbd->noXkb) {
-#endif
+# endif
InitKeyboardDeviceStruct((DevicePtr) device,
&keySyms,
modMap,
KbdBell,
(KbdCtrlProcPtr)KbdCtrl);
-#ifdef XKB
+# ifdef XKB
} else {
if (xkbnames.keymap)
xkb_rules = NULL;
@@ -578,7 +606,9 @@ KbdProc(DeviceIntPtr device, int what)
KbdBell,
(KbdCtrlProcPtr)KbdCtrl);
}
-#endif
+# endif /* ifdef XKB */
+#endif /* #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 5 */
+
InitKBD(pInfo, TRUE);
break;
case DEVICE_ON:
@@ -624,15 +654,17 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
DeviceIntPtr device = pInfo->dev;
- KeyClassRec *keyc = device->key;
- KbdFeedbackClassRec *kbdfeed = device->kbdfeed;
- int specialkey = 0;
+ int keycode;
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
+ int specialkey = 0;
+ KeyClassRec *keyc = device->key;
Bool UsePrefix = FALSE;
+ KbdFeedbackClassRec *kbdfeed = device->kbdfeed;
KeySym *keysym;
- int keycode;
unsigned long changeLock = 0;
static int lockkeys = 0;
+#endif
#ifdef DEBUG
ErrorF("kbd driver rec scancode: 0x02%x %s\n", scanCode, down?"down":"up");
@@ -669,6 +701,7 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
}
}
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
/*
* and now get some special keysequences
*/
@@ -685,16 +718,17 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
}
}
-#ifndef TERMINATE_FALLBACK
-#define TERMINATE_FALLBACK 0
-#endif
-#ifdef XKB
+
+# ifndef TERMINATE_FALLBACK
+# define TERMINATE_FALLBACK 0
+# endif
+# ifdef XKB
if (noXkbExtension
-#if TERMINATE_FALLBACK
+# if TERMINATE_FALLBACK
|| specialkey == KEY_BackSpace
-#endif
+# endif
)
-#endif
+# endif
{
if (CommonSpecialKey(specialkey, down, keyc->state))
return;
@@ -702,8 +736,8 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
if (pKbd->SpecialKey(pInfo, specialkey, down, keyc->state))
return;
}
-
-#ifndef __sparc64__
+
+# ifndef __sparc64__
/*
* PC keyboards generate separate key codes for
* Alt+Print and Control+Pause but in the X keyboard model
@@ -716,20 +750,23 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
else if (scanCode == KEY_Break)
scanCode = KEY_Pause;
}
-#endif
+# endif
+#endif /* #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5 */
sunKeyboards:
/*
* Now map the scancodes to real X-keycodes ...
*/
keycode = scanCode + MIN_KEYCODE;
+
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
keysym = (keyc->curKeySyms.map +
keyc->curKeySyms.mapWidth *
(keycode - keyc->curKeySyms.minKeyCode));
-#ifdef XKB
+# ifdef XKB
if (pKbd->noXkb) {
-#endif
+# endif
/*
* Filter autorepeated caps/num/scroll lock keycodes.
*/
@@ -811,7 +848,7 @@ sunKeyboards:
UpdateLeds(pInfo);
}
-#if !defined(CSRG_BASED) && \
+# if !defined(CSRG_BASED) && \
!defined(__GNU__) && \
defined(KB_84)
if (!pKbd->CustomKeycodes) {
@@ -830,11 +867,11 @@ sunKeyboards:
}
}
}
-#endif /* !CSRG_BASED && !GNU && KB_84 */
+# endif /* !CSRG_BASED && !GNU && KB_84 */
-#ifdef XKB
+# ifdef XKB
}
-#endif
+# endif
/*
* check for an autorepeat-event
@@ -855,7 +892,9 @@ sunKeyboards:
xf86PostKeyboardEvent(device, keycode, down);
xf86PostKeyboardEvent(device,
keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], FALSE);
- } else {
+ } else
+#endif /* #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5 */
+ {
xf86PostKeyboardEvent(device, keycode, down);
}
}
diff --git a/src/xf86OSKbd.h b/src/xf86OSKbd.h
index 4ab722c..28098a0 100644
--- a/src/xf86OSKbd.h
+++ b/src/xf86OSKbd.h
@@ -83,7 +83,9 @@ typedef struct {
int scanPrefix;
Bool vtSwitchSupported;
Bool CustomKeycodes;
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
Bool noXkb;
+#endif
Bool isConsole;
TransMapPtr scancodeMap;
TransMapPtr specialMap;
--
1.6.1
------=_20090204193337_98940--
More information about the xorg
mailing list