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 "Screen.h"
|
||||||
#include "XNWindow.h"
|
#include "XNWindow.h"
|
||||||
#include "Events.h"
|
#include "Events.h"
|
||||||
|
#include "Keyboard.h"
|
||||||
#include "mipointer.h"
|
#include "mipointer.h"
|
||||||
|
|
||||||
CARD32 lastEventTime = 0;
|
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
|
void
|
||||||
xnestCollectEvents()
|
xnestCollectEvents()
|
||||||
{
|
{
|
||||||
|
@ -105,17 +116,13 @@ xnestCollectEvents()
|
||||||
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
|
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
|
||||||
switch (X.type) {
|
switch (X.type) {
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
x.u.u.type = KeyPress;
|
xnestUpdateModifierState(X.xkey.state);
|
||||||
x.u.u.detail = X.xkey.keycode;
|
xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
|
||||||
mieqEnqueue(&x);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
x.u.u.type = KeyRelease;
|
xnestUpdateModifierState(X.xkey.state);
|
||||||
x.u.u.detail = X.xkey.keycode;
|
xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
|
||||||
mieqEnqueue(&x);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
|
|
|
@ -26,5 +26,6 @@ extern CARD32 lastEventTime;
|
||||||
void SetTimeSinceLastInputEvent(void);
|
void SetTimeSinceLastInputEvent(void);
|
||||||
void xnestCollectExposures(void);
|
void xnestCollectExposures(void);
|
||||||
void xnestCollectEvents(void);
|
void xnestCollectEvents(void);
|
||||||
|
void xnestQueueKeyEvent(int type, unsigned int keycode);
|
||||||
|
|
||||||
#endif /* XNESTEVENTS_H */
|
#endif /* XNESTEVENTS_H */
|
||||||
|
|
|
@ -87,15 +87,13 @@ InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
|
||||||
void
|
void
|
||||||
InitInput(int argc, char *argv[])
|
InitInput(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
pointer ptr, kbd;
|
xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
|
||||||
|
xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, TRUE);
|
||||||
|
|
||||||
ptr = AddInputDevice(xnestPointerProc, TRUE);
|
RegisterPointerDevice(xnestPointerDevice);
|
||||||
kbd = AddInputDevice(xnestKeyboardProc, TRUE);
|
RegisterKeyboardDevice(xnestKeyboardDevice);
|
||||||
|
|
||||||
RegisterPointerDevice(ptr);
|
mieqInit((DevicePtr)xnestKeyboardDevice, (DevicePtr)xnestPointerDevice);
|
||||||
RegisterKeyboardDevice(kbd);
|
|
||||||
|
|
||||||
mieqInit(kbd, ptr);
|
|
||||||
|
|
||||||
AddEnabledDevice(XConnectionNumber(xnestDisplay));
|
AddEnabledDevice(XConnectionNumber(xnestDisplay));
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ is" without express or implied warranty.
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
#include "Args.h"
|
#include "Args.h"
|
||||||
|
#include "Events.h"
|
||||||
|
|
||||||
#ifdef XKB
|
#ifdef XKB
|
||||||
#include <X11/extensions/XKB.h>
|
#include <X11/extensions/XKB.h>
|
||||||
|
@ -83,6 +84,8 @@ extern Status XkbGetControls(
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DeviceIntPtr xnestKeyboardDevice = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
|
xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
|
||||||
{
|
{
|
||||||
|
@ -282,3 +285,49 @@ LegalModifier(unsigned int key, DevicePtr pDev)
|
||||||
{
|
{
|
||||||
return TRUE;
|
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 \
|
#define XNEST_KEYBOARD_EVENT_MASK \
|
||||||
(KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask)
|
(KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask)
|
||||||
|
|
||||||
|
extern DeviceIntPtr xnestKeyboardDevice;
|
||||||
|
|
||||||
void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls);
|
void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls);
|
||||||
void xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl);
|
void xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl);
|
||||||
int xnestKeyboardProc(DeviceIntPtr pDev, int onoff);
|
int xnestKeyboardProc(DeviceIntPtr pDev, int onoff);
|
||||||
|
void xnestUpdateModifierState(unsigned int state);
|
||||||
|
|
||||||
#endif /* XNESTKEYBOARD_H */
|
#endif /* XNESTKEYBOARD_H */
|
||||||
|
|
|
@ -31,6 +31,8 @@ is" without express or implied warranty.
|
||||||
#include "Pointer.h"
|
#include "Pointer.h"
|
||||||
#include "Args.h"
|
#include "Args.h"
|
||||||
|
|
||||||
|
DeviceIntPtr xnestPointerDevice = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
|
xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,8 @@ is" without express or implied warranty.
|
||||||
(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | \
|
(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | \
|
||||||
EnterWindowMask | LeaveWindowMask)
|
EnterWindowMask | LeaveWindowMask)
|
||||||
|
|
||||||
|
extern DeviceIntPtr xnestPointerDevice;
|
||||||
|
|
||||||
void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl);
|
void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl);
|
||||||
int xnestPointerProc(DeviceIntPtr pDev, int onoff);
|
int xnestPointerProc(DeviceIntPtr pDev, int onoff);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue