From cbc6f983959595aa21c9dd72fac6a7070a650ef7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 31 Oct 2008 14:36:48 +1030 Subject: 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. --- xkb/Makefile.am | 1 - xkb/ddxDevBtn.c | 26 ++++++++++++++++++++++++- xkb/ddxFakeBtn.c | 59 -------------------------------------------------------- xkb/xkbActions.c | 13 +++++-------- xkb/xkbEvents.c | 6 +++--- 5 files changed, 33 insertions(+), 72 deletions(-) delete mode 100644 xkb/ddxFakeBtn.c (limited to 'xkb') diff --git a/xkb/Makefile.am b/xkb/Makefile.am index 5b594c130..5967f42ff 100644 --- a/xkb/Makefile.am +++ b/xkb/Makefile.am @@ -6,7 +6,6 @@ AM_CFLAGS = $(DIX_CFLAGS) \ DDX_SRCS = \ ddxBeep.c \ ddxCtrls.c \ - ddxFakeBtn.c \ ddxFakeMtn.c \ ddxInit.c \ ddxKeyClick.c \ diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c index e812e0be6..b68a28b2a 100644 --- a/xkb/ddxDevBtn.c +++ b/xkb/ddxDevBtn.c @@ -47,11 +47,13 @@ XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button) { int * devVal; INT32 * evVal; -xEvent events[2]; +xEvent events[2], + *m_events = NULL; /* master dev */ deviceKeyButtonPointer *btn; deviceValuator * val; int x,y; int nAxes, i, count; +DeviceIntPtr master = NULL; if (dev == inputInfo.pointer || !dev->public.on) return; @@ -95,6 +97,28 @@ int nAxes, i, count; 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); + + if (master) { + (*master->public.processInputProc)(m_events, master, count); + xfree(m_events); + } return; } diff --git a/xkb/ddxFakeBtn.c b/xkb/ddxFakeBtn.c deleted file mode 100644 index f9dcbf79d..000000000 --- a/xkb/ddxFakeBtn.c +++ /dev/null @@ -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 -#endif - -#include -#define NEED_EVENTS 1 -#include -#include -#include -#include "inputstr.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include -#include - -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; -} diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 35938a960..94420cf68 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -595,9 +595,6 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { - if (xkbi->device == inputInfo.keyboard) - return 0; - if (filter->keycode==0) { /* initial press */ int button= pAction->btn.button; @@ -617,7 +614,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, ((pAction->btn.flags&XkbSA_LockNoLock)==0)) { xkbi->lockedPtrButtons|= (1<device, 1, button); filter->upAction.type= XkbSA_NoAction; } break; @@ -628,12 +625,12 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, if (pAction->btn.count>0) { nClicks= pAction->btn.count; for (i=0;idevice, 1, button); + XkbDDXFakeDeviceButton(xkbi->device, 0, button); } filter->upAction.type= XkbSA_NoAction; } - else XkbDDXFakePointerButton(ButtonPress,button); + else XkbDDXFakeDeviceButton(xkbi->device, 1, button); } break; case XkbSA_SetPtrDflt: @@ -689,7 +686,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, } xkbi->lockedPtrButtons&= ~(1<device, 0, button); break; } filter->active = 0; diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 047efcdfb..335620baa 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -870,7 +870,7 @@ XkbSrvInfoPtr xkbi; * Faking a release of the button here solves the problem. */ 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 { @@ -923,12 +923,12 @@ XkbSrvInfoPtr xkbi; ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && (xkbi->lockedPtrButtons & button_mask) == button_mask) { 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 && ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask && (xkbi->lockedPtrButtons & button_mask) == button_mask) { 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); } } } -- cgit v1.2.3