xkb: when faking mouse button events, fake them on the correct devices.
When MouseKeys are activated, keyboard devices may generate fake mouse button events through XKB. Let's get then running through the appropriate paths, i.e. as XI events on the correct device. To make matters more fun, ProcessOtherEvents drops events if the DIX device state cannot be updated accordingly, i.e. all button events from keyboard devices. Hence we need to get the paired MD for the device in XkbDDXFakeDeviceButton, and post the event through the paired MD (usually the VCP). Removes now-unused ddxFakeBtn.c. Note: this patch only half-arsedly fixed button events, motion events are a more complicated matter.
This commit is contained in:
parent
4971315296
commit
cbc6f98395
|
@ -274,7 +274,7 @@ ChangeDeviceID(DeviceIntPtr dev, xEvent* event)
|
||||||
* @param master The event after being copied
|
* @param master The event after being copied
|
||||||
* @param count Number of events in original.
|
* @param count Number of events in original.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
|
CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
|
||||||
xEvent** master, int count)
|
xEvent** master, int count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@ AM_CFLAGS = $(DIX_CFLAGS) \
|
||||||
DDX_SRCS = \
|
DDX_SRCS = \
|
||||||
ddxBeep.c \
|
ddxBeep.c \
|
||||||
ddxCtrls.c \
|
ddxCtrls.c \
|
||||||
ddxFakeBtn.c \
|
|
||||||
ddxFakeMtn.c \
|
ddxFakeMtn.c \
|
||||||
ddxInit.c \
|
ddxInit.c \
|
||||||
ddxKeyClick.c \
|
ddxKeyClick.c \
|
||||||
|
|
|
@ -47,11 +47,13 @@ XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
|
||||||
{
|
{
|
||||||
int * devVal;
|
int * devVal;
|
||||||
INT32 * evVal;
|
INT32 * evVal;
|
||||||
xEvent events[2];
|
xEvent events[2],
|
||||||
|
*m_events = NULL; /* master dev */
|
||||||
deviceKeyButtonPointer *btn;
|
deviceKeyButtonPointer *btn;
|
||||||
deviceValuator * val;
|
deviceValuator * val;
|
||||||
int x,y;
|
int x,y;
|
||||||
int nAxes, i, count;
|
int nAxes, i, count;
|
||||||
|
DeviceIntPtr master = NULL;
|
||||||
|
|
||||||
if (dev == inputInfo.pointer || !dev->public.on)
|
if (dev == inputInfo.pointer || !dev->public.on)
|
||||||
return;
|
return;
|
||||||
|
@ -95,6 +97,28 @@ int nAxes, i, count;
|
||||||
count= 1+((nAxes+5)/6);
|
count= 1+((nAxes+5)/6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XXX: This is obnoxious. ProcessOtherEvent updates the DIX device state,
|
||||||
|
* but may not do anything if the device state is invalid. This happens if
|
||||||
|
* we post a mouse event from a pure keyboard device. So we need to hack
|
||||||
|
* around that by getting the master, then posting the event for the
|
||||||
|
* pointer paired with the master.
|
||||||
|
*
|
||||||
|
* Note:the DeviceButtonEvent on the SD itself will do nothing in most
|
||||||
|
* cases, unless dev is both a keyboard and a mouse.
|
||||||
|
*/
|
||||||
|
if (!dev->isMaster && dev->u.master) {
|
||||||
|
master = dev->u.master;
|
||||||
|
if (!IsPointerDevice(master))
|
||||||
|
master = GetPairedDevice(dev->u.master);
|
||||||
|
|
||||||
|
CopyGetMasterEvent(master, &events, &m_events, count);
|
||||||
|
}
|
||||||
|
|
||||||
(*dev->public.processInputProc)((xEventPtr)btn, dev, count);
|
(*dev->public.processInputProc)((xEventPtr)btn, dev, count);
|
||||||
|
|
||||||
|
if (master) {
|
||||||
|
(*master->public.processInputProc)(m_events, master, count);
|
||||||
|
xfree(m_events);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
/************************************************************
|
|
||||||
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this
|
|
||||||
software and its documentation for any purpose and without
|
|
||||||
fee is hereby granted, provided that the above copyright
|
|
||||||
notice appear in all copies and that both that copyright
|
|
||||||
notice and this permission notice appear in supporting
|
|
||||||
documentation, and that the name of Silicon Graphics not be
|
|
||||||
used in advertising or publicity pertaining to distribution
|
|
||||||
of the software without specific prior written permission.
|
|
||||||
Silicon Graphics makes no representation about the suitability
|
|
||||||
of this software for any purpose. It is provided "as is"
|
|
||||||
without any express or implied warranty.
|
|
||||||
|
|
||||||
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
||||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
|
||||||
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
|
||||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
||||||
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
||||||
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
||||||
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
********************************************************/
|
|
||||||
|
|
||||||
#ifdef HAVE_DIX_CONFIG_H
|
|
||||||
#include <dix-config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#define NEED_EVENTS 1
|
|
||||||
#include <X11/X.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include "inputstr.h"
|
|
||||||
#include "scrnintstr.h"
|
|
||||||
#include "windowstr.h"
|
|
||||||
#include <xkbsrv.h>
|
|
||||||
#include <X11/extensions/XI.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
XkbDDXFakePointerButton(int event,int button)
|
|
||||||
{
|
|
||||||
xEvent ev;
|
|
||||||
int x,y;
|
|
||||||
DevicePtr ptr;
|
|
||||||
|
|
||||||
if ((ptr = (DevicePtr)inputInfo.pointer)==NULL)
|
|
||||||
return;
|
|
||||||
GetSpritePosition(inputInfo.pointer, &x,&y);
|
|
||||||
ev.u.u.type = event;
|
|
||||||
ev.u.u.detail = button;
|
|
||||||
ev.u.keyButtonPointer.time = GetTimeInMillis();
|
|
||||||
ev.u.keyButtonPointer.rootX = x;
|
|
||||||
ev.u.keyButtonPointer.rootY = y;
|
|
||||||
(*ptr->processInputProc)( &ev, (DeviceIntPtr)ptr, 1 );
|
|
||||||
return;
|
|
||||||
}
|
|
|
@ -595,9 +595,6 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
|
||||||
unsigned keycode,
|
unsigned keycode,
|
||||||
XkbAction * pAction)
|
XkbAction * pAction)
|
||||||
{
|
{
|
||||||
if (xkbi->device == inputInfo.keyboard)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (filter->keycode==0) { /* initial press */
|
if (filter->keycode==0) { /* initial press */
|
||||||
int button= pAction->btn.button;
|
int button= pAction->btn.button;
|
||||||
|
|
||||||
|
@ -617,7 +614,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
|
||||||
((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
|
((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
|
||||||
xkbi->lockedPtrButtons|= (1<<button);
|
xkbi->lockedPtrButtons|= (1<<button);
|
||||||
AccessXCancelRepeatKey(xkbi,keycode);
|
AccessXCancelRepeatKey(xkbi,keycode);
|
||||||
XkbDDXFakePointerButton(ButtonPress,button);
|
XkbDDXFakeDeviceButton(xkbi->device, 1, button);
|
||||||
filter->upAction.type= XkbSA_NoAction;
|
filter->upAction.type= XkbSA_NoAction;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -628,12 +625,12 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
|
||||||
if (pAction->btn.count>0) {
|
if (pAction->btn.count>0) {
|
||||||
nClicks= pAction->btn.count;
|
nClicks= pAction->btn.count;
|
||||||
for (i=0;i<nClicks;i++) {
|
for (i=0;i<nClicks;i++) {
|
||||||
XkbDDXFakePointerButton(ButtonPress,button);
|
XkbDDXFakeDeviceButton(xkbi->device, 1, button);
|
||||||
XkbDDXFakePointerButton(ButtonRelease,button);
|
XkbDDXFakeDeviceButton(xkbi->device, 0, button);
|
||||||
}
|
}
|
||||||
filter->upAction.type= XkbSA_NoAction;
|
filter->upAction.type= XkbSA_NoAction;
|
||||||
}
|
}
|
||||||
else XkbDDXFakePointerButton(ButtonPress,button);
|
else XkbDDXFakeDeviceButton(xkbi->device, 1, button);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XkbSA_SetPtrDflt:
|
case XkbSA_SetPtrDflt:
|
||||||
|
@ -689,7 +686,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
|
||||||
}
|
}
|
||||||
xkbi->lockedPtrButtons&= ~(1<<button);
|
xkbi->lockedPtrButtons&= ~(1<<button);
|
||||||
case XkbSA_PtrBtn:
|
case XkbSA_PtrBtn:
|
||||||
XkbDDXFakePointerButton(ButtonRelease,button);
|
XkbDDXFakeDeviceButton(xkbi->device, 0, button);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
filter->active = 0;
|
filter->active = 0;
|
||||||
|
|
|
@ -870,7 +870,7 @@ XkbSrvInfoPtr xkbi;
|
||||||
* Faking a release of the button here solves the problem.
|
* Faking a release of the button here solves the problem.
|
||||||
*/
|
*/
|
||||||
DebugF("[xkb] Faking release of button %d\n", xE[0].u.u.detail);
|
DebugF("[xkb] Faking release of button %d\n", xE[0].u.u.detail);
|
||||||
XkbDDXFakePointerButton(ButtonRelease, xE[0].u.u.detail);
|
XkbDDXFakeDeviceButton(xkbi->device, 0, xE[0].u.u.detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -923,12 +923,12 @@ XkbSrvInfoPtr xkbi;
|
||||||
((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
|
((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
|
||||||
(xkbi->lockedPtrButtons & button_mask) == button_mask) {
|
(xkbi->lockedPtrButtons & button_mask) == button_mask) {
|
||||||
DebugF("[xkb] Faking release of button %d\n", xE[i].u.u.detail);
|
DebugF("[xkb] Faking release of button %d\n", xE[i].u.u.detail);
|
||||||
XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail);
|
XkbDDXFakeDeviceButton(xkbi->device, 0, xE[i].u.u.detail);
|
||||||
} else if (type == DeviceButtonPress &&
|
} else if (type == DeviceButtonPress &&
|
||||||
((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
|
((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
|
||||||
(xkbi->lockedPtrButtons & button_mask) == button_mask) {
|
(xkbi->lockedPtrButtons & button_mask) == button_mask) {
|
||||||
DebugF("[xkb] Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
|
DebugF("[xkb] Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
|
||||||
XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state);
|
XkbDDXFakeDeviceButton(xkbi->device, 0, ((deviceKeyButtonPointer*)&xE[i])->state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue