aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xi/exevents.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/Xi/exevents.c
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/Xi/exevents.c')
-rw-r--r--xorg-server/Xi/exevents.c1799
1 files changed, 884 insertions, 915 deletions
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index f390f6739..ff2224094 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -95,12 +95,12 @@ SOFTWARE.
#include "exevents.h"
#include "extnsionst.h"
#include "exglobals.h"
-#include "dixevents.h" /* DeliverFocusedEvent */
-#include "dixgrabs.h" /* CreateGrab() */
+#include "dixevents.h" /* DeliverFocusedEvent */
+#include "dixgrabs.h" /* CreateGrab() */
#include "scrnintstr.h"
-#include "listdev.h" /* for CopySwapXXXClass */
+#include "listdev.h" /* for CopySwapXXXClass */
#include "xace.h"
-#include "xiquerydevice.h" /* For List*Info */
+#include "xiquerydevice.h" /* For List*Info */
#include "eventconvert.h"
#include "eventstr.h"
#include "inpututils.h"
@@ -117,9 +117,9 @@ SOFTWARE.
Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
Bool ShouldFreeInputMasks(WindowPtr /* pWin */ ,
- Bool /* ignoreSelectedEvents */
+ Bool /* ignoreSelectedEvents */
);
-static Bool MakeInputMasks(WindowPtr /* pWin */
+static Bool MakeInputMasks(WindowPtr /* pWin */
);
/*
@@ -140,32 +140,30 @@ XIShouldNotify(ClientPtr client, DeviceIntPtr dev)
}
Bool
-IsPointerEvent(InternalEvent* event)
-{
- switch(event->any.type)
- {
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_Motion:
- /* XXX: enter/leave ?? */
- return TRUE;
- default:
- break;
+IsPointerEvent(InternalEvent *event)
+{
+ switch (event->any.type) {
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_Motion:
+ /* XXX: enter/leave ?? */
+ return TRUE;
+ default:
+ break;
}
return FALSE;
}
Bool
-IsTouchEvent(InternalEvent* event)
-{
- switch(event->any.type)
- {
- case ET_TouchBegin:
- case ET_TouchUpdate:
- case ET_TouchEnd:
- return TRUE;
- default:
- break;
+IsTouchEvent(InternalEvent *event)
+{
+ switch (event->any.type) {
+ case ET_TouchBegin:
+ case ET_TouchUpdate:
+ case ET_TouchEnd:
+ return TRUE;
+ default:
+ break;
}
return FALSE;
}
@@ -175,7 +173,7 @@ IsTouchEvent(InternalEvent* event)
* NULL if the event is not an XInput event.
*/
DeviceIntPtr
-XIGetDevice(xEvent* xE)
+XIGetDevice(xEvent *xE)
{
DeviceIntPtr pDev = NULL;
@@ -183,13 +181,11 @@ XIGetDevice(xEvent* xE)
xE->u.u.type == DeviceButtonRelease ||
xE->u.u.type == DeviceMotionNotify ||
xE->u.u.type == ProximityIn ||
- xE->u.u.type == ProximityOut ||
- xE->u.u.type == DevicePropertyNotify)
- {
+ xE->u.u.type == ProximityOut || xE->u.u.type == DevicePropertyNotify) {
int rc;
int id;
- id = ((deviceKeyButtonPointer*)xE)->deviceid & ~MORE_EVENTS;
+ id = ((deviceKeyButtonPointer *) xE)->deviceid & ~MORE_EVENTS;
rc = dixLookupDevice(&pDev, id, serverClient, DixUnknownAccess);
if (rc != Success)
@@ -198,7 +194,6 @@ XIGetDevice(xEvent* xE)
return pDev;
}
-
/**
* Copy the device->key into master->key and send a mapping notify to the
* clients if appropriate.
@@ -235,7 +230,6 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
mk->sourceid = device->id;
-
if (!XkbCopyDeviceKeymap(master, device))
FatalError("Couldn't pivot keymap from device to core!\n");
}
@@ -250,153 +244,136 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
{
ClassesPtr classes;
-
- if (from->intfeed)
- {
+ if (from->intfeed) {
IntegerFeedbackPtr *i, it;
- if (!to->intfeed)
- {
+ if (!to->intfeed) {
classes = to->unused_classes;
to->intfeed = classes->intfeed;
classes->intfeed = NULL;
}
i = &to->intfeed;
- for (it = from->intfeed; it; it = it->next)
- {
- if (!(*i))
- {
+ for (it = from->intfeed; it; it = it->next) {
+ if (!(*i)) {
*i = calloc(1, sizeof(IntegerFeedbackClassRec));
- if (!(*i))
- {
+ if (!(*i)) {
ErrorF("[Xi] Cannot alloc memory for class copy.");
return;
}
}
(*i)->CtrlProc = it->CtrlProc;
- (*i)->ctrl = it->ctrl;
+ (*i)->ctrl = it->ctrl;
i = &(*i)->next;
}
- } else if (to->intfeed && !from->intfeed)
- {
+ }
+ else if (to->intfeed && !from->intfeed) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->intfeed = to->intfeed;
- to->intfeed = NULL;
+ to->intfeed = NULL;
}
- if (from->stringfeed)
- {
+ if (from->stringfeed) {
StringFeedbackPtr *s, it;
- if (!to->stringfeed)
- {
+ if (!to->stringfeed) {
classes = to->unused_classes;
to->stringfeed = classes->stringfeed;
classes->stringfeed = NULL;
}
s = &to->stringfeed;
- for (it = from->stringfeed; it; it = it->next)
- {
- if (!(*s))
- {
+ for (it = from->stringfeed; it; it = it->next) {
+ if (!(*s)) {
*s = calloc(1, sizeof(StringFeedbackClassRec));
- if (!(*s))
- {
+ if (!(*s)) {
ErrorF("[Xi] Cannot alloc memory for class copy.");
return;
}
}
(*s)->CtrlProc = it->CtrlProc;
- (*s)->ctrl = it->ctrl;
+ (*s)->ctrl = it->ctrl;
s = &(*s)->next;
}
- } else if (to->stringfeed && !from->stringfeed)
- {
+ }
+ else if (to->stringfeed && !from->stringfeed) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->stringfeed = to->stringfeed;
- to->stringfeed = NULL;
+ to->stringfeed = NULL;
}
- if (from->bell)
- {
+ if (from->bell) {
BellFeedbackPtr *b, it;
- if (!to->bell)
- {
+ if (!to->bell) {
classes = to->unused_classes;
to->bell = classes->bell;
classes->bell = NULL;
}
b = &to->bell;
- for (it = from->bell; it; it = it->next)
- {
- if (!(*b))
- {
+ for (it = from->bell; it; it = it->next) {
+ if (!(*b)) {
*b = calloc(1, sizeof(BellFeedbackClassRec));
- if (!(*b))
- {
+ if (!(*b)) {
ErrorF("[Xi] Cannot alloc memory for class copy.");
return;
}
}
(*b)->BellProc = it->BellProc;
(*b)->CtrlProc = it->CtrlProc;
- (*b)->ctrl = it->ctrl;
+ (*b)->ctrl = it->ctrl;
b = &(*b)->next;
}
- } else if (to->bell && !from->bell)
- {
+ }
+ else if (to->bell && !from->bell) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->bell = to->bell;
- to->bell = NULL;
+ to->bell = NULL;
}
- if (from->leds)
- {
+ if (from->leds) {
LedFeedbackPtr *l, it;
- if (!to->leds)
- {
+ if (!to->leds) {
classes = to->unused_classes;
to->leds = classes->leds;
classes->leds = NULL;
}
l = &to->leds;
- for (it = from->leds; it; it = it->next)
- {
- if (!(*l))
- {
+ for (it = from->leds; it; it = it->next) {
+ if (!(*l)) {
*l = calloc(1, sizeof(LedFeedbackClassRec));
- if (!(*l))
- {
+ if (!(*l)) {
ErrorF("[Xi] Cannot alloc memory for class copy.");
return;
}
}
(*l)->CtrlProc = it->CtrlProc;
- (*l)->ctrl = it->ctrl;
+ (*l)->ctrl = it->ctrl;
if ((*l)->xkb_sli)
XkbFreeSrvLedInfo((*l)->xkb_sli);
(*l)->xkb_sli = XkbCopySrvLedInfo(from, it->xkb_sli, NULL, *l);
l = &(*l)->next;
}
- } else if (to->leds && !from->leds)
- {
+ }
+ else if (to->leds && !from->leds) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->leds = to->leds;
- to->leds = NULL;
+ to->leds = NULL;
}
}
@@ -408,12 +385,10 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
/* XkbInitDevice (->XkbInitIndicatorMap->XkbFindSrvLedInfo) relies on the
* kbdfeed to be set up properly, so let's do the feedback classes first.
*/
- if (from->kbdfeed)
- {
+ if (from->kbdfeed) {
KbdFeedbackPtr *k, it;
- if (!to->kbdfeed)
- {
+ if (!to->kbdfeed) {
classes = to->unused_classes;
to->kbdfeed = classes->kbdfeed;
@@ -423,38 +398,34 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
}
k = &to->kbdfeed;
- for(it = from->kbdfeed; it; it = it->next)
- {
- if (!(*k))
- {
+ for (it = from->kbdfeed; it; it = it->next) {
+ if (!(*k)) {
*k = calloc(1, sizeof(KbdFeedbackClassRec));
- if (!*k)
- {
+ if (!*k) {
ErrorF("[Xi] Cannot alloc memory for class copy.");
return;
}
}
(*k)->BellProc = it->BellProc;
(*k)->CtrlProc = it->CtrlProc;
- (*k)->ctrl = it->ctrl;
+ (*k)->ctrl = it->ctrl;
if ((*k)->xkb_sli)
XkbFreeSrvLedInfo((*k)->xkb_sli);
(*k)->xkb_sli = XkbCopySrvLedInfo(from, it->xkb_sli, *k, NULL);
k = &(*k)->next;
}
- } else if (to->kbdfeed && !from->kbdfeed)
- {
+ }
+ else if (to->kbdfeed && !from->kbdfeed) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->kbdfeed = to->kbdfeed;
- to->kbdfeed = NULL;
+ to->kbdfeed = NULL;
}
- if (from->key)
- {
- if (!to->key)
- {
+ if (from->key) {
+ if (!to->key) {
classes = to->unused_classes;
to->key = classes->key;
if (!to->key)
@@ -464,28 +435,26 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
}
CopyKeyClass(from, to);
- } else if (to->key && !from->key)
- {
+ }
+ else if (to->key && !from->key) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->key = to->key;
- to->key = NULL;
+ to->key = NULL;
}
/* If a SrvLedInfoPtr's flags are XkbSLI_IsDefault, the names and maps
* pointer point into the xkbInfo->desc struct. XkbCopySrvLedInfo
* didn't update the pointers so we need to do it manually here.
*/
- if (to->kbdfeed)
- {
+ if (to->kbdfeed) {
KbdFeedbackPtr k;
- for (k = to->kbdfeed; k; k = k->next)
- {
+ for (k = to->kbdfeed; k; k = k->next) {
if (!k->xkb_sli)
continue;
- if (k->xkb_sli->flags & XkbSLI_IsDefault)
- {
+ if (k->xkb_sli->flags & XkbSLI_IsDefault) {
k->xkb_sli->names = to->key->xkbInfo->desc->names->indicators;
k->xkb_sli->maps = to->key->xkbInfo->desc->indicators->maps;
}
@@ -498,38 +467,38 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
* So we only copy the focus class if the device didn't have one,
* otherwise we leave it as it is.
*/
- if (from->focus)
- {
- if (!to->focus)
- {
+ if (from->focus) {
+ if (!to->focus) {
WindowPtr *oldTrace;
classes = to->unused_classes;
to->focus = classes->focus;
- if (!to->focus)
- {
+ if (!to->focus) {
to->focus = calloc(1, sizeof(FocusClassRec));
if (!to->focus)
FatalError("[Xi] no memory for class shift.\n");
- } else
+ }
+ else
classes->focus = NULL;
oldTrace = to->focus->trace;
memcpy(to->focus, from->focus, sizeof(FocusClassRec));
to->focus->trace = realloc(oldTrace,
- to->focus->traceSize * sizeof(WindowPtr));
+ to->focus->traceSize *
+ sizeof(WindowPtr));
if (!to->focus->trace && to->focus->traceSize)
FatalError("[Xi] no memory for trace.\n");
memcpy(to->focus->trace, from->focus->trace,
- from->focus->traceSize * sizeof(WindowPtr));
+ from->focus->traceSize * sizeof(WindowPtr));
to->focus->sourceid = from->id;
}
- } else if (to->focus)
- {
+ }
+ else if (to->focus) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->focus = to->focus;
- to->focus = NULL;
+ to->focus = NULL;
}
}
@@ -542,47 +511,42 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
ClassesPtr classes;
/* Feedback classes must be copied first */
- if (from->ptrfeed)
- {
+ if (from->ptrfeed) {
PtrFeedbackPtr *p, it;
- if (!to->ptrfeed)
- {
+
+ if (!to->ptrfeed) {
classes = to->unused_classes;
to->ptrfeed = classes->ptrfeed;
classes->ptrfeed = NULL;
}
p = &to->ptrfeed;
- for (it = from->ptrfeed; it; it = it->next)
- {
- if (!(*p))
- {
+ for (it = from->ptrfeed; it; it = it->next) {
+ if (!(*p)) {
*p = calloc(1, sizeof(PtrFeedbackClassRec));
- if (!*p)
- {
+ if (!*p) {
ErrorF("[Xi] Cannot alloc memory for class copy.");
return;
}
}
(*p)->CtrlProc = it->CtrlProc;
- (*p)->ctrl = it->ctrl;
+ (*p)->ctrl = it->ctrl;
p = &(*p)->next;
}
- } else if (to->ptrfeed && !from->ptrfeed)
- {
+ }
+ else if (to->ptrfeed && !from->ptrfeed) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->ptrfeed = to->ptrfeed;
- to->ptrfeed = NULL;
+ to->ptrfeed = NULL;
}
- if (from->valuator)
- {
+ if (from->valuator) {
ValuatorClassPtr v;
- if (!to->valuator)
- {
+ if (!to->valuator) {
classes = to->unused_classes;
to->valuator = classes->valuator;
if (to->valuator)
@@ -598,87 +562,84 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
memcpy(v->axes, from->valuator->axes, v->numAxes * sizeof(AxisInfo));
v->sourceid = from->id;
- } else if (to->valuator && !from->valuator)
- {
+ }
+ else if (to->valuator && !from->valuator) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->valuator = to->valuator;
- to->valuator = NULL;
+ to->valuator = NULL;
}
- if (from->button)
- {
- if (!to->button)
- {
+ if (from->button) {
+ if (!to->button) {
classes = to->unused_classes;
to->button = classes->button;
- if (!to->button)
- {
+ if (!to->button) {
to->button = calloc(1, sizeof(ButtonClassRec));
if (!to->button)
FatalError("[Xi] no memory for class shift.\n");
- } else
+ }
+ else
classes->button = NULL;
}
- if (from->button->xkb_acts)
- {
- if (!to->button->xkb_acts)
- {
+ if (from->button->xkb_acts) {
+ if (!to->button->xkb_acts) {
to->button->xkb_acts = calloc(1, sizeof(XkbAction));
if (!to->button->xkb_acts)
FatalError("[Xi] not enough memory for xkb_acts.\n");
}
memcpy(to->button->xkb_acts, from->button->xkb_acts,
- sizeof(XkbAction));
- } else
+ sizeof(XkbAction));
+ }
+ else
free(to->button->xkb_acts);
- memcpy(to->button->labels, from->button->labels,
- from->button->numButtons * sizeof(Atom));
+ memcpy(to->button->labels, from->button->labels,
+ from->button->numButtons * sizeof(Atom));
to->button->sourceid = from->id;
- } else if (to->button && !from->button)
- {
+ }
+ else if (to->button && !from->button) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->button = to->button;
- to->button = NULL;
+ to->button = NULL;
}
- if (from->proximity)
- {
- if (!to->proximity)
- {
+ if (from->proximity) {
+ if (!to->proximity) {
classes = to->unused_classes;
to->proximity = classes->proximity;
- if (!to->proximity)
- {
+ if (!to->proximity) {
to->proximity = calloc(1, sizeof(ProximityClassRec));
if (!to->proximity)
FatalError("[Xi] no memory for class shift.\n");
- } else
+ }
+ else
classes->proximity = NULL;
}
memcpy(to->proximity, from->proximity, sizeof(ProximityClassRec));
to->proximity->sourceid = from->id;
- } else if (to->proximity)
- {
+ }
+ else if (to->proximity) {
ClassesPtr classes;
+
classes = to->unused_classes;
classes->proximity = to->proximity;
- to->proximity = NULL;
+ to->proximity = NULL;
}
- if (from->touch)
- {
+ if (from->touch) {
TouchClassPtr t, f;
- if (!to->touch)
- {
+
+ if (!to->touch) {
classes = to->unused_classes;
to->touch = classes->touch;
- if (!to->touch)
- {
+ if (!to->touch) {
int i;
+
to->touch = calloc(1, sizeof(TouchClassRec));
if (!to->touch)
FatalError("[Xi] no memory for class shift.\n");
@@ -689,11 +650,11 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
TouchInitTouchPoint(to->touch, to->valuator, i);
if (!to->touch)
FatalError("[Xi] no memory for class shift.\n");
- } else
+ }
+ else
classes->touch = NULL;
}
-
t = to->touch;
f = from->touch;
t->sourceid = f->sourceid;
@@ -719,7 +680,8 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
* Saves a few memory allocations.
*/
void
-DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dce)
+DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
+ DeviceChangedEvent *dce)
{
/* generic feedback classes, not tied to pointer and/or keyboard */
DeepCopyFeedbackClasses(from, to);
@@ -730,7 +692,6 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dc
DeepCopyPointerClasses(from, to);
}
-
/**
* Send an XI2 DeviceChangedEvent to all interested clients.
*/
@@ -740,16 +701,15 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce)
xXIDeviceChangedEvent *dcce;
int rc;
- rc = EventToXI2((InternalEvent*)dce, (xEvent**)&dcce);
- if (rc != Success)
- {
+ rc = EventToXI2((InternalEvent *) dce, (xEvent **) &dcce);
+ if (rc != Success) {
ErrorF("[Xi] event conversion from DCE failed with code %d\n", rc);
return;
}
/* we don't actually swap if there's a NullClient, swapping is done
* later when event is delivered. */
- SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent*)dcce, 1);
+ SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent *) dcce, 1);
free(dcce);
}
@@ -766,16 +726,16 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
rc = dixLookupDevice(&slave, dce->sourceid, serverClient, DixReadAccess);
if (rc != Success)
- return; /* Device has disappeared */
+ return; /* Device has disappeared */
if (IsMaster(slave))
return;
if (IsFloating(slave))
- return; /* set floating since the event */
+ return; /* set floating since the event */
if (GetMaster(slave, MASTER_ATTACHED)->id != dce->masterid)
- return; /* not our slave anymore, don't care */
+ return; /* not our slave anymore, don't care */
/* FIXME: we probably need to send a DCE for the new slave now */
@@ -846,40 +806,38 @@ DecreaseButtonCount(DeviceIntPtr dev, int key, CARD8 *buttons_down,
#define DEFAULT 0
#define DONT_PROCESS 1
int
-UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
+UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event)
{
int i;
- int key = 0,
- last_valuator;
+ int key = 0, last_valuator;
- KeyClassPtr k = NULL;
- ButtonClassPtr b = NULL;
- ValuatorClassPtr v = NULL;
- TouchClassPtr t = NULL;
+ KeyClassPtr k = NULL;
+ ButtonClassPtr b = NULL;
+ ValuatorClassPtr v = NULL;
+ TouchClassPtr t = NULL;
/* This event is always the first we get, before the actual events with
* the data. However, the way how the DDX is set up, "device" will
* actually be the slave device that caused the event.
*/
- switch(event->type)
- {
- case ET_DeviceChanged:
- ChangeMasterDeviceClasses(device, (DeviceChangedEvent*)event);
- return DONT_PROCESS; /* event has been sent already */
- case ET_Motion:
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_KeyPress:
- case ET_KeyRelease:
- case ET_ProximityIn:
- case ET_ProximityOut:
- case ET_TouchBegin:
- case ET_TouchUpdate:
- case ET_TouchEnd:
- break;
- default:
- /* other events don't update the device */
- return DEFAULT;
+ switch (event->type) {
+ case ET_DeviceChanged:
+ ChangeMasterDeviceClasses(device, (DeviceChangedEvent *) event);
+ return DONT_PROCESS; /* event has been sent already */
+ case ET_Motion:
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_KeyPress:
+ case ET_KeyRelease:
+ case ET_ProximityIn:
+ case ET_ProximityOut:
+ case ET_TouchBegin:
+ case ET_TouchUpdate:
+ case ET_TouchEnd:
+ break;
+ default:
+ /* other events don't update the device */
+ return DEFAULT;
}
k = device->key;
@@ -892,27 +850,23 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
/* Update device axis */
/* Check valuators first */
last_valuator = -1;
- for (i = 0; i < MAX_VALUATORS; i++)
- {
- if (BitIsOn(&event->valuators.mask, i))
- {
- if (!v)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
+ if (BitIsOn(&event->valuators.mask, i)) {
+ if (!v) {
ErrorF("[Xi] Valuators reported for non-valuator device '%s'. "
- "Ignoring event.\n", device->name);
+ "Ignoring event.\n", device->name);
return DONT_PROCESS;
- } else if (v->numAxes < i)
- {
+ }
+ else if (v->numAxes < i) {
ErrorF("[Xi] Too many valuators reported for device '%s'. "
- "Ignoring event.\n", device->name);
+ "Ignoring event.\n", device->name);
return DONT_PROCESS;
}
last_valuator = i;
}
}
- for (i = 0; i <= last_valuator && i < v->numAxes; i++)
- {
+ for (i = 0; i <= last_valuator && i < v->numAxes; i++) {
/* XXX: Relative/Absolute mode */
if (BitIsOn(&event->valuators.mask, i))
v->axisVal[i] = event->valuators.data[i];
@@ -922,23 +876,25 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
if (!k)
return DONT_PROCESS;
- /* don't allow ddx to generate multiple downs, but repeats are okay */
- if (key_is_down(device, key, KEY_PROCESSED) && !event->key_repeat)
- return DONT_PROCESS;
+ /* don't allow ddx to generate multiple downs, but repeats are okay */
+ if (key_is_down(device, key, KEY_PROCESSED) && !event->key_repeat)
+ return DONT_PROCESS;
- if (device->valuator)
- device->valuator->motionHintWindow = NullWindow;
- set_key_down(device, key, KEY_PROCESSED);
- } else if (event->type == ET_KeyRelease) {
+ if (device->valuator)
+ device->valuator->motionHintWindow = NullWindow;
+ set_key_down(device, key, KEY_PROCESSED);
+ }
+ else if (event->type == ET_KeyRelease) {
if (!k)
return DONT_PROCESS;
- if (!key_is_down(device, key, KEY_PROCESSED)) /* guard against duplicates */
- return DONT_PROCESS;
- if (device->valuator)
- device->valuator->motionHintWindow = NullWindow;
- set_key_up(device, key, KEY_PROCESSED);
- } else if (event->type == ET_ButtonPress) {
+ if (!key_is_down(device, key, KEY_PROCESSED)) /* guard against duplicates */
+ return DONT_PROCESS;
+ if (device->valuator)
+ device->valuator->motionHintWindow = NullWindow;
+ set_key_up(device, key, KEY_PROCESSED);
+ }
+ else if (event->type == ET_ButtonPress) {
if (!b)
return DONT_PROCESS;
@@ -950,9 +906,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
if (!b->map[key])
return DONT_PROCESS;
- IncreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state);
+ IncreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask,
+ &b->state);
UpdateDeviceMotionMask(device, b->state, b->motionMask);
- } else if (event->type == ET_ButtonRelease) {
+ }
+ else if (event->type == ET_ButtonRelease) {
if (!b)
return DONT_PROCESS;
@@ -981,12 +939,14 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
if (!b->map[key])
return DONT_PROCESS;
- DecreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state);
- UpdateDeviceMotionMask(device, b->state, b->motionMask);
- } else if (event->type == ET_ProximityIn)
- device->proximity->in_proximity = TRUE;
+ DecreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask,
+ &b->state);
+ UpdateDeviceMotionMask(device, b->state, b->motionMask);
+ }
+ else if (event->type == ET_ProximityIn)
+ device->proximity->in_proximity = TRUE;
else if (event->type == ET_ProximityOut)
- device->proximity->in_proximity = FALSE;
+ device->proximity->in_proximity = FALSE;
else if (event->type == ET_TouchBegin) {
BUG_WARN(!b || !v);
BUG_WARN(!t);
@@ -998,9 +958,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
(event->flags & TOUCH_REPLAYING))
return DONT_PROCESS;
- IncreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, &t->state);
+ IncreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask,
+ &t->state);
UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask);
- } else if (event->type == ET_TouchEnd) {
+ }
+ else if (event->type == ET_TouchEnd) {
BUG_WARN(!b || !v);
BUG_WARN(!t);
@@ -1012,7 +974,8 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
if (!(event->flags & TOUCH_END))
return DONT_PROCESS;
- DecreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, &t->state);
+ DecreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask,
+ &t->state);
UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask);
}
@@ -1027,12 +990,12 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
* window for this device, FALSE otherwise
*/
static inline Bool
-TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev, WindowPtr win)
+TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev,
+ WindowPtr win)
{
InputClients *iclient;
- nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next)
- {
+ nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) {
if (rClient(iclient) != client)
continue;
@@ -1043,7 +1006,8 @@ TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev, WindowPtr wi
}
static void
-TouchSendOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, int reason, XID resource)
+TouchSendOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, int reason,
+ XID resource)
{
int nev, i;
InternalEvent *tel = InitEventList(GetMaximumEventsNum());
@@ -1072,8 +1036,8 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti,
/* If the client does not have the ownership mask set and is not
* the current owner of the touch, only pretend we delivered */
if (!grab && ti->num_grabs != 0 &&
- !TouchClientWantsOwnershipEvents(client, dev,win))
- return TRUE;
+ !TouchClientWantsOwnershipEvents(client, dev, win))
+ return TRUE;
/* If we fail here, we're going to leave a client hanging. */
err = EventToXI2(ev, &xi2);
@@ -1102,8 +1066,7 @@ ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti)
rc = dixLookupClient(&client, ti->listeners[0].listener, serverClient,
DixSendAccess);
- if (rc != Success)
- {
+ if (rc != Success) {
ErrorF("[Xi] Failed to lookup early accepting client.\n");
return;
}
@@ -1158,15 +1121,14 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
/* Deliver the ownership */
if (ti->listeners[0].state == LISTENER_AWAITING_OWNER ||
ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
- DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ti->listeners[0].listener);
+ DeliverTouchEvents(dev, ti, (InternalEvent *) ev,
+ ti->listeners[0].listener);
else if (ti->listeners[0].state == LISTENER_AWAITING_BEGIN)
TouchEventHistoryReplay(ti, dev, ti->listeners[0].listener);
/* If we've just removed the last grab and the touch has physically
* ended, send a TouchEnd event too and finalise the touch. */
- if (ti->num_listeners == 1 && ti->num_grabs == 0 &&
- ti->pending_finish)
- {
+ if (ti->num_listeners == 1 && ti->num_grabs == 0 && ti->pending_finish) {
EmitTouchEnd(dev, ti, 0, 0);
TouchEndTouch(dev, ti);
return;
@@ -1195,10 +1157,8 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
/* Send a TouchEnd event to the resource being removed, but only if they
* haven't received one yet already */
- for (i = 0; i < ti->num_listeners; i++)
- {
- if (ti->listeners[i].listener == resource)
- {
+ for (i = 0; i < ti->num_listeners; i++) {
+ if (ti->listeners[i].listener == resource) {
if (ti->listeners[i].state != LISTENER_HAS_END)
EmitTouchEnd(sourcedev, ti, TOUCH_REJECT, resource);
break;
@@ -1207,16 +1167,14 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
/* If there are no other listeners left, and the touchpoint is pending
* finish, then we can just kill it now. */
- if (ti->num_listeners == 1 && ti->pending_finish)
- {
+ if (ti->num_listeners == 1 && ti->pending_finish) {
TouchEndTouch(sourcedev, ti);
return;
}
/* Remove the resource from the listener list, updating
* ti->num_listeners, as well as ti->num_grabs if it was a grab. */
- if (TouchRemoveListener(ti, resource))
- {
+ if (TouchRemoveListener(ti, resource)) {
if (dixLookupResourceByType(&grab, resource, RT_PASSIVEGRAB,
serverClient, DixGetAttrAccess) == Success)
ti->num_grabs--;
@@ -1252,8 +1210,11 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
/* Owner accepted after receiving end */
if (ti->listeners[0].state == LISTENER_HAS_END)
TouchEndTouch(dev, ti);
- } else { /* this is the very first ownership event for a grab */
- DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ev->resource);
+ else
+ ti->listeners[0].state = LISTENER_HAS_ACCEPTED;
+ }
+ else { /* this is the very first ownership event for a grab */
+ DeliverTouchEvents(dev, ti, (InternalEvent *) ev, ev->resource);
}
}
@@ -1265,6 +1226,7 @@ static void
TouchCopyValuatorData(DeviceEvent *ev, TouchPointInfoPtr ti)
{
int i;
+
for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++)
if (BitIsOn(ev->valuators.mask, i))
valuator_mask_set_double(ti->valuators, i, ev->valuators.data[i]);
@@ -1287,24 +1249,23 @@ TouchCopyValuatorData(DeviceEvent *ev, TouchPointInfoPtr ti)
*/
static Bool
RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
- InternalEvent *ev, TouchListener *listener,
+ InternalEvent *ev, TouchListener * listener,
ClientPtr *client, WindowPtr *win, GrabPtr *grab,
XI2Mask **mask)
{
- int rc;
- InputClients *iclients = NULL;
+ int rc;
+ InputClients *iclients = NULL;
if (listener->type == LISTENER_GRAB ||
- listener->type == LISTENER_POINTER_GRAB)
- {
- rc = dixLookupResourceByType((pointer*)grab, listener->listener,
- RT_PASSIVEGRAB,
- serverClient, DixSendAccess);
- if (rc != Success)
- {
+ listener->type == LISTENER_POINTER_GRAB) {
+ rc = dixLookupResourceByType((pointer *) grab, listener->listener,
+ RT_PASSIVEGRAB,
+ serverClient, DixSendAccess);
+ if (rc != Success) {
/* the grab doesn't exist but we have a grabbing listener - this
* is an implicit/active grab */
- rc = dixLookupClient(client, listener->listener, serverClient, DixSendAccess);
+ rc = dixLookupClient(client, listener->listener, serverClient,
+ DixSendAccess);
if (rc != Success)
return FALSE;
@@ -1316,51 +1277,56 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
*client = rClient(*grab);
*win = (*grab)->window;
*mask = (*grab)->xi2mask;
- } else {
+ }
+ else {
if (listener->level == CORE)
rc = dixLookupWindow(win, listener->listener,
serverClient, DixSendAccess);
else
- rc = dixLookupResourceByType((pointer*)win, listener->listener,
+ rc = dixLookupResourceByType((pointer *) win, listener->listener,
RT_INPUTCLIENT,
serverClient, DixSendAccess);
if (rc != Success)
return FALSE;
-
- if (listener->level == XI2)
- {
+ if (listener->level == XI2) {
int evtype;
- if (ti->emulate_pointer && listener->type == LISTENER_POINTER_REGULAR)
+
+ if (ti->emulate_pointer &&
+ listener->type == LISTENER_POINTER_REGULAR)
evtype = GetXI2Type(TouchGetPointerEventType(ev));
else
evtype = GetXI2Type(ev->any.type);
- nt_list_for_each_entry(iclients, wOtherInputMasks(*win)->inputClients, next)
+ nt_list_for_each_entry(iclients,
+ wOtherInputMasks(*win)->inputClients, next)
if (xi2mask_isset(iclients->xi2mask, dev, evtype))
- break;
+ break;
BUG_WARN(!iclients);
if (!iclients)
return FALSE;
- } else if (listener->level == XI)
- {
+ }
+ else if (listener->level == XI) {
int xi_type = GetXIType(TouchGetPointerEventType(ev));
Mask xi_filter = event_get_filter_from_type(dev, xi_type);
- nt_list_for_each_entry(iclients, wOtherInputMasks(*win)->inputClients, next)
+
+ nt_list_for_each_entry(iclients,
+ wOtherInputMasks(*win)->inputClients, next)
if (iclients->mask[dev->id] & xi_filter)
- break;
+ break;
BUG_WARN(!iclients);
if (!iclients)
return FALSE;
- } else
- {
+ }
+ else {
int coretype = GetCoreType(TouchGetPointerEventType(ev));
Mask core_filter = event_get_filter_from_type(dev, coretype);
/* all others */
- nt_list_for_each_entry(iclients, (InputClients*)wOtherClients(*win), next)
+ nt_list_for_each_entry(iclients,
+ (InputClients *) wOtherClients(*win), next)
if (iclients->mask[XIAllDevices] & core_filter)
- break;
+ break;
/* if owner selected, iclients is NULL */
}
@@ -1373,9 +1339,10 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
}
static int
-DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
- TouchListener *listener, ClientPtr client,
- WindowPtr win, GrabPtr grab, XI2Mask *xi2mask)
+DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
+ InternalEvent *ev, TouchListener * listener,
+ ClientPtr client, WindowPtr win, GrabPtr grab,
+ XI2Mask *xi2mask)
{
InternalEvent motion, button;
InternalEvent *ptrev = &motion;
@@ -1398,22 +1365,22 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent
event_set_state(dev, kbd, &ptrev->device_event);
ptrev->device_event.corestate = event_get_corestate(dev, kbd);
- if (grab)
- {
+ if (grab) {
/* this side-steps the usual activation mechansims, but... */
if (ev->any.type == ET_TouchBegin && !dev->deviceGrab.grab)
- ActivatePassiveGrab(dev, grab, ptrev, ev); /* also delivers the event */
+ ActivatePassiveGrab(dev, grab, ptrev, ev); /* also delivers the event */
else {
int deliveries = 0;
+
/* 'grab' is the passive grab, but if the grab isn't active,
* don't deliver */
if (!dev->deviceGrab.grab)
return Success;
- if (grab->ownerEvents)
- {
+ if (grab->ownerEvents) {
WindowPtr focus = NullWindow;
WindowPtr win = dev->spriteInfo->sprite->win;
+
deliveries = DeliverDeviceEvents(win, ptrev, grab, focus, dev);
}
@@ -1422,12 +1389,11 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent
if (ev->any.type == ET_TouchEnd &&
!dev->button->buttonsDown &&
- dev->deviceGrab.fromPassiveGrab &&
- GrabIsPointerGrab(grab))
- (*dev->deviceGrab.DeactivateGrab)(dev);
+ dev->deviceGrab.fromPassiveGrab && GrabIsPointerGrab(grab))
+ (*dev->deviceGrab.DeactivateGrab) (dev);
}
- } else
- {
+ }
+ else {
GrabPtr devgrab = dev->deviceGrab.grab;
DeliverDeviceEvents(win, ptrev, grab, win, dev);
@@ -1435,8 +1401,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent
* Implicit passive grab activated in response to this event. Store
* the event.
*/
- if (!devgrab && dev->deviceGrab.grab && dev->deviceGrab.implicitGrab)
- {
+ if (!devgrab && dev->deviceGrab.grab && dev->deviceGrab.implicitGrab) {
TouchListener *listener;
devgrab = dev->deviceGrab.grab;
@@ -1450,8 +1415,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent
listener = &ti->listeners[ti->num_listeners - 1];
listener->listener = devgrab->resource;
- if (devgrab->grabtype != XI2 ||
- devgrab->type != XI_TouchBegin)
+ if (devgrab->grabtype != XI2 || devgrab->type != XI_TouchBegin)
listener->type = LISTENER_POINTER_GRAB;
else
listener->type = LISTENER_GRAB;
@@ -1466,17 +1430,13 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent
return Success;
}
-
-
-
static void
DeliverEmulatedMotionEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
InternalEvent *ev)
{
InternalEvent motion;
- if (ti->num_listeners)
- {
+ if (ti->num_listeners) {
ClientPtr client;
WindowPtr win;
GrabPtr grab;
@@ -1496,21 +1456,22 @@ DeliverEmulatedMotionEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
return;
/* There may be a pointer grab on the device */
- if (!grab)
- {
+ if (!grab) {
grab = dev->deviceGrab.grab;
- if (grab)
- {
+ if (grab) {
win = grab->window;
mask = grab->xi2mask;
client = rClient(grab);
}
}
- DeliverTouchEmulatedEvent(dev, ti, &motion, &ti->listeners[0], client, win, grab, mask);
- } else {
+ DeliverTouchEmulatedEvent(dev, ti, &motion, &ti->listeners[0], client,
+ win, grab, mask);
+ }
+ else {
InternalEvent button;
int converted;
+
converted = TouchConvertToPointerEvent(ev, &motion, &button);
BUG_WARN(converted == 0);
@@ -1534,7 +1495,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
TouchPointInfoPtr ti;
uint32_t touchid;
int type = ev->any.type;
- int emulate_pointer = !!(ev->device_event.flags & TOUCH_POINTER_EMULATED);
+ int emulate_pointer = ! !(ev->device_event.flags & TOUCH_POINTER_EMULATED);
if (!t)
return;
@@ -1547,17 +1508,16 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
if (type == ET_TouchBegin) {
ti = TouchBeginTouch(dev, ev->device_event.sourceid, touchid,
emulate_pointer);
- } else
+ }
+ else
ti = TouchFindByClientID(dev, touchid);
- if (!ti)
- {
+ if (!ti) {
DebugF("[Xi] %s: Failed to get event %d for touchpoint %d\n",
dev->name, type, touchid);
return;
}
-
/* if emulate_pointer is set, emulate the motion event right
* here, so we can ignore it for button event emulation. TouchUpdate
* events which _only_ emulate motion just work normally */
@@ -1576,8 +1536,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
* have more complex semantics. */
if (ev->any.type == ET_TouchOwnership)
ProcessTouchOwnershipEvent(dev, ti, &ev->touch_ownership_event);
- else
- {
+ else {
TouchCopyValuatorData(&ev->device_event, ti);
/* WARNING: the event type may change to TouchUpdate in
* DeliverTouchEvents if a TouchEnd was delivered to a grabbing
@@ -1588,7 +1547,6 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
}
}
-
/**
* Process DeviceEvents and DeviceChangedEvents.
*/
@@ -1604,14 +1562,13 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device)
DeviceIntPtr mouse = NULL, kbd = NULL;
DeviceEvent *event = &ev->device_event;
- if (IsPointerDevice(device))
- {
+ if (IsPointerDevice(device)) {
kbd = GetMaster(device, KEYBOARD_OR_FLOAT);
mouse = device;
- if (!kbd->key) /* can happen with floating SDs */
+ if (!kbd->key) /* can happen with floating SDs */
kbd = NULL;
- } else
- {
+ }
+ else {
mouse = GetMaster(device, POINTER_OR_FLOAT);
kbd = device;
if (!mouse->valuator || !mouse->button) /* may be float. SDs */
@@ -1630,88 +1587,85 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device)
if (IsMaster(device) || IsFloating(device))
CheckMotion(event, device);
- switch (event->type)
- {
- case ET_Motion:
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_KeyPress:
- case ET_KeyRelease:
- case ET_ProximityIn:
- case ET_ProximityOut:
- GetSpritePosition(device, &rootX, &rootY);
- event->root_x = rootX;
- event->root_y = rootY;
- NoticeEventTime((InternalEvent*)event);
- event->corestate = corestate;
- key = event->detail.key;
- break;
- default:
- break;
+ switch (event->type) {
+ case ET_Motion:
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_KeyPress:
+ case ET_KeyRelease:
+ case ET_ProximityIn:
+ case ET_ProximityOut:
+ GetSpritePosition(device, &rootX, &rootY);
+ event->root_x = rootX;
+ event->root_y = rootY;
+ NoticeEventTime((InternalEvent *) event, device);
+ event->corestate = corestate;
+ key = event->detail.key;
+ break;
+ default:
+ break;
}
if (DeviceEventCallback && !syncEvents.playingEvents) {
- DeviceEventInfoRec eventinfo;
- SpritePtr pSprite = device->spriteInfo->sprite;
+ DeviceEventInfoRec eventinfo;
+ SpritePtr pSprite = device->spriteInfo->sprite;
- /* see comment in EnqueueEvents regarding the next three lines */
- if (ev->any.type == ET_Motion)
- ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
+ /* see comment in EnqueueEvents regarding the next three lines */
+ if (ev->any.type == ET_Motion)
+ ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
- eventinfo.device = device;
- eventinfo.event = ev;
- CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
+ eventinfo.device = device;
+ eventinfo.event = ev;
+ CallCallbacks(&DeviceEventCallback, (pointer) &eventinfo);
}
grab = device->deviceGrab.grab;
- switch(event->type)
- {
- case ET_KeyPress:
- if (!grab && CheckDeviceGrabs(device, event, 0))
- return;
- break;
- case ET_KeyRelease:
- if (grab && device->deviceGrab.fromPassiveGrab &&
- (key == device->deviceGrab.activatingKey) &&
- GrabIsKeyboardGrab(device->deviceGrab.grab))
- deactivateDeviceGrab = TRUE;
- break;
- case ET_ButtonPress:
- if (b->map[key] == 0) /* there's no button 0 */
- return;
- event->detail.button = b->map[key];
- if (!grab && CheckDeviceGrabs(device, event, 0))
- {
- /* if a passive grab was activated, the event has been sent
- * already */
- return;
- }
- break;
- case ET_ButtonRelease:
- if (b->map[key] == 0) /* there's no button 0 */
- return;
- event->detail.button = b->map[key];
- if (grab && !b->buttonsDown &&
- device->deviceGrab.fromPassiveGrab &&
- GrabIsPointerGrab(device->deviceGrab.grab))
- deactivateDeviceGrab = TRUE;
- default:
- break;
+ switch (event->type) {
+ case ET_KeyPress:
+ if (!grab && CheckDeviceGrabs(device, event, 0))
+ return;
+ break;
+ case ET_KeyRelease:
+ if (grab && device->deviceGrab.fromPassiveGrab &&
+ (key == device->deviceGrab.activatingKey) &&
+ GrabIsKeyboardGrab(device->deviceGrab.grab))
+ deactivateDeviceGrab = TRUE;
+ break;
+ case ET_ButtonPress:
+ if (b->map[key] == 0) /* there's no button 0 */
+ return;
+ event->detail.button = b->map[key];
+ if (!grab && CheckDeviceGrabs(device, event, 0)) {
+ /* if a passive grab was activated, the event has been sent
+ * already */
+ return;
+ }
+ break;
+ case ET_ButtonRelease:
+ if (b->map[key] == 0) /* there's no button 0 */
+ return;
+ event->detail.button = b->map[key];
+ if (grab && !b->buttonsDown &&
+ device->deviceGrab.fromPassiveGrab &&
+ GrabIsPointerGrab(device->deviceGrab.grab))
+ deactivateDeviceGrab = TRUE;
+ default:
+ break;
}
-
if (grab)
- DeliverGrabbedEvent((InternalEvent*)event, device, deactivateDeviceGrab);
+ DeliverGrabbedEvent((InternalEvent *) event, device,
+ deactivateDeviceGrab);
else if (device->focus && !IsPointerEvent(ev))
- DeliverFocusedEvent(device, (InternalEvent*)event,
+ DeliverFocusedEvent(device, (InternalEvent *) event,
GetSpriteWindow(device));
else
- DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent*)event,
+ DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent *) event,
NullGrab, NullWindow, device);
if (deactivateDeviceGrab == TRUE)
- (*device->deviceGrab.DeactivateGrab) (device);
+ (*device->deviceGrab.DeactivateGrab) (device);
event->detail.key = key;
}
@@ -1725,118 +1679,117 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
{
verify_internal_event(ev);
- switch(ev->any.type)
- {
- case ET_RawKeyPress:
- case ET_RawKeyRelease:
- case ET_RawButtonPress:
- case ET_RawButtonRelease:
- case ET_RawMotion:
- case ET_RawTouchBegin:
- case ET_RawTouchUpdate:
- case ET_RawTouchEnd:
- DeliverRawEvent(&ev->raw_event, device);
- break;
- case ET_TouchBegin:
- case ET_TouchUpdate:
- case ET_TouchOwnership:
- case ET_TouchEnd:
- ProcessTouchEvent(ev, device);
- break;
- default:
- ProcessDeviceEvent(ev, device);
- break;
+ switch (ev->any.type) {
+ case ET_RawKeyPress:
+ case ET_RawKeyRelease:
+ case ET_RawButtonPress:
+ case ET_RawButtonRelease:
+ case ET_RawMotion:
+ case ET_RawTouchBegin:
+ case ET_RawTouchUpdate:
+ case ET_RawTouchEnd:
+ DeliverRawEvent(&ev->raw_event, device);
+ break;
+ case ET_TouchBegin:
+ case ET_TouchUpdate:
+ case ET_TouchOwnership:
+ case ET_TouchEnd:
+ ProcessTouchEvent(ev, device);
+ break;
+ default:
+ ProcessDeviceEvent(ev, device);
+ break;
}
}
static int
-DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
- TouchListener *listener, ClientPtr client,
- WindowPtr win, GrabPtr grab, XI2Mask *xi2mask)
+DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
+ InternalEvent *ev, TouchListener * listener,
+ ClientPtr client, WindowPtr win, GrabPtr grab,
+ XI2Mask *xi2mask)
{
enum TouchListenerState state;
int rc = Success;
Bool has_ownershipmask;
if (listener->type == LISTENER_POINTER_REGULAR ||
- listener->type == LISTENER_POINTER_GRAB)
- {
+ listener->type == LISTENER_POINTER_GRAB) {
rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win,
grab, xi2mask);
goto out;
}
-
has_ownershipmask = xi2mask_isset(xi2mask, dev, XI_TouchOwnership);
if (TouchResourceIsOwner(ti, listener->listener) || has_ownershipmask)
rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
- if (!TouchResourceIsOwner(ti, listener->listener))
- {
+ if (!TouchResourceIsOwner(ti, listener->listener)) {
if (has_ownershipmask)
state = LISTENER_AWAITING_OWNER;
else
state = LISTENER_AWAITING_BEGIN;
- } else
- {
+ }
+ else {
if (has_ownershipmask)
TouchSendOwnershipEvent(dev, ti, 0, listener->listener);
- state = LISTENER_IS_OWNER;
+
+ if (!has_ownershipmask || listener->type == LISTENER_REGULAR)
+ state = LISTENER_HAS_ACCEPTED;
+ else
+ state = LISTENER_IS_OWNER;
}
listener->state = state;
-out:
+ out:
return rc;
}
static int
DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
- TouchListener *listener, ClientPtr client,
+ TouchListener * listener, ClientPtr client,
WindowPtr win, GrabPtr grab, XI2Mask *xi2mask)
{
int rc = Success;
if (listener->type == LISTENER_POINTER_REGULAR ||
- listener->type == LISTENER_POINTER_GRAB)
- {
+ listener->type == LISTENER_POINTER_GRAB) {
rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win,
grab, xi2mask);
goto out;
}
/* Event in response to reject */
- if (ev->device_event.flags & TOUCH_REJECT)
- {
+ if (ev->device_event.flags & TOUCH_REJECT) {
if (listener->state != LISTENER_HAS_END)
rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
listener->state = LISTENER_HAS_END;
- } else if (TouchResourceIsOwner(ti, listener->listener))
- {
+ }
+ else if (TouchResourceIsOwner(ti, listener->listener)) {
+ Bool normal_end = !(ev->device_event.flags & TOUCH_ACCEPT);
+
/* FIXME: what about early acceptance */
- if (!(ev->device_event.flags & TOUCH_ACCEPT))
- {
- if (listener->state != LISTENER_HAS_END)
- rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
- listener->state = LISTENER_HAS_END;
- }
+ if (normal_end && listener->state != LISTENER_HAS_END)
+ rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
+
if ((ti->num_listeners > 1 ||
- (listener->type == LISTENER_GRAB &&
- xi2mask_isset(xi2mask, dev, XI_TouchOwnership))) &&
- (ev->device_event.flags & (TOUCH_ACCEPT|TOUCH_REJECT)) == 0)
- {
+ listener->state != LISTENER_HAS_ACCEPTED) &&
+ (ev->device_event.flags & (TOUCH_ACCEPT | TOUCH_REJECT)) == 0) {
ev->any.type = ET_TouchUpdate;
ev->device_event.flags |= TOUCH_PENDING_END;
ti->pending_finish = TRUE;
}
+
+ if (normal_end)
+ listener->state = LISTENER_HAS_END;
}
-out:
+ out:
return rc;
}
static int
DeliverTouchEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
- TouchListener *listener, ClientPtr client,
+ TouchListener * listener, ClientPtr client,
WindowPtr win, GrabPtr grab, XI2Mask *xi2mask)
{
Bool has_ownershipmask = FALSE;
@@ -1845,30 +1798,34 @@ DeliverTouchEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
if (xi2mask)
has_ownershipmask = xi2mask_isset(xi2mask, dev, XI_TouchOwnership);
- if (ev->any.type == ET_TouchOwnership)
- {
+ if (ev->any.type == ET_TouchOwnership) {
ev->touch_ownership_event.deviceid = dev->id;
if (!TouchResourceIsOwner(ti, listener->listener))
goto out;
rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
listener->state = LISTENER_IS_OWNER;
- } else
+ }
+ else
ev->device_event.deviceid = dev->id;
- if (ev->any.type == ET_TouchBegin)
- {
- rc = DeliverTouchBeginEvent(dev, ti, ev, listener, client, win, grab, xi2mask);
- } else if (ev->any.type == ET_TouchUpdate)
- {
+ if (ev->any.type == ET_TouchBegin) {
+ rc = DeliverTouchBeginEvent(dev, ti, ev, listener, client, win, grab,
+ xi2mask);
+ }
+ else if (ev->any.type == ET_TouchUpdate) {
if (listener->type == LISTENER_POINTER_REGULAR ||
listener->type == LISTENER_POINTER_GRAB)
- DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win, grab, xi2mask);
- else if (TouchResourceIsOwner(ti, listener->listener) || has_ownershipmask)
+ DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win, grab,
+ xi2mask);
+ else if (TouchResourceIsOwner(ti, listener->listener) ||
+ has_ownershipmask)
rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
- } else if (ev->any.type == ET_TouchEnd)
- rc = DeliverTouchEndEvent(dev, ti, ev, listener, client, win, grab, xi2mask);
+ }
+ else if (ev->any.type == ET_TouchEnd)
+ rc = DeliverTouchEndEvent(dev, ti, ev, listener, client, win, grab,
+ xi2mask);
-out:
+ out:
return rc;
}
@@ -1888,13 +1845,12 @@ DeliverTouchEvents(DeviceIntPtr dev, TouchPointInfoPtr ti,
int i;
if (ev->any.type == ET_TouchBegin &&
- !(ev->device_event.flags & (TOUCH_CLIENT_ID|TOUCH_REPLAYING)))
+ !(ev->device_event.flags & (TOUCH_CLIENT_ID | TOUCH_REPLAYING)))
TouchSetupListeners(dev, ti, ev);
TouchEventHistoryPush(ti, &ev->device_event);
- for (i = 0; i < ti->num_listeners; i++)
- {
+ for (i = 0; i < ti->num_listeners; i++) {
GrabPtr grab = NULL;
ClientPtr client;
WindowPtr win;
@@ -1922,7 +1878,7 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec));
if (!proxc)
- return FALSE;
+ return FALSE;
proxc->sourceid = dev->id;
proxc->in_proximity = TRUE;
dev->proximity = proxc;
@@ -1939,8 +1895,9 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
* @see InitValuatorClassDeviceStruct
*/
Bool
-InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
- int resolution, int min_res, int max_res, int mode)
+InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
+ int maxval, int resolution, int min_res, int max_res,
+ int mode)
{
AxisInfoPtr ax;
@@ -1969,7 +1926,8 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int
* Set the given axis number as a scrolling valuator.
*/
Bool
-SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double increment, int flags)
+SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type,
+ double increment, int flags)
{
AxisInfoPtr ax;
int *current_ax;
@@ -1979,30 +1937,29 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr
if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes)
return FALSE;
- switch (type)
- {
- case SCROLL_TYPE_VERTICAL:
- current_ax = &dev->valuator->v_scroll_axis;
- break;
- case SCROLL_TYPE_HORIZONTAL:
- current_ax = &dev->valuator->h_scroll_axis;
- break;
- case SCROLL_TYPE_NONE:
- ax = &dev->valuator->axes[axnum];
- ax->scroll.type = type;
- return TRUE;
- default:
- return FALSE;
+ switch (type) {
+ case SCROLL_TYPE_VERTICAL:
+ current_ax = &dev->valuator->v_scroll_axis;
+ break;
+ case SCROLL_TYPE_HORIZONTAL:
+ current_ax = &dev->valuator->h_scroll_axis;
+ break;
+ case SCROLL_TYPE_NONE:
+ ax = &dev->valuator->axes[axnum];
+ ax->scroll.type = type;
+ return TRUE;
+ default:
+ return FALSE;
}
if (increment == 0.0)
return FALSE;
- if (*current_ax != -1 && axnum != *current_ax)
- {
+ if (*current_ax != -1 && axnum != *current_ax) {
ax = &dev->valuator->axes[*current_ax];
if (ax->scroll.type == type &&
- (flags & SCROLL_FLAG_PREFERRED) && (ax->scroll.flags & SCROLL_FLAG_PREFERRED))
+ (flags & SCROLL_FLAG_PREFERRED) &&
+ (ax->scroll.flags & SCROLL_FLAG_PREFERRED))
return FALSE;
}
*current_ax = axnum;
@@ -2013,7 +1970,9 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr
ax->scroll.flags = flags;
master = GetMaster(dev, MASTER_ATTACHED);
- CreateClassesChangedEvent(&dce, master, dev, DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE);
+ CreateClassesChangedEvent(&dce, master, dev,
+ DEVCHANGE_POINTER_EVENT |
+ DEVCHANGE_DEVICE_CHANGE);
XISendDeviceChangedEvent(dev, &dce.changed_event);
/* if the current slave is us, update the master. If not, we'll update
@@ -2027,7 +1986,7 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr
static void
FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
- ButtonClassPtr b, ValuatorClassPtr v, int first)
+ ButtonClassPtr b, ValuatorClassPtr v, int first)
{
ev->type = DeviceStateNotify;
ev->deviceid = dev->id;
@@ -2038,36 +1997,37 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
ev->num_valuators = 0;
if (b) {
- ev->classes_reported |= (1 << ButtonClass);
- ev->num_buttons = b->numButtons;
- memcpy((char*)ev->buttons, (char*)b->down, 4);
- } else if (k) {
- ev->classes_reported |= (1 << KeyClass);
- ev->num_keys = k->xkbInfo->desc->max_key_code -
- k->xkbInfo->desc->min_key_code;
- memmove((char *)&ev->keys[0], (char *)k->down, 4);
+ ev->classes_reported |= (1 << ButtonClass);
+ ev->num_buttons = b->numButtons;
+ memcpy((char *) ev->buttons, (char *) b->down, 4);
+ }
+ else if (k) {
+ ev->classes_reported |= (1 << KeyClass);
+ ev->num_keys = k->xkbInfo->desc->max_key_code -
+ k->xkbInfo->desc->min_key_code;
+ memmove((char *) &ev->keys[0], (char *) k->down, 4);
}
if (v) {
- int nval = v->numAxes - first;
-
- ev->classes_reported |= (1 << ValuatorClass);
- ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift;
- ev->num_valuators = nval < 3 ? nval : 3;
- switch (ev->num_valuators) {
- case 3:
- ev->valuator2 = v->axisVal[first + 2];
- case 2:
- ev->valuator1 = v->axisVal[first + 1];
- case 1:
- ev->valuator0 = v->axisVal[first];
- break;
- }
+ int nval = v->numAxes - first;
+
+ ev->classes_reported |= (1 << ValuatorClass);
+ ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift;
+ ev->num_valuators = nval < 3 ? nval : 3;
+ switch (ev->num_valuators) {
+ case 3:
+ ev->valuator2 = v->axisVal[first + 2];
+ case 2:
+ ev->valuator1 = v->axisVal[first + 1];
+ case 1:
+ ev->valuator0 = v->axisVal[first];
+ break;
+ }
}
}
static void
FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
- int first)
+ int first)
{
int nval = v->numAxes - first;
@@ -2077,12 +2037,12 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
ev->first_valuator = first;
switch (ev->num_valuators) {
case 3:
- ev->valuator2 = v->axisVal[first + 2];
+ ev->valuator2 = v->axisVal[first + 2];
case 2:
- ev->valuator1 = v->axisVal[first + 1];
+ ev->valuator1 = v->axisVal[first + 1];
case 1:
- ev->valuator0 = v->axisVal[first];
- break;
+ ev->valuator0 = v->axisVal[first];
+ break;
}
first += ev->num_valuators;
}
@@ -2110,8 +2070,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
evcount++;
}
if ((k = dev->key) != NULL) {
- nkeys = k->xkbInfo->desc->max_key_code -
- k->xkbInfo->desc->min_key_code;
+ nkeys = k->xkbInfo->desc->max_key_code - k->xkbInfo->desc->min_key_code;
if (nkeys > 32)
evcount++;
if (nbuttons > 0) {
@@ -2143,7 +2102,8 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
bev = (deviceButtonStateNotify *) ev++;
bev->type = DeviceButtonStateNotify;
bev->deviceid = dev->id;
- memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4);
+ memcpy((char *) &bev->buttons[4], (char *) &b->down[4],
+ DOWN_LENGTH - 4);
}
if (nval > 0) {
(ev - 1)->deviceid |= MORE_EVENTS;
@@ -2162,7 +2122,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
kev = (deviceKeyStateNotify *) ev++;
kev->type = DeviceKeyStateNotify;
kev->deviceid = dev->id;
- memmove((char *)&kev->keys[0], (char *)&k->down[4], 28);
+ memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
}
if (nval > 0) {
(ev - 1)->deviceid |= MORE_EVENTS;
@@ -2191,7 +2151,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
void
DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
- WindowPtr pWin)
+ WindowPtr pWin)
{
deviceFocus event;
xXIFocusInEvent *xi2event;
@@ -2206,25 +2166,24 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
len = sizeof(xXIFocusInEvent) + btlen * 4;
xi2event = calloc(1, len);
- xi2event->type = GenericEvent;
- xi2event->extension = IReqCode;
- xi2event->evtype = type;
- xi2event->length = bytes_to_int32(len - sizeof(xEvent));
- xi2event->buttons_len = btlen;
- xi2event->detail = detail;
- xi2event->time = currentTime.milliseconds;
- xi2event->deviceid = dev->id;
- xi2event->sourceid = dev->id; /* a device doesn't change focus by itself */
- xi2event->mode = mode;
- xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
- xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
+ xi2event->type = GenericEvent;
+ xi2event->extension = IReqCode;
+ xi2event->evtype = type;
+ xi2event->length = bytes_to_int32(len - sizeof(xEvent));
+ xi2event->buttons_len = btlen;
+ xi2event->detail = detail;
+ xi2event->time = currentTime.milliseconds;
+ xi2event->deviceid = dev->id;
+ xi2event->sourceid = dev->id; /* a device doesn't change focus by itself */
+ xi2event->mode = mode;
+ xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
+ xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
if (BitIsOn(mouse->button->down, i))
SetBit(&xi2event[1], mouse->button->map[i]);
- if (dev->key)
- {
+ if (dev->key) {
xi2event->mods.base_mods = dev->key->xkbInfo->state.base_mods;
xi2event->mods.latched_mods = dev->key->xkbInfo->state.latched_mods;
xi2event->mods.locked_mods = dev->key->xkbInfo->state.locked_mods;
@@ -2236,11 +2195,11 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
xi2event->group.effective_group = dev->key->xkbInfo->state.group;
}
- FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent*)xi2event, pWin,
+ FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent *) xi2event, pWin,
None, FALSE);
- DeliverEventsToWindow(dev, pWin, (xEvent*)xi2event, 1,
- GetEventFilter(dev, (xEvent*)xi2event), NullGrab);
+ DeliverEventsToWindow(dev, pWin, (xEvent *) xi2event, 1,
+ GetEventFilter(dev, (xEvent *) xi2event), NullGrab);
free(xi2event);
@@ -2252,46 +2211,44 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
event.window = pWin->drawable.id;
event.time = currentTime.milliseconds;
- DeliverEventsToWindow(dev, pWin, (xEvent *) & event, 1,
- DeviceFocusChangeMask, NullGrab);
+ DeliverEventsToWindow(dev, pWin, (xEvent *) &event, 1,
+ DeviceFocusChangeMask, NullGrab);
if (event.type == DeviceFocusIn)
DeliverStateNotifyEvent(dev, pWin);
}
int
-CheckGrabValues(ClientPtr client, GrabParameters* param)
+CheckGrabValues(ClientPtr client, GrabParameters *param)
{
if (param->grabtype != CORE &&
- param->grabtype != XI &&
- param->grabtype != XI2)
- {
+ param->grabtype != XI && param->grabtype != XI2) {
ErrorF("[Xi] grabtype is invalid. This is a bug.\n");
return BadImplementation;
}
if ((param->this_device_mode != GrabModeSync) &&
- (param->this_device_mode != GrabModeAsync) &&
+ (param->this_device_mode != GrabModeAsync) &&
(param->this_device_mode != XIGrabModeTouch)) {
- client->errorValue = param->this_device_mode;
- return BadValue;
+ client->errorValue = param->this_device_mode;
+ return BadValue;
}
if ((param->other_devices_mode != GrabModeSync) &&
- (param->other_devices_mode != GrabModeAsync) &&
+ (param->other_devices_mode != GrabModeAsync) &&
(param->other_devices_mode != XIGrabModeTouch)) {
- client->errorValue = param->other_devices_mode;
- return BadValue;
+ client->errorValue = param->other_devices_mode;
+ return BadValue;
}
if (param->grabtype != XI2 && (param->modifiers != AnyModifier) &&
(param->modifiers & ~AllModifiersMask)) {
- client->errorValue = param->modifiers;
- return BadValue;
+ client->errorValue = param->modifiers;
+ return BadValue;
}
if ((param->ownerEvents != xFalse) && (param->ownerEvents != xTrue)) {
- client->errorValue = param->ownerEvents;
- return BadValue;
+ client->errorValue = param->ownerEvents;
+ return BadValue;
}
return Success;
}
@@ -2299,7 +2256,7 @@ CheckGrabValues(ClientPtr client, GrabParameters* param)
int
GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
int button, GrabParameters *param, enum InputLevel grabtype,
- GrabMask *mask)
+ GrabMask *mask)
{
WindowPtr pWin, confineTo;
CursorPtr cursor;
@@ -2309,34 +2266,35 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
rc = CheckGrabValues(client, param);
if (rc != Success)
- return rc;
+ return rc;
if (param->confineTo == None)
- confineTo = NullWindow;
+ confineTo = NullWindow;
else {
- rc = dixLookupWindow(&confineTo, param->confineTo, client, DixSetAttrAccess);
- if (rc != Success)
- return rc;
+ rc = dixLookupWindow(&confineTo, param->confineTo, client,
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
}
if (param->cursor == None)
- cursor = NullCursor;
+ cursor = NullCursor;
else {
- rc = dixLookupResourceByType((pointer *)&cursor, param->cursor,
- RT_CURSOR, client, DixUseAccess);
- if (rc != Success)
- {
- client->errorValue = param->cursor;
- return rc;
- }
- access_mode |= DixForceAccess;
- }
- if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync)
- access_mode |= DixFreezeAccess;
+ rc = dixLookupResourceByType((pointer *) &cursor, param->cursor,
+ RT_CURSOR, client, DixUseAccess);
+ if (rc != Success) {
+ client->errorValue = param->cursor;
+ return rc;
+ }
+ access_mode |= DixForceAccess;
+ }
+ if (param->this_device_mode == GrabModeSync ||
+ param->other_devices_mode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
- return rc;
+ return rc;
rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
if (grabtype == XI)
type = DeviceButtonPress;
@@ -2346,7 +2304,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype,
mask, param, type, button, confineTo, cursor);
if (!grab)
- return BadAlloc;
+ return BadAlloc;
return AddPassiveGrabToList(client, grab);
}
@@ -2356,7 +2314,8 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
*/
int
GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
- int key, GrabParameters *param, enum InputLevel grabtype, GrabMask *mask)
+ int key, GrabParameters *param, enum InputLevel grabtype,
+ GrabMask *mask)
{
WindowPtr pWin;
GrabPtr grab;
@@ -2368,32 +2327,33 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
if (rc != Success)
return rc;
if ((dev->id != XIAllDevices && dev->id != XIAllMasterDevices) && k == NULL)
- return BadMatch;
- if (grabtype == XI)
- {
+ return BadMatch;
+ if (grabtype == XI) {
if ((key > k->xkbInfo->desc->max_key_code ||
- key < k->xkbInfo->desc->min_key_code)
- && (key != AnyKey)) {
+ key < k->xkbInfo->desc->min_key_code)
+ && (key != AnyKey)) {
client->errorValue = key;
return BadValue;
}
type = DeviceKeyPress;
- } else if (grabtype == XI2)
+ }
+ else if (grabtype == XI2)
type = XI_KeyPress;
rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
- if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync)
- access_mode |= DixFreezeAccess;
+ return rc;
+ if (param->this_device_mode == GrabModeSync ||
+ param->other_devices_mode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
- return rc;
+ return rc;
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype,
mask, param, type, key, NULL, NULL);
if (!grab)
- return BadAlloc;
+ return BadAlloc;
return AddPassiveGrabToList(client, grab);
}
@@ -2414,28 +2374,29 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type,
rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
if (param->cursor == None)
- cursor = NullCursor;
+ cursor = NullCursor;
else {
- rc = dixLookupResourceByType((pointer *)&cursor, param->cursor,
- RT_CURSOR, client, DixUseAccess);
- if (rc != Success)
- {
- client->errorValue = param->cursor;
- return rc;
- }
- access_mode |= DixForceAccess;
- }
- if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync)
- access_mode |= DixFreezeAccess;
+ rc = dixLookupResourceByType((pointer *) &cursor, param->cursor,
+ RT_CURSOR, client, DixUseAccess);
+ if (rc != Success) {
+ client->errorValue = param->cursor;
+ return rc;
+ }
+ access_mode |= DixForceAccess;
+ }
+ if (param->this_device_mode == GrabModeSync ||
+ param->other_devices_mode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
- return rc;
+ return rc;
grab = CreateGrab(client->index, dev, dev, pWin, XI2,
- mask, param, (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn,
- 0, NULL, cursor);
+ mask, param,
+ (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, 0,
+ NULL, cursor);
if (!grab)
return BadAlloc;
@@ -2458,10 +2419,10 @@ GrabTouch(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev,
rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGrabAccess);
if (rc != Success)
- return rc;
+ return rc;
grab = CreateGrab(client->index, dev, mod_dev, pWin, XI2,
mask, param, XI_TouchBegin, 0, NullWindow, NullCursor);
@@ -2473,7 +2434,7 @@ GrabTouch(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev,
int
SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
- Mask mask, Mask exclusivemasks)
+ Mask mask, Mask exclusivemasks)
{
int mskidx = dev->id;
int i, ret;
@@ -2482,54 +2443,54 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
check = (mask & exclusivemasks);
if (wOtherInputMasks(pWin)) {
- if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different
- * clients to select on any of the
- * events for maskcheck. However,
- * it is OK, for some client to
- * continue selecting on one of those
- * events. */
- for (others = wOtherInputMasks(pWin)->inputClients; others;
- others = others->next) {
- if (!SameClient(others, client) && (check &
- others->mask[mskidx]))
- return BadAccess;
- }
- }
- for (others = wOtherInputMasks(pWin)->inputClients; others;
- others = others->next) {
- if (SameClient(others, client)) {
- check = others->mask[mskidx];
- others->mask[mskidx] = mask;
- if (mask == 0) {
- for (i = 0; i < EMASKSIZE; i++)
- if (i != mskidx && others->mask[i] != 0)
- break;
- if (i == EMASKSIZE) {
- RecalculateDeviceDeliverableEvents(pWin);
- if (ShouldFreeInputMasks(pWin, FALSE))
- FreeResource(others->resource, RT_NONE);
- return Success;
- }
- }
- goto maskSet;
- }
- }
+ if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different
+ * clients to select on any of the
+ * events for maskcheck. However,
+ * it is OK, for some client to
+ * continue selecting on one of those
+ * events. */
+ for (others = wOtherInputMasks(pWin)->inputClients; others;
+ others = others->next) {
+ if (!SameClient(others, client) && (check &
+ others->mask[mskidx]))
+ return BadAccess;
+ }
+ }
+ for (others = wOtherInputMasks(pWin)->inputClients; others;
+ others = others->next) {
+ if (SameClient(others, client)) {
+ check = others->mask[mskidx];
+ others->mask[mskidx] = mask;
+ if (mask == 0) {
+ for (i = 0; i < EMASKSIZE; i++)
+ if (i != mskidx && others->mask[i] != 0)
+ break;
+ if (i == EMASKSIZE) {
+ RecalculateDeviceDeliverableEvents(pWin);
+ if (ShouldFreeInputMasks(pWin, FALSE))
+ FreeResource(others->resource, RT_NONE);
+ return Success;
+ }
+ }
+ goto maskSet;
+ }
+ }
}
check = 0;
if ((ret = AddExtensionClient(pWin, client, mask, mskidx)) != Success)
- return ret;
- maskSet:
+ return ret;
+ maskSet:
if (dev->valuator)
- if ((dev->valuator->motionHintWindow == pWin) &&
- (mask & DevicePointerMotionHintMask) &&
- !(check & DevicePointerMotionHintMask) && !dev->deviceGrab.grab)
- dev->valuator->motionHintWindow = NullWindow;
+ if ((dev->valuator->motionHintWindow == pWin) &&
+ (mask & DevicePointerMotionHintMask) &&
+ !(check & DevicePointerMotionHintMask) && !dev->deviceGrab.grab)
+ dev->valuator->motionHintWindow = NullWindow;
RecalculateDeviceDeliverableEvents(pWin);
return Success;
}
static void
-FreeInputClient(InputClientsPtr *other)
+FreeInputClient(InputClientsPtr * other)
{
xi2mask_free(&(*other)->xi2mask);
free(*other);
@@ -2548,12 +2509,12 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
InputClientsPtr others;
if (!pWin->optional && !MakeWindowOptional(pWin))
- return BadAlloc;
+ return BadAlloc;
others = AllocInputClient();
if (!others)
- return BadAlloc;
+ return BadAlloc;
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
- goto bail;
+ goto bail;
others->xi2mask = xi2mask_new();
if (!others->xi2mask)
goto bail;
@@ -2562,10 +2523,10 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
others->next = pWin->optional->inputMasks->inputClients;
pWin->optional->inputMasks->inputClients = others;
if (!AddResource(others->resource, RT_INPUTCLIENT, (pointer) pWin))
- goto bail;
+ goto bail;
return Success;
-bail:
+ bail:
FreeInputClient(&others);
return BadAlloc;
}
@@ -2577,10 +2538,9 @@ MakeInputMasks(WindowPtr pWin)
imasks = calloc(1, sizeof(struct _OtherInputMasks));
if (!imasks)
- return FALSE;
+ return FALSE;
imasks->xi2mask = xi2mask_new();
- if (!imasks->xi2mask)
- {
+ if (!imasks->xi2mask) {
free(imasks);
return FALSE;
}
@@ -2589,7 +2549,7 @@ MakeInputMasks(WindowPtr pWin)
}
static void
-FreeInputMask(OtherInputMasks **imask)
+FreeInputMask(OtherInputMasks ** imask)
{
xi2mask_free(&(*imask)->xi2mask);
free(*imask);
@@ -2600,39 +2560,39 @@ void
RecalculateDeviceDeliverableEvents(WindowPtr pWin)
{
InputClientsPtr others;
- struct _OtherInputMasks *inputMasks; /* default: NULL */
+ struct _OtherInputMasks *inputMasks; /* default: NULL */
WindowPtr pChild, tmp;
int i;
pChild = pWin;
while (1) {
- if ((inputMasks = wOtherInputMasks(pChild)) != 0) {
+ if ((inputMasks = wOtherInputMasks(pChild)) != 0) {
xi2mask_zero(inputMasks->xi2mask, -1);
- for (others = inputMasks->inputClients; others;
- others = others->next) {
- for (i = 0; i < EMASKSIZE; i++)
- inputMasks->inputEvents[i] |= others->mask[i];
+ for (others = inputMasks->inputClients; others;
+ others = others->next) {
+ for (i = 0; i < EMASKSIZE; i++)
+ inputMasks->inputEvents[i] |= others->mask[i];
xi2mask_merge(inputMasks->xi2mask, others->xi2mask);
- }
- for (i = 0; i < EMASKSIZE; i++)
- inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i];
- for (tmp = pChild->parent; tmp; tmp = tmp->parent)
- if (wOtherInputMasks(tmp))
- for (i = 0; i < EMASKSIZE; i++)
- inputMasks->deliverableEvents[i] |=
- (wOtherInputMasks(tmp)->deliverableEvents[i]
- & ~inputMasks->
- dontPropagateMask[i] & PropagateMask[i]);
- }
- if (pChild->firstChild) {
- pChild = pChild->firstChild;
- continue;
- }
- while (!pChild->nextSib && (pChild != pWin))
- pChild = pChild->parent;
- if (pChild == pWin)
- break;
- pChild = pChild->nextSib;
+ }
+ for (i = 0; i < EMASKSIZE; i++)
+ inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i];
+ for (tmp = pChild->parent; tmp; tmp = tmp->parent)
+ if (wOtherInputMasks(tmp))
+ for (i = 0; i < EMASKSIZE; i++)
+ inputMasks->deliverableEvents[i] |=
+ (wOtherInputMasks(tmp)->deliverableEvents[i]
+ & ~inputMasks->dontPropagateMask[i] &
+ PropagateMask[i]);
+ }
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
}
}
@@ -2642,36 +2602,40 @@ InputClientGone(WindowPtr pWin, XID id)
InputClientsPtr other, prev;
if (!wOtherInputMasks(pWin))
- return Success;
+ return Success;
prev = 0;
for (other = wOtherInputMasks(pWin)->inputClients; other;
- other = other->next) {
- if (other->resource == id) {
- if (prev) {
- prev->next = other->next;
- FreeInputClient(&other);
- } else if (!(other->next)) {
- if (ShouldFreeInputMasks(pWin, TRUE)) {
- OtherInputMasks *mask = wOtherInputMasks(pWin);
- mask->inputClients = other->next;
- FreeInputMask(&mask);
- pWin->optional->inputMasks = (OtherInputMasks *) NULL;
- CheckWindowOptionalNeed(pWin);
- FreeInputClient(&other);
- } else {
- other->resource = FakeClientID(0);
- if (!AddResource(other->resource, RT_INPUTCLIENT,
- (pointer) pWin))
- return BadAlloc;
- }
- } else {
- wOtherInputMasks(pWin)->inputClients = other->next;
- FreeInputClient(&other);
- }
- RecalculateDeviceDeliverableEvents(pWin);
- return Success;
- }
- prev = other;
+ other = other->next) {
+ if (other->resource == id) {
+ if (prev) {
+ prev->next = other->next;
+ FreeInputClient(&other);
+ }
+ else if (!(other->next)) {
+ if (ShouldFreeInputMasks(pWin, TRUE)) {
+ OtherInputMasks *mask = wOtherInputMasks(pWin);
+
+ mask->inputClients = other->next;
+ FreeInputMask(&mask);
+ pWin->optional->inputMasks = (OtherInputMasks *) NULL;
+ CheckWindowOptionalNeed(pWin);
+ FreeInputClient(&other);
+ }
+ else {
+ other->resource = FakeClientID(0);
+ if (!AddResource(other->resource, RT_INPUTCLIENT,
+ (pointer) pWin))
+ return BadAlloc;
+ }
+ }
+ else {
+ wOtherInputMasks(pWin)->inputClients = other->next;
+ FreeInputClient(&other);
+ }
+ RecalculateDeviceDeliverableEvents(pWin);
+ return Success;
+ }
+ prev = other;
}
FatalError("client not on device event list");
}
@@ -2681,7 +2645,8 @@ InputClientGone(WindowPtr pWin, XID id)
* and all its subwindows from the trace when found. The initial window
* order is preserved.
*/
-void WindowGone(WindowPtr win)
+void
+WindowGone(WindowPtr win)
{
DeviceIntPtr dev;
@@ -2708,60 +2673,63 @@ void WindowGone(WindowPtr win)
int
SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
- xEvent * ev, Mask mask, int count)
+ xEvent *ev, Mask mask, int count)
{
WindowPtr pWin;
- WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
+ WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
WindowPtr spriteWin = GetSpriteWindow(d);
if (dest == PointerWindow)
- pWin = spriteWin;
+ pWin = spriteWin;
else if (dest == InputFocus) {
- WindowPtr inputFocus;
-
- if (!d->focus)
- inputFocus = spriteWin;
- else
- inputFocus = d->focus->win;
-
- if (inputFocus == FollowKeyboardWin)
- inputFocus = inputInfo.keyboard->focus->win;
-
- if (inputFocus == NoneWin)
- return Success;
-
- /* If the input focus is PointerRootWin, send the event to where
- * the pointer is if possible, then perhaps propogate up to root. */
- if (inputFocus == PointerRootWin)
- inputFocus = GetCurrentRootWindow(d);
-
- if (IsParent(inputFocus, spriteWin)) {
- effectiveFocus = inputFocus;
- pWin = spriteWin;
- } else
- effectiveFocus = pWin = inputFocus;
- } else
- dixLookupWindow(&pWin, dest, client, DixSendAccess);
+ WindowPtr inputFocus;
+
+ if (!d->focus)
+ inputFocus = spriteWin;
+ else
+ inputFocus = d->focus->win;
+
+ if (inputFocus == FollowKeyboardWin)
+ inputFocus = inputInfo.keyboard->focus->win;
+
+ if (inputFocus == NoneWin)
+ return Success;
+
+ /* If the input focus is PointerRootWin, send the event to where
+ * the pointer is if possible, then perhaps propogate up to root. */
+ if (inputFocus == PointerRootWin)
+ inputFocus = GetCurrentRootWindow(d);
+
+ if (IsParent(inputFocus, spriteWin)) {
+ effectiveFocus = inputFocus;
+ pWin = spriteWin;
+ }
+ else
+ effectiveFocus = pWin = inputFocus;
+ }
+ else
+ dixLookupWindow(&pWin, dest, client, DixSendAccess);
if (!pWin)
- return BadWindow;
+ return BadWindow;
if ((propagate != xFalse) && (propagate != xTrue)) {
- client->errorValue = propagate;
- return BadValue;
+ client->errorValue = propagate;
+ return BadValue;
}
ev->u.u.type |= 0x80;
if (propagate) {
- for (; pWin; pWin = pWin->parent) {
- if (DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab))
- return Success;
- if (pWin == effectiveFocus)
- return Success;
- if (wOtherInputMasks(pWin))
- mask &= ~wOtherInputMasks(pWin)->dontPropagateMask[d->id];
- if (!mask)
- break;
- }
- } else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count))
- DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab);
+ for (; pWin; pWin = pWin->parent) {
+ if (DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab))
+ return Success;
+ if (pWin == effectiveFocus)
+ return Success;
+ if (wOtherInputMasks(pWin))
+ mask &= ~wOtherInputMasks(pWin)->dontPropagateMask[d->id];
+ if (!mask)
+ break;
+ }
+ }
+ else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count))
+ DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab);
return Success;
}
@@ -2772,47 +2740,47 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
ButtonClassPtr b = dev->button;
if (b == NULL)
- return BadMatch;
+ return BadMatch;
if (nElts != b->numButtons) {
- client->errorValue = nElts;
- return BadValue;
+ client->errorValue = nElts;
+ return BadValue;
}
if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
- return BadValue;
+ return BadValue;
for (i = 0; i < nElts; i++)
- if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
- return MappingBusy;
+ if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
+ return MappingBusy;
for (i = 0; i < nElts; i++)
- b->map[i + 1] = map[i];
+ b->map[i + 1] = map[i];
return Success;
}
int
ChangeKeyMapping(ClientPtr client,
- DeviceIntPtr dev,
- unsigned len,
- int type,
- KeyCode firstKeyCode,
- CARD8 keyCodes, CARD8 keySymsPerKeyCode, KeySym * map)
+ DeviceIntPtr dev,
+ unsigned len,
+ int type,
+ KeyCode firstKeyCode,
+ CARD8 keyCodes, CARD8 keySymsPerKeyCode, KeySym * map)
{
KeySymsRec keysyms;
KeyClassPtr k = dev->key;
if (k == NULL)
- return BadMatch;
+ return BadMatch;
if (len != (keyCodes * keySymsPerKeyCode))
- return BadLength;
+ return BadLength;
if ((firstKeyCode < k->xkbInfo->desc->min_key_code) ||
- (firstKeyCode + keyCodes - 1 > k->xkbInfo->desc->max_key_code)) {
- client->errorValue = firstKeyCode;
- return BadValue;
+ (firstKeyCode + keyCodes - 1 > k->xkbInfo->desc->max_key_code)) {
+ client->errorValue = firstKeyCode;
+ return BadValue;
}
if (keySymsPerKeyCode == 0) {
- client->errorValue = 0;
- return BadValue;
+ client->errorValue = 0;
+ return BadValue;
}
keysyms.minKeyCode = firstKeyCode;
keysyms.maxKeyCode = firstKeyCode + keyCodes - 1;
@@ -2835,68 +2803,70 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
* Deactivating a device grab should cause focus events. */
if (dev->deviceGrab.grab && (dev->deviceGrab.grab->window == pWin))
- (*dev->deviceGrab.DeactivateGrab) (dev);
+ (*dev->deviceGrab.DeactivateGrab) (dev);
/* If the focus window is a root window (ie. has no parent)
* then don't delete the focus from it. */
if (dev->focus && (pWin == dev->focus->win) && (pWin->parent != NullWindow)) {
- int focusEventMode = NotifyNormal;
-
- /* If a grab is in progress, then alter the mode of focus events. */
-
- if (dev->deviceGrab.grab)
- focusEventMode = NotifyWhileGrabbed;
-
- switch (dev->focus->revert) {
- case RevertToNone:
- if (!ActivateFocusInGrab(dev, pWin, NoneWin))
- DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
- dev->focus->win = NoneWin;
- dev->focus->traceGood = 0;
- break;
- case RevertToParent:
- parent = pWin;
- do {
- parent = parent->parent;
- dev->focus->traceGood--;
- }
- while (!parent->realized);
- if (!ActivateFocusInGrab(dev, pWin, parent))
- DoFocusEvents(dev, pWin, parent, focusEventMode);
- dev->focus->win = parent;
- dev->focus->revert = RevertToNone;
- break;
- case RevertToPointerRoot:
- if (!ActivateFocusInGrab(dev, pWin, PointerRootWin))
- DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode);
- dev->focus->win = PointerRootWin;
- dev->focus->traceGood = 0;
- break;
- case RevertToFollowKeyboard:
- {
- DeviceIntPtr kbd = GetMaster(dev, MASTER_KEYBOARD);
- if (!kbd || (kbd == dev && kbd != inputInfo.keyboard))
- kbd = inputInfo.keyboard;
- if (kbd->focus->win) {
- if (!ActivateFocusInGrab(dev, pWin, kbd->focus->win))
- DoFocusEvents(dev, pWin, kbd->focus->win, focusEventMode);
- dev->focus->win = FollowKeyboardWin;
- dev->focus->traceGood = 0;
- } else {
+ int focusEventMode = NotifyNormal;
+
+ /* If a grab is in progress, then alter the mode of focus events. */
+
+ if (dev->deviceGrab.grab)
+ focusEventMode = NotifyWhileGrabbed;
+
+ switch (dev->focus->revert) {
+ case RevertToNone:
+ if (!ActivateFocusInGrab(dev, pWin, NoneWin))
+ DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
+ dev->focus->win = NoneWin;
+ dev->focus->traceGood = 0;
+ break;
+ case RevertToParent:
+ parent = pWin;
+ do {
+ parent = parent->parent;
+ dev->focus->traceGood--;
+ }
+ while (!parent->realized);
+ if (!ActivateFocusInGrab(dev, pWin, parent))
+ DoFocusEvents(dev, pWin, parent, focusEventMode);
+ dev->focus->win = parent;
+ dev->focus->revert = RevertToNone;
+ break;
+ case RevertToPointerRoot:
+ if (!ActivateFocusInGrab(dev, pWin, PointerRootWin))
+ DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode);
+ dev->focus->win = PointerRootWin;
+ dev->focus->traceGood = 0;
+ break;
+ case RevertToFollowKeyboard:
+ {
+ DeviceIntPtr kbd = GetMaster(dev, MASTER_KEYBOARD);
+
+ if (!kbd || (kbd == dev && kbd != inputInfo.keyboard))
+ kbd = inputInfo.keyboard;
+ if (kbd->focus->win) {
+ if (!ActivateFocusInGrab(dev, pWin, kbd->focus->win))
+ DoFocusEvents(dev, pWin, kbd->focus->win, focusEventMode);
+ dev->focus->win = FollowKeyboardWin;
+ dev->focus->traceGood = 0;
+ }
+ else {
if (!ActivateFocusInGrab(dev, pWin, NoneWin))
DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
- dev->focus->win = NoneWin;
- dev->focus->traceGood = 0;
- }
+ dev->focus->win = NoneWin;
+ dev->focus->traceGood = 0;
}
- break;
- }
+ }
+ break;
+ }
}
if (dev->valuator)
- if (dev->valuator->motionHintWindow == pWin)
- dev->valuator->motionHintWindow = NullWindow;
+ if (dev->valuator->motionHintWindow == pWin)
+ dev->valuator->motionHintWindow = NullWindow;
}
void
@@ -2908,79 +2878,80 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
struct _OtherInputMasks *inputMasks;
for (dev = inputInfo.devices; dev; dev = dev->next) {
- DeleteDeviceFromAnyExtEvents(pWin, dev);
+ DeleteDeviceFromAnyExtEvents(pWin, dev);
}
for (dev = inputInfo.off_devices; dev; dev = dev->next)
- DeleteDeviceFromAnyExtEvents(pWin, dev);
+ DeleteDeviceFromAnyExtEvents(pWin, dev);
if (freeResources)
- while ((inputMasks = wOtherInputMasks(pWin)) != 0) {
- ic = inputMasks->inputClients;
- for (i = 0; i < EMASKSIZE; i++)
- inputMasks->dontPropagateMask[i] = 0;
- FreeResource(ic->resource, RT_NONE);
- }
+ while ((inputMasks = wOtherInputMasks(pWin)) != 0) {
+ ic = inputMasks->inputClients;
+ for (i = 0; i < EMASKSIZE; i++)
+ inputMasks->dontPropagateMask[i] = 0;
+ FreeResource(ic->resource, RT_NONE);
+ }
}
int
-MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask)
+MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer *pEvents, Mask mask)
{
DeviceIntPtr dev;
dixLookupDevice(&dev, pEvents->deviceid & DEVICE_BITS, serverClient,
- DixReadAccess);
+ DixReadAccess);
if (!dev)
return 0;
if (pEvents->type == DeviceMotionNotify) {
- if (mask & DevicePointerMotionHintMask) {
- if (WID(dev->valuator->motionHintWindow) == pEvents->event) {
- return 1; /* don't send, but pretend we did */
- }
- pEvents->detail = NotifyHint;
- } else {
- pEvents->detail = NotifyNormal;
- }
+ if (mask & DevicePointerMotionHintMask) {
+ if (WID(dev->valuator->motionHintWindow) == pEvents->event) {
+ return 1; /* don't send, but pretend we did */
+ }
+ pEvents->detail = NotifyHint;
+ }
+ else {
+ pEvents->detail = NotifyNormal;
+ }
}
return 0;
}
void
CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
- deviceKeyButtonPointer * xE, GrabPtr grab,
- ClientPtr client, Mask deliveryMask)
+ deviceKeyButtonPointer *xE, GrabPtr grab,
+ ClientPtr client, Mask deliveryMask)
{
DeviceIntPtr dev;
dixLookupDevice(&dev, xE->deviceid & DEVICE_BITS, serverClient,
- DixGrabAccess);
+ DixGrabAccess);
if (!dev)
return;
if (type == DeviceMotionNotify)
- dev->valuator->motionHintWindow = pWin;
+ dev->valuator->motionHintWindow = pWin;
else if ((type == DeviceButtonPress) && (!grab) &&
- (deliveryMask & DeviceButtonGrabMask)) {
- GrabPtr tempGrab;
+ (deliveryMask & DeviceButtonGrabMask)) {
+ GrabPtr tempGrab;
- tempGrab = AllocGrab();
- if (!tempGrab)
- return;
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return;
- tempGrab->device = dev;
- tempGrab->resource = client->clientAsMask;
- tempGrab->window = pWin;
- tempGrab->ownerEvents =
- (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
- tempGrab->eventMask = deliveryMask;
- tempGrab->keyboardMode = GrabModeAsync;
- tempGrab->pointerMode = GrabModeAsync;
- tempGrab->confineTo = NullWindow;
- tempGrab->cursor = NullCursor;
- tempGrab->next = NULL;
- (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, currentTime, TRUE);
- FreeGrab(tempGrab);
+ tempGrab->device = dev;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->window = pWin;
+ tempGrab->ownerEvents =
+ (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
+ tempGrab->eventMask = deliveryMask;
+ tempGrab->keyboardMode = GrabModeAsync;
+ tempGrab->pointerMode = GrabModeAsync;
+ tempGrab->confineTo = NullWindow;
+ tempGrab->cursor = NullCursor;
+ tempGrab->next = NULL;
+ (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, currentTime, TRUE);
+ FreeGrab(tempGrab);
}
}
@@ -2990,11 +2961,11 @@ DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
InputClientsPtr other;
if (!wOtherInputMasks(pWin))
- return 0;
+ return 0;
for (other = wOtherInputMasks(pWin)->inputClients; other;
- other = other->next) {
- if (SameClient(other, client))
- return other->mask[dev->id];
+ other = other->next) {
+ if (SameClient(other, client))
+ return other->mask[dev->id];
}
return 0;
}
@@ -3008,39 +2979,40 @@ MaybeStopDeviceHint(DeviceIntPtr dev, ClientPtr client)
pWin = dev->valuator->motionHintWindow;
if ((grab && SameClient(grab, client) &&
- ((grab->eventMask & DevicePointerMotionHintMask) ||
- (grab->ownerEvents &&
- (DeviceEventMaskForClient(dev, pWin, client) &
- DevicePointerMotionHintMask)))) ||
- (!grab &&
- (DeviceEventMaskForClient(dev, pWin, client) &
- DevicePointerMotionHintMask)))
- dev->valuator->motionHintWindow = NullWindow;
+ ((grab->eventMask & DevicePointerMotionHintMask) ||
+ (grab->ownerEvents &&
+ (DeviceEventMaskForClient(dev, pWin, client) &
+ DevicePointerMotionHintMask)))) ||
+ (!grab &&
+ (DeviceEventMaskForClient(dev, pWin, client) &
+ DevicePointerMotionHintMask)))
+ dev->valuator->motionHintWindow = NullWindow;
}
int
DeviceEventSuppressForWindow(WindowPtr pWin, ClientPtr client, Mask mask,
- int maskndx)
+ int maskndx)
{
struct _OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
if (mask & ~PropagateMask[maskndx]) {
- client->errorValue = mask;
- return BadValue;
+ client->errorValue = mask;
+ return BadValue;
}
if (mask == 0) {
- if (inputMasks)
- inputMasks->dontPropagateMask[maskndx] = mask;
- } else {
- if (!inputMasks)
- AddExtensionClient(pWin, client, 0, 0);
- inputMasks = wOtherInputMasks(pWin);
- inputMasks->dontPropagateMask[maskndx] = mask;
+ if (inputMasks)
+ inputMasks->dontPropagateMask[maskndx] = mask;
+ }
+ else {
+ if (!inputMasks)
+ AddExtensionClient(pWin, client, 0, 0);
+ inputMasks = wOtherInputMasks(pWin);
+ inputMasks->dontPropagateMask[maskndx] = mask;
}
RecalculateDeviceDeliverableEvents(pWin);
if (ShouldFreeInputMasks(pWin, FALSE))
- FreeResource(inputMasks->inputClients->resource, RT_NONE);
+ FreeResource(inputMasks->inputClients->resource, RT_NONE);
return Success;
}
@@ -3052,14 +3024,14 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents)
struct _OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
for (i = 0; i < EMASKSIZE; i++)
- allInputEventMasks |= inputMasks->dontPropagateMask[i];
+ allInputEventMasks |= inputMasks->dontPropagateMask[i];
if (!ignoreSelectedEvents)
- for (i = 0; i < EMASKSIZE; i++)
- allInputEventMasks |= inputMasks->inputEvents[i];
+ for (i = 0; i < EMASKSIZE; i++)
+ allInputEventMasks |= inputMasks->inputEvents[i];
if (allInputEventMasks == 0)
- return TRUE;
+ return TRUE;
else
- return FALSE;
+ return FALSE;
}
/***********************************************************************
@@ -3071,7 +3043,7 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents)
static void
FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
- xEvent * ev, int count)
+ xEvent *ev, int count)
{
WindowPtr p2;
@@ -3090,7 +3062,7 @@ FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
*/
void
-SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
+SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent *ev, int count)
{
int i;
WindowPtr pWin, p1;
@@ -3115,29 +3087,26 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
*/
int
XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
- unsigned int len, unsigned char* mask)
+ unsigned int len, unsigned char *mask)
{
OtherInputMasks *masks;
InputClientsPtr others = NULL;
masks = wOtherInputMasks(win);
- if (masks)
- {
- for (others = wOtherInputMasks(win)->inputClients; others;
- others = others->next) {
- if (SameClient(others, client)) {
+ if (masks) {
+ for (others = wOtherInputMasks(win)->inputClients; others;
+ others = others->next) {
+ if (SameClient(others, client)) {
xi2mask_zero(others->xi2mask, dev->id);
break;
}
}
}
-
- if (len && !others)
- {
+ if (len && !others) {
if (AddExtensionClient(win, client, 0, 0) != Success)
return BadAlloc;
- others= wOtherInputMasks(win)->inputClients;
+ others = wOtherInputMasks(win)->inputClients;
}
if (others) {