xserver: Branch 'mpx' - 4 commits
Peter Hutterer
whot at kemper.freedesktop.org
Thu Feb 15 05:25:41 EET 2007
dix/events.c | 94 +++++++++++++++++++++--------------------
dix/getevents.c | 57 +++++++++++++-----------
hw/xfree86/common/xf86Xinput.c | 17 ++++++-
include/dix.h | 8 +++
mi/mipointer.c | 21 +++++++++
5 files changed, 125 insertions(+), 72 deletions(-)
New commits:
diff-tree f6c3b9fa97ccf85e96f15435d564a1c261e40532 (from 25104ed2e6050f86691104b34eeaf3147eb83c4a)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Thu Feb 15 13:51:20 2007 +1030
xfree86: mouse and keyboard hotplugging support. New mouse devices will get
new cursors, keyboard devices use VCP's focus until paired.
diff --git a/dix/events.c b/dix/events.c
index a931e41..57a356d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2043,7 +2043,7 @@ XYToWindow(int x, int y)
return spriteTrace[spriteTraceGood-1];
}
-static Bool
+Bool
CheckMotion(xEvent *xE, DeviceIntPtr pDev)
{
WindowPtr prevSpriteWin;
@@ -2190,61 +2190,65 @@ void ReinitializeRootWindow(WindowPtr wi
void
DefineInitialRootWindow(register WindowPtr win)
{
- register ScreenPtr pScreen = win->drawable.pScreen;
- SpritePtr pSprite;
DeviceIntPtr pDev = inputInfo.devices;
+#ifdef XEVIE
+ xeviewin = win;
+#endif
+ ROOT = win;
+
while (pDev)
{
if (DevHasCursor(pDev))
- {
- pSprite = pDev->pSprite;
+ InitializeSprite(pDev, win);
+ pDev = pDev->next;
+ }
+}
- pSprite->hotPhys.pScreen = pScreen;
- pSprite->hotPhys.x = pScreen->width / 2;
- pSprite->hotPhys.y = pScreen->height / 2;
- pSprite->hot = pSprite->hotPhys;
- pSprite->hotLimits.x2 = pScreen->width;
- pSprite->hotLimits.y2 = pScreen->height;
-#ifdef XEVIE
- xeviewin =
-#endif
- pSprite->win = win;
- pSprite->current = wCursor (win);
- pSprite->current->refcnt++;
- spriteTraceGood = 1;
- ROOT = win;
- (*pScreen->CursorLimits) ( pDev, pScreen, pSprite->current,
- &pSprite->hotLimits, &pSprite->physLimits);
- pSprite->confined = FALSE;
-
- (*pScreen->ConstrainCursor) (pDev, pScreen,
- &pSprite->physLimits);
- (*pScreen->SetCursorPosition) (pDev, pScreen, pSprite->hot.x,
- pSprite->hot.y,
- FALSE);
- (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current);
+void
+InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
+{
+ SpritePtr pSprite;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ pSprite = pDev->pSprite;
+ pSprite->hotPhys.pScreen = pScreen;
+ pSprite->hotPhys.x = pScreen->width / 2;
+ pSprite->hotPhys.y = pScreen->height / 2;
+ pSprite->hot = pSprite->hotPhys;
+ pSprite->hotLimits.x2 = pScreen->width;
+ pSprite->hotLimits.y2 = pScreen->height;
+ pSprite->win = pWin;
+ pSprite->current = wCursor (pWin);
+ pSprite->current->refcnt++;
+
+ (*pScreen->CursorLimits) ( pDev, pScreen, pSprite->current,
+ &pSprite->hotLimits, &pSprite->physLimits);
+ pSprite->confined = FALSE;
+
+ (*pScreen->ConstrainCursor) (pDev, pScreen,
+ &pSprite->physLimits);
+ (*pScreen->SetCursorPosition) (pDev, pScreen, pSprite->hot.x,
+ pSprite->hot.y,
+ FALSE);
+ (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current);
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
- pSprite->hotLimits.x1 = -panoramiXdataPtr[0].x;
- pSprite->hotLimits.y1 = -panoramiXdataPtr[0].y;
- pSprite->hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x;
- pSprite->hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
- pSprite->physLimits = pSprite->hotLimits;
- pSprite->confineWin = NullWindow;
+ if(!noPanoramiXExtension) {
+ pSprite->hotLimits.x1 = -panoramiXdataPtr[0].x;
+ pSprite->hotLimits.y1 = -panoramiXdataPtr[0].y;
+ pSprite->hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x;
+ pSprite->hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+ pSprite->physLimits = pSprite->hotLimits;
+ pSprite->confineWin = NullWindow;
#ifdef SHAPE
- pSprite->hotShape = NullRegion;
+ pSprite->hotShape = NullRegion;
#endif
- pSprite->screen = pScreen;
- /* gotta UNINIT these someplace */
- REGION_NULL(pScreen, &pSprite->Reg1);
- REGION_NULL(pScreen, &pSprite->Reg2);
- }
-#endif
- }
- pDev = pDev->next;
+ pSprite->screen = pScreen;
+ /* gotta UNINIT these someplace */
+ REGION_NULL(pScreen, &pSprite->Reg1);
+ REGION_NULL(pScreen, &pSprite->Reg2);
}
+#endif
}
/*
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 6218b35..c2ea108 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -129,7 +129,6 @@ xf86ProcessCommonOptions(LocalDevicePtr
xf86SetBoolOption(list, "CorePointer", 0) ||
xf86SetBoolOption(list, "CoreKeyboard", 0)) {
local->flags |= XI86_ALWAYS_CORE;
- local->flags |= XI86_SHARED_POINTER;
xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
}
@@ -378,6 +377,16 @@ NewInputDeviceRequest (InputOption *opti
}
}
+ if (!drv) {
+ xf86Msg(X_ERROR, "No input driver specified (ignoring)\n");
+ return BadMatch;
+ }
+
+ if (!idev->identifier) {
+ xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
+ return BadMatch;
+ }
+
if (!drv->PreInit) {
xf86Msg(X_ERROR,
"Input driver `%s' has no PreInit function (ignoring)\n",
@@ -407,10 +416,14 @@ NewInputDeviceRequest (InputOption *opti
xf86ActivateDevice(pInfo);
dev = pInfo->dev;
- dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+ ActivateDevice(dev);
if (dev->inited && dev->startup)
EnableDevice(dev);
+ /* send enter/leave event, update sprite window */
+ InitializeSprite(dev, GetCurrentRootWindow());
+ CheckMotion(NULL, dev);
+
return Success;
}
diff --git a/include/dix.h b/include/dix.h
index 8e34211..1c6b163 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -494,6 +494,10 @@ extern int DeliverDeviceEvents(
extern void DefineInitialRootWindow(
WindowPtr /* win */);
+extern void InitializeSprite(
+ DeviceIntPtr /* pDev */,
+ WindowPtr /* pWin */);
+
extern void WindowHasNewCursor(
WindowPtr /* pWin */);
@@ -578,6 +582,10 @@ extern int DeliverEvents(
int /*count*/,
WindowPtr /*otherParent*/);
+extern Bool
+CheckMotion(
+ xEvent* /* xE */,
+ DeviceIntPtr /* pDev */);
extern void WriteEventsToClient(
ClientPtr /*pClient*/,
diff-tree 25104ed2e6050f86691104b34eeaf3147eb83c4a (from 33ef546b942977bb2573156eaba5269350d16f99)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Wed Feb 14 11:26:53 2007 +1030
dix: fix typo in condition.
diff --git a/dix/getevents.c b/dix/getevents.c
index ccaa232..a8d9ec3 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -515,7 +515,7 @@ GetPointerEvents(xEvent *events, DeviceI
}
/* Do we need to send a DeviceValuator event? */
- if (!coreOnly & sendValuators) {
+ if (!coreOnly && sendValuators) {
if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
num_valuators = MAX_VALUATOR_EVENTS * 6;
num_events += ((num_valuators - 1) / 6) + 1;
diff-tree 33ef546b942977bb2573156eaba5269350d16f99 (from 7cd73b00a29469d37a7f526cc9b35cc927a13ae2)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Wed Feb 14 11:18:43 2007 +1030
dix: Clean up GetPointerEvents. If pDev == inputInfo.pointer, assume that
we do not want Xi events.
mi: Remove POINTER_CORE_ONLY flag.
diff --git a/dix/getevents.c b/dix/getevents.c
index f9e6962..ccaa232 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -482,8 +482,6 @@ GetKeyboardValuatorEvents(xEvent *events
* The DDX is responsible for allocating the event structure in the first
* place via GetMaximumEventsNum(), and for freeing it.
*
- * If flag has POINTER_CORE_ONLY set, no XI or valuator event will be
- * generated.
*/
_X_EXPORT int
GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
@@ -497,7 +495,8 @@ GetPointerEvents(xEvent *events, DeviceI
Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
DeviceIntPtr pointer = NULL;
int x = 0, y = 0;
- Bool coreOnly = (flags & POINTER_CORE_ONLY);
+ /* The core pointer must not send Xi events. */
+ Bool coreOnly = (pDev == inputInfo.pointer);
/* Sanity checks. */
if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
@@ -530,10 +529,6 @@ GetPointerEvents(xEvent *events, DeviceI
ms = GetTimeInMillis();
- kbp = (deviceKeyButtonPointer *) events;
- kbp->time = ms;
- kbp->deviceid = pDev->id;
-
if (!pDev->coreEvents || pDev->isMPDev)
pointer = pDev;
else
@@ -598,22 +593,27 @@ GetPointerEvents(xEvent *events, DeviceI
pDev->valuator->lastx = x;
pDev->valuator->lasty = y;
- if (type == MotionNotify) {
- kbp->type = DeviceMotionNotify;
- }
- else {
- if (type == ButtonPress)
- kbp->type = DeviceButtonPress;
- else if (type == ButtonRelease)
- kbp->type = DeviceButtonRelease;
- kbp->detail = pDev->button->map[buttons];
- }
-
- kbp->root_x = x;
- kbp->root_y = y;
-
+ /* create Xi event */
if (!coreOnly)
{
+ kbp = (deviceKeyButtonPointer *) events;
+ kbp->time = ms;
+ kbp->deviceid = pDev->id;
+
+ if (type == MotionNotify) {
+ kbp->type = DeviceMotionNotify;
+ }
+ else {
+ if (type == ButtonPress)
+ kbp->type = DeviceButtonPress;
+ else if (type == ButtonRelease)
+ kbp->type = DeviceButtonRelease;
+ kbp->detail = pDev->button->map[buttons];
+ }
+
+ kbp->root_x = x;
+ kbp->root_y = y;
+
events++;
if (sendValuators) {
kbp->deviceid |= MORE_EVENTS;
diff --git a/include/input.h b/include/input.h
index f7d12cb..96a28a5 100644
--- a/include/input.h
+++ b/include/input.h
@@ -62,7 +62,6 @@ SOFTWARE.
#define POINTER_RELATIVE (1 << 1)
#define POINTER_ABSOLUTE (1 << 2)
#define POINTER_ACCELERATE (1 << 3)
-#define POINTER_CORE_ONLY (1 << 4) /* do not generate XI event */
#define MAP_LENGTH 256
#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 432333d..ed82fcd 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -543,7 +543,6 @@ miPointerMoved (DeviceIntPtr pDev, Scree
xEvent* events;
int i, nevents;
int valuators[2];
- int flags;
miPointerPtr pPointer = MIPOINTER(pDev);
SetupScreen(pScreen);
@@ -571,15 +570,8 @@ miPointerMoved (DeviceIntPtr pDev, Scree
return;
}
- flags = POINTER_ABSOLUTE;
-
- /* If called from ProcWarpCursor, pDev is the VCP and we must not generate
- an XI event. */
- if (pDev == inputInfo.pointer)
- flags |= POINTER_CORE_ONLY;
-
nevents = GetPointerEvents(events, pDev, MotionNotify, 0,
- flags, 0, 2, valuators);
+ POINTER_ABSOLUTE, 0, 2, valuators);
for (i = 0; i < nevents; i++)
mieqEnqueue(pDev, &events[i]);
diff-tree 7cd73b00a29469d37a7f526cc9b35cc927a13ae2 (from a309c936bb79e2fea04a96ce33c7da99ed902484)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Mon Feb 5 14:48:48 2007 +1030
dix: If POINTER_CORE_ONLY is set, GetPointerEvents() only creates a core event
mi: fix: Create motion event in miPointerMoved
diff --git a/dix/getevents.c b/dix/getevents.c
index 8eaacf1..f9e6962 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -481,6 +481,9 @@ GetKeyboardValuatorEvents(xEvent *events
* events is not NULL-terminated; the return value is the number of events.
* The DDX is responsible for allocating the event structure in the first
* place via GetMaximumEventsNum(), and for freeing it.
+ *
+ * If flag has POINTER_CORE_ONLY set, no XI or valuator event will be
+ * generated.
*/
_X_EXPORT int
GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
@@ -494,6 +497,7 @@ GetPointerEvents(xEvent *events, DeviceI
Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
DeviceIntPtr pointer = NULL;
int x = 0, y = 0;
+ Bool coreOnly = (flags & POINTER_CORE_ONLY);
/* Sanity checks. */
if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
@@ -502,7 +506,7 @@ GetPointerEvents(xEvent *events, DeviceI
if ((type == ButtonPress || type == ButtonRelease) && !pDev->button)
return 0;
- if (pDev->coreEvents || pDev->isMPDev)
+ if (!coreOnly && (pDev->coreEvents || pDev->isMPDev))
num_events = 2;
else
num_events = 1;
@@ -512,7 +516,7 @@ GetPointerEvents(xEvent *events, DeviceI
}
/* Do we need to send a DeviceValuator event? */
- if (sendValuators) {
+ if (!coreOnly & sendValuators) {
if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
num_valuators = MAX_VALUATOR_EVENTS * 6;
num_events += ((num_valuators - 1) / 6) + 1;
@@ -608,16 +612,19 @@ GetPointerEvents(xEvent *events, DeviceI
kbp->root_x = x;
kbp->root_y = y;
- events++;
- if (sendValuators) {
- kbp->deviceid |= MORE_EVENTS;
- clipValuators(pDev, first_valuator, num_valuators, valuators);
- events = getValuatorEvents(events, pDev, first_valuator,
- num_valuators, valuators);
+ if (!coreOnly)
+ {
+ events++;
+ if (sendValuators) {
+ kbp->deviceid |= MORE_EVENTS;
+ clipValuators(pDev, first_valuator, num_valuators, valuators);
+ events = getValuatorEvents(events, pDev, first_valuator,
+ num_valuators, valuators);
+ }
}
/* MPX devices always send core events */
- if (pDev->coreEvents || pDev->isMPDev) {
+ if (coreOnly || pDev->coreEvents || pDev->isMPDev) {
events->u.u.type = type;
events->u.keyButtonPointer.time = ms;
events->u.keyButtonPointer.rootX = x;
diff --git a/include/input.h b/include/input.h
index 96a28a5..f7d12cb 100644
--- a/include/input.h
+++ b/include/input.h
@@ -62,6 +62,7 @@ SOFTWARE.
#define POINTER_RELATIVE (1 << 1)
#define POINTER_ABSOLUTE (1 << 2)
#define POINTER_ACCELERATE (1 << 3)
+#define POINTER_CORE_ONLY (1 << 4) /* do not generate XI event */
#define MAP_LENGTH 256
#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 1474cb9..432333d 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -540,6 +540,10 @@ void
miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
unsigned long time)
{
+ xEvent* events;
+ int i, nevents;
+ int valuators[2];
+ int flags;
miPointerPtr pPointer = MIPOINTER(pDev);
SetupScreen(pScreen);
@@ -556,4 +560,29 @@ miPointerMoved (DeviceIntPtr pDev, Scree
pPointer->x = x;
pPointer->y = y;
pPointer->pScreen = pScreen;
+
+ /* generate event here */
+ valuators[0] = x;
+ valuators[1] = y;
+ events = (xEvent*)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ if (!events)
+ {
+ FatalError("Could not allocate event store.\n");
+ return;
+ }
+
+ flags = POINTER_ABSOLUTE;
+
+ /* If called from ProcWarpCursor, pDev is the VCP and we must not generate
+ an XI event. */
+ if (pDev == inputInfo.pointer)
+ flags |= POINTER_CORE_ONLY;
+
+ nevents = GetPointerEvents(events, pDev, MotionNotify, 0,
+ flags, 0, 2, valuators);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(pDev, &events[i]);
+
+ xfree(events);
}
More information about the xorg-commit
mailing list