aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/getevents.c119
-rw-r--r--xorg-server/dix/inpututils.c21
-rw-r--r--xorg-server/dix/touch.c61
-rw-r--r--xorg-server/dix/window.c2
4 files changed, 91 insertions, 112 deletions
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index e7699cd40..68c614cc4 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -1853,10 +1853,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
int i;
int num_events = 0;
RawDeviceEvent *raw;
- union touch {
- TouchPointInfoPtr dix_ti;
- DDXTouchPointInfoPtr ti;
- } touchpoint;
+ DDXTouchPointInfoPtr ti;
int need_rawevent = TRUE;
Bool emulate_pointer = FALSE;
int client_id = 0;
@@ -1875,37 +1872,15 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
/* Find and/or create the DDX touch info */
- if (flags & TOUCH_CLIENT_ID) { /* A DIX-submitted TouchEnd */
- touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid);
- BUG_RETURN_VAL(!touchpoint.dix_ti, 0);
-
- if (!mask_in ||
- !valuator_mask_isset(mask_in, 0) ||
- !valuator_mask_isset(mask_in, 1)) {
- ErrorF
- ("[dix] dix-submitted events must have x/y valuator information.\n");
- return 0;
- }
-
- need_rawevent = FALSE;
- client_id = touchpoint.dix_ti->client_id;
- }
- else { /* a DDX-submitted touch */
-
- touchpoint.ti =
- TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin));
- if (!touchpoint.ti) {
- ErrorFSigSafe("[dix] %s: unable to %s touch point %u\n", dev->name,
- type == XI_TouchBegin ? "begin" : "find", ddx_touchid);
- return 0;
- }
- client_id = touchpoint.ti->client_id;
+ ti = TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin));
+ if (!ti) {
+ ErrorFSigSafe("[dix] %s: unable to %s touch point %u\n", dev->name,
+ type == XI_TouchBegin ? "begin" : "find", ddx_touchid);
+ return 0;
}
+ client_id = ti->client_id;
- if (!(flags & TOUCH_CLIENT_ID))
- emulate_pointer = touchpoint.ti->emulate_pointer;
- else
- emulate_pointer = ! !(flags & TOUCH_POINTER_EMULATED);
+ emulate_pointer = ti->emulate_pointer;
if (!IsMaster(dev))
events =
@@ -1925,11 +1900,6 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
num_events++;
init_device_event(event, dev, ms);
- /* if submitted for master device, get the sourceid from there */
- if (flags & TOUCH_CLIENT_ID) {
- event->sourceid = touchpoint.dix_ti->sourceid;
- /* TOUCH_CLIENT_ID implies norawevent */
- }
switch (type) {
case XI_TouchBegin:
@@ -1954,38 +1924,30 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
event->type = ET_TouchEnd;
/* We can end the DDX touch here, since we don't use the active
* field below */
- if (!(flags & TOUCH_CLIENT_ID))
- TouchEndDDXTouch(dev, touchpoint.ti);
+ TouchEndDDXTouch(dev, ti);
break;
default:
return 0;
}
- if (t->mode == XIDirectTouch && !(flags & TOUCH_CLIENT_ID)) {
- if (!valuator_mask_isset(&mask, 0))
- valuator_mask_set_double(&mask, 0,
- valuator_mask_get_double(touchpoint.ti->
- valuators, 0));
- if (!valuator_mask_isset(&mask, 1))
- valuator_mask_set_double(&mask, 1,
- valuator_mask_get_double(touchpoint.ti->
- valuators, 1));
- }
/* Get our screen event co-ordinates (root_x/root_y/event_x/event_y):
* these come from the touchpoint in Absolute mode, or the sprite in
* Relative. */
if (t->mode == XIDirectTouch) {
- transformAbsolute(dev, &mask);
-
- if (!(flags & TOUCH_CLIENT_ID)) {
- for (i = 0; i < valuator_mask_size(&mask); i++) {
- double val;
-
- if (valuator_mask_fetch_double(&mask, i, &val))
- valuator_mask_set_double(touchpoint.ti->valuators, i, val);
- }
+ for (i = 0; i < max(valuator_mask_size(&mask), 2); i++) {
+ double val;
+
+ if (valuator_mask_fetch_double(&mask, i, &val))
+ valuator_mask_set_double(ti->valuators, i, val);
+ /* If the device doesn't post new X and Y axis values,
+ * use the last values posted.
+ */
+ else if (i < 2 &&
+ valuator_mask_fetch_double(ti->valuators, i, &val))
+ valuator_mask_set_double(&mask, i, val);
}
+ transformAbsolute(dev, &mask);
clipAbsolute(dev, &mask);
}
else {
@@ -2014,6 +1976,14 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
if (emulate_pointer)
storeLastValuators(dev, &mask, 0, 1, devx, devy);
+ /* Update the MD's co-ordinates, which are always in desktop space. */
+ if (emulate_pointer && !IsMaster(dev) && !IsFloating(dev)) {
+ DeviceIntPtr master = GetMaster(dev, MASTER_POINTER);
+
+ master->last.valuators[0] = screenx;
+ master->last.valuators[1] = screeny;
+ }
+
event->root = scr->root->drawable.id;
event_set_root_coordinates(event, screenx, screeny);
@@ -2034,6 +2004,37 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
return num_events;
}
+void
+GetDixTouchEnd(InternalEvent *ievent, DeviceIntPtr dev, TouchPointInfoPtr ti,
+ uint32_t flags)
+{
+ ScreenPtr scr = dev->spriteInfo->sprite->hotPhys.pScreen;
+ DeviceEvent *event = &ievent->device_event;
+ CARD32 ms = GetTimeInMillis();
+
+ BUG_WARN(!dev->enabled);
+
+ init_device_event(event, dev, ms);
+
+ event->sourceid = ti->sourceid;
+ event->type = ET_TouchEnd;
+
+ event->root = scr->root->drawable.id;
+
+ /* Get screen event coordinates from the sprite. Is this really the best
+ * we can do? */
+ event_set_root_coordinates(event,
+ dev->last.valuators[0],
+ dev->last.valuators[1]);
+ event->touchid = ti->client_id;
+ event->flags = flags;
+
+ if (flags & TOUCH_POINTER_EMULATED) {
+ event->flags |= TOUCH_POINTER_EMULATED;
+ event->detail.button = 1;
+ }
+}
+
/**
* Synthesize a single motion event for the core pointer.
*
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c
index 3136a6dd3..fee34ef59 100644
--- a/xorg-server/dix/inpututils.c
+++ b/xorg-server/dix/inpututils.c
@@ -910,11 +910,7 @@ input_option_set_value(InputOption *opt, const char *value)
double
fp1616_to_double(FP1616 in)
{
- double ret;
-
- ret = (double) (in >> 16);
- ret += (double) (in & 0xffff) * (1.0 / (1UL << 16)); /* Optimized: ldexp((double)(in & 0xffff), -16); */
- return ret;
+ return pixman_fixed_to_double(in);
}
double
@@ -930,20 +926,7 @@ fp3232_to_double(FP3232 in)
FP1616
double_to_fp1616(double in)
{
- FP1616 ret;
- int32_t integral;
- double tmp;
- uint32_t frac_d;
-
- tmp = floor(in);
- integral = (int32_t) tmp;
-
- tmp = (in - integral) * (1UL << 16); /* Optimized: ldexp(in - integral, 16) */
- frac_d = (uint16_t) tmp;
-
- ret = integral << 16;
- ret |= frac_d & 0xffff;
- return ret;
+ return pixman_double_to_fixed(in);
}
FP3232
diff --git a/xorg-server/dix/touch.c b/xorg-server/dix/touch.c
index 5f77be575..29ba17194 100644
--- a/xorg-server/dix/touch.c
+++ b/xorg-server/dix/touch.c
@@ -463,45 +463,14 @@ TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev)
void
TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource)
{
- InternalEvent *tel;
- ValuatorMask *mask;
- int i, nev;
- int flags;
+ int i;
if (!ti->history)
return;
- tel = InitEventList(GetMaximumEventsNum());
- mask = valuator_mask_new(0);
-
- valuator_mask_set_double(mask, 0, ti->history[0].valuators.data[0]);
- valuator_mask_set_double(mask, 1, ti->history[0].valuators.data[1]);
-
- flags = TOUCH_CLIENT_ID | TOUCH_REPLAYING;
- if (ti->emulate_pointer)
- flags |= TOUCH_POINTER_EMULATED;
- /* Generate events based on a fake touch begin event to get DCCE events if
- * needed */
- /* FIXME: This needs to be cleaned up */
- nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchBegin, flags, mask);
- for (i = 0; i < nev; i++) {
- /* Send saved touch begin event */
- if (tel[i].any.type == ET_TouchBegin) {
- DeviceEvent *ev = &ti->history[0];
- ev->flags |= TOUCH_REPLAYING;
- DeliverTouchEvents(dev, ti, (InternalEvent*)ev, resource);
- }
- else {/* Send DCCE event */
- tel[i].any.time = ti->history[0].time;
- DeliverTouchEvents(dev, ti, tel + i, resource);
- }
- }
-
- valuator_mask_free(&mask);
- FreeEventList(tel, GetMaximumEventsNum());
+ TouchDeliverDeviceClassesChangedEvent(ti, ti->history[0].time, resource);
- /* First event was TouchBegin, already replayed that one */
- for (i = 1; i < ti->history_elements; i++) {
+ for (i = 0; i < ti->history_elements; i++) {
DeviceEvent *ev = &ti->history[i];
ev->flags |= TOUCH_REPLAYING;
@@ -509,6 +478,30 @@ TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource)
}
}
+void
+TouchDeliverDeviceClassesChangedEvent(TouchPointInfoPtr ti, Time time,
+ XID resource)
+{
+ DeviceIntPtr dev;
+ int num_events = 0;
+ InternalEvent dcce;
+
+ dixLookupDevice(&dev, ti->sourceid, serverClient, DixWriteAccess);
+
+ if (!dev)
+ return;
+
+ /* UpdateFromMaster generates at most one event */
+ UpdateFromMaster(&dcce, dev, DEVCHANGE_POINTER_EVENT, &num_events);
+ BUG_WARN(num_events > 1);
+
+ if (num_events) {
+ dcce.any.time = time;
+ /* FIXME: This doesn't do anything */
+ dev->public.processInputProc(&dcce, dev);
+ }
+}
+
Bool
TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite)
{
diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c
index ce47651cc..6932157d1 100644
--- a/xorg-server/dix/window.c
+++ b/xorg-server/dix/window.c
@@ -3098,6 +3098,8 @@ dixSaveScreens(ClientPtr client, int on, int mode)
UpdateCurrentTimeIf();
nt_list_for_each_entry(dev, inputInfo.devices, next)
lastDeviceEventTime[dev->id] = currentTime;
+ lastDeviceEventTime[XIAllDevices] = currentTime;
+ lastDeviceEventTime[XIAllMasterDevices] = currentTime;
}
SetScreenSaverTimer();
}