Bug #3030: Fix Xnest keyboard state handling. (Mark McLoughlin)
This commit is contained in:
parent
8562f800b8
commit
aa7fb99bc7
|
@ -34,6 +34,7 @@ is" without express or implied warranty.
|
|||
#include "Screen.h"
|
||||
#include "XNWindow.h"
|
||||
#include "Events.h"
|
||||
#include "Keyboard.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
CARD32 lastEventTime = 0;
|
||||
|
@ -95,6 +96,16 @@ xnestCollectExposures()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
xnestQueueKeyEvent(int type, unsigned int keycode)
|
||||
{
|
||||
xEvent x;
|
||||
x.u.u.type = type;
|
||||
x.u.u.detail = keycode;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
||||
mieqEnqueue(&x);
|
||||
}
|
||||
|
||||
void
|
||||
xnestCollectEvents()
|
||||
{
|
||||
|
@ -105,17 +116,13 @@ xnestCollectEvents()
|
|||
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
|
||||
switch (X.type) {
|
||||
case KeyPress:
|
||||
x.u.u.type = KeyPress;
|
||||
x.u.u.detail = X.xkey.keycode;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
||||
mieqEnqueue(&x);
|
||||
xnestUpdateModifierState(X.xkey.state);
|
||||
xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
|
||||
break;
|
||||
|
||||
case KeyRelease:
|
||||
x.u.u.type = KeyRelease;
|
||||
x.u.u.detail = X.xkey.keycode;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
||||
mieqEnqueue(&x);
|
||||
xnestUpdateModifierState(X.xkey.state);
|
||||
xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
|
|
|
@ -26,5 +26,6 @@ extern CARD32 lastEventTime;
|
|||
void SetTimeSinceLastInputEvent(void);
|
||||
void xnestCollectExposures(void);
|
||||
void xnestCollectEvents(void);
|
||||
void xnestQueueKeyEvent(int type, unsigned int keycode);
|
||||
|
||||
#endif /* XNESTEVENTS_H */
|
||||
|
|
|
@ -87,15 +87,13 @@ InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
|
|||
void
|
||||
InitInput(int argc, char *argv[])
|
||||
{
|
||||
pointer ptr, kbd;
|
||||
xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
|
||||
xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, TRUE);
|
||||
|
||||
ptr = AddInputDevice(xnestPointerProc, TRUE);
|
||||
kbd = AddInputDevice(xnestKeyboardProc, TRUE);
|
||||
RegisterPointerDevice(xnestPointerDevice);
|
||||
RegisterKeyboardDevice(xnestKeyboardDevice);
|
||||
|
||||
RegisterPointerDevice(ptr);
|
||||
RegisterKeyboardDevice(kbd);
|
||||
|
||||
mieqInit(kbd, ptr);
|
||||
mieqInit((DevicePtr)xnestKeyboardDevice, (DevicePtr)xnestPointerDevice);
|
||||
|
||||
AddEnabledDevice(XConnectionNumber(xnestDisplay));
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ is" without express or implied warranty.
|
|||
#include "Screen.h"
|
||||
#include "Keyboard.h"
|
||||
#include "Args.h"
|
||||
#include "Events.h"
|
||||
|
||||
#ifdef XKB
|
||||
#include <X11/extensions/XKB.h>
|
||||
|
@ -83,6 +84,8 @@ extern Status XkbGetControls(
|
|||
|
||||
#endif
|
||||
|
||||
DeviceIntPtr xnestKeyboardDevice = NULL;
|
||||
|
||||
void
|
||||
xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
|
||||
{
|
||||
|
@ -282,3 +285,49 @@ LegalModifier(unsigned int key, DevicePtr pDev)
|
|||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xnestUpdateModifierState(unsigned int state)
|
||||
{
|
||||
DeviceIntPtr pDev = xnestKeyboardDevice;
|
||||
KeyClassPtr keyc = pDev->key;
|
||||
int i;
|
||||
CARD8 mask;
|
||||
|
||||
if (keyc->state == state)
|
||||
return;
|
||||
|
||||
for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
|
||||
int key;
|
||||
|
||||
/* Modifier is down, but shouldn't be
|
||||
*/
|
||||
if ((keyc->state & mask) && !(state & mask)) {
|
||||
int count = keyc->modifierKeyCount[i];
|
||||
|
||||
for (key = 0; key < MAP_LENGTH; key++)
|
||||
if (keyc->modifierMap[key] & mask) {
|
||||
int bit;
|
||||
BYTE *kptr;
|
||||
|
||||
kptr = &keyc->down[key >> 3];
|
||||
bit = 1 << (key & 7);
|
||||
|
||||
if (*kptr & bit)
|
||||
xnestQueueKeyEvent(KeyRelease, key);
|
||||
|
||||
if (--count == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modifier shoud be down, but isn't
|
||||
*/
|
||||
if (!(keyc->state & mask) && (state & mask))
|
||||
for (key = 0; key < MAP_LENGTH; key++)
|
||||
if (keyc->modifierMap[key] & mask) {
|
||||
xnestQueueKeyEvent(KeyPress, key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,11 @@ is" without express or implied warranty.
|
|||
#define XNEST_KEYBOARD_EVENT_MASK \
|
||||
(KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask)
|
||||
|
||||
extern DeviceIntPtr xnestKeyboardDevice;
|
||||
|
||||
void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls);
|
||||
void xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl);
|
||||
int xnestKeyboardProc(DeviceIntPtr pDev, int onoff);
|
||||
void xnestUpdateModifierState(unsigned int state);
|
||||
|
||||
#endif /* XNESTKEYBOARD_H */
|
||||
|
|
|
@ -31,6 +31,8 @@ is" without express or implied warranty.
|
|||
#include "Pointer.h"
|
||||
#include "Args.h"
|
||||
|
||||
DeviceIntPtr xnestPointerDevice = NULL;
|
||||
|
||||
void
|
||||
xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ is" without express or implied warranty.
|
|||
(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | \
|
||||
EnterWindowMask | LeaveWindowMask)
|
||||
|
||||
extern DeviceIntPtr xnestPointerDevice;
|
||||
|
||||
void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl);
|
||||
int xnestPointerProc(DeviceIntPtr pDev, int onoff);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user