summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2016-04-01 22:44:26 -0400
committerAdam Jackson <ajax@redhat.com>2016-05-04 10:58:01 -0400
commit137ac094e7ab8c871f3b36e40ad826ac797f0e26 (patch)
tree176d84564ba28a563152634d5726ada7ce613969
parentac164e58870d70640381e68b776eb95578c7fbd3 (diff)
dix: Push UpdateCurrentTimeIf down out of the main loop
This was added in: commit 312910b4e34215aaa50fc0c6092684d5878dc32f Author: Chase Douglas <chase.douglas@canonical.com> Date: Wed Apr 18 11:15:40 2012 -0700 Update currentTime in dispatch loop Unfortunately this is equivalent to calling GetTimeInMillis() once per request. In the absolute best case (as on Linux) you're only hitting the vDSO; on other platforms that's a syscall. Either way it puts a pretty hard ceiling on request throughput. Instead, push the call down to the requests that need it; basically, grab processing and event generation. Cc: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r--Xext/shape.c1
-rw-r--r--Xi/extinit.c2
-rw-r--r--Xi/xiproperty.c6
-rw-r--r--dix/devices.c16
-rw-r--r--dix/dispatch.c5
-rw-r--r--dix/enterleave.c1
-rw-r--r--dix/events.c6
-rw-r--r--dix/property.c12
-rw-r--r--dix/selection.c3
-rw-r--r--randr/randr.c2
-rw-r--r--xfixes/cursor.c1
-rw-r--r--xfixes/select.c1
12 files changed, 39 insertions, 17 deletions
diff --git a/Xext/shape.c b/Xext/shape.c
index 2fc789ec1..142f9c178 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -881,6 +881,7 @@ SendShapeNotify(WindowPtr pWin, int which)
default:
return;
}
+ UpdateCurrentTimeIf();
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
xShapeNotifyEvent se = {
.type = ShapeNotify + ShapeEventBase,
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 26c628cbd..75f383238 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -406,6 +406,7 @@ ProcIDispatch(ClientPtr client)
if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
return BadRequest;
+ UpdateCurrentTimeIf();
return (*ProcIVector[stuff->data]) (client);
}
@@ -425,6 +426,7 @@ SProcIDispatch(ClientPtr client)
if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
return BadRequest;
+ UpdateCurrentTimeIf();
return (*SProcIVector[stuff->data]) (client);
}
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index e3b8f5abe..26d12066a 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -622,6 +622,7 @@ XIDeleteAllDeviceProperties(DeviceIntPtr device)
XIPropertyPtr prop, next;
XIPropertyHandlerPtr curr_handler, next_handler;
+ UpdateCurrentTimeIf();
for (prop = device->properties.properties; prop; prop = next) {
next = prop->next;
send_property_event(device, prop->propertyName, XIPropertyDeleted);
@@ -672,6 +673,7 @@ XIDeleteDeviceProperty(DeviceIntPtr device, Atom property, Bool fromClient)
}
if (prop) {
+ UpdateCurrentTimeIf();
*prev = prop->next;
send_property_event(device, prop->propertyName, XIPropertyDeleted);
XIDestroyDeviceProperty(prop);
@@ -793,9 +795,11 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
dev->properties.properties = prop;
}
- if (sendevent)
+ if (sendevent) {
+ UpdateCurrentTimeIf();
send_property_event(dev, prop->propertyName,
(add) ? XIPropertyCreated : XIPropertyModified);
+ }
return Success;
}
diff --git a/dix/devices.c b/dix/devices.c
index a532dcfaa..fcd0c08fa 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -281,6 +281,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
dev->startup = autoStart;
/* device grab defaults */
+ UpdateCurrentTimeIf();
dev->deviceGrab.grabTime = currentTime;
dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
@@ -336,12 +337,13 @@ void
SendDevicePresenceEvent(int deviceid, int type)
{
DeviceIntRec dummyDev = { .id = XIAllDevices };
- devicePresenceNotify ev = {
- .type = DevicePresenceNotify,
- .time = currentTime.milliseconds,
- .devchange = type,
- .deviceid = deviceid
- };
+ devicePresenceNotify ev;
+
+ UpdateCurrentTimeIf();
+ ev.type = DevicePresenceNotify;
+ ev.time = currentTime.milliseconds;
+ ev.devchange = type;
+ ev.deviceid = deviceid;
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
(xEvent *) &ev, 1);
@@ -1403,6 +1405,7 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev)
focc = malloc(sizeof(FocusClassRec));
if (!focc)
return FALSE;
+ UpdateCurrentTimeIf();
focc->win = PointerRootWin;
focc->revert = None;
focc->time = currentTime;
@@ -2354,6 +2357,7 @@ ProcGetMotionEvents(ClientPtr client)
if (rc != Success)
return rc;
+ UpdateCurrentTimeIf();
if (mouse->valuator->motionHintWindow)
MaybeStopHint(mouse, client);
rep = (xGetMotionEventsReply) {
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 53032dc64..26122c1b6 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -393,11 +393,8 @@ Dispatch(void)
client->smart_priority--;
break;
}
- /* now, finally, deal with client requests */
- /* Update currentTime so request time checks, such as for input
- * device grabs, are calculated correctly */
- UpdateCurrentTimeIf();
+ /* now, finally, deal with client requests */
result = ReadRequestFromClient(client);
if (result <= 0) {
if (result < 0)
diff --git a/dix/enterleave.c b/dix/enterleave.c
index f0b1572fb..0fba8bdee 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -782,6 +782,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
DeviceIntPtr mouse;
int btlen, len, i;
+ UpdateCurrentTimeIf();
mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
/* XI 2 event */
diff --git a/dix/events.c b/dix/events.c
index efaf91d2b..0404ebacc 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1822,6 +1822,7 @@ ProcAllowEvents(ClientPtr client)
REQUEST(xAllowEventsReq);
REQUEST_SIZE_MATCH(xAllowEventsReq);
+ UpdateCurrentTime();
time = ClientTimeToServerTime(stuff->time);
mouse = PickPointer(client);
@@ -2241,6 +2242,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
this mask is the mask of the grab. */
int type = pEvents->u.u.type;
+ UpdateCurrentTimeIf();
/* Deliver to window owner */
if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0) {
enum EventDeliveryState rc;
@@ -4952,6 +4954,7 @@ ProcChangeActivePointerGrab(ClientPtr client)
return Success;
if (!SameClient(grab, client))
return Success;
+ UpdateCurrentTime();
time = ClientTimeToServerTime(stuff->time);
if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER))
@@ -5132,6 +5135,7 @@ ProcGrabKeyboard(ClientPtr client)
GrabMask mask;
REQUEST_SIZE_MATCH(xGrabKeyboardReq);
+ UpdateCurrentTime();
mask.core = KeyPressMask | KeyReleaseMask;
@@ -5544,6 +5548,7 @@ ProcGrabButton(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xGrabButtonReq);
+ UpdateCurrentTime();
if ((stuff->pointerMode != GrabModeSync) &&
(stuff->pointerMode != GrabModeAsync)) {
client->errorValue = stuff->pointerMode;
@@ -5632,6 +5637,7 @@ ProcUngrabButton(ClientPtr client)
DeviceIntPtr ptr;
REQUEST_SIZE_MATCH(xUngrabButtonReq);
+ UpdateCurrentTime();
if ((stuff->modifiers != AnyModifier) &&
(stuff->modifiers & ~AllModifiersMask)) {
client->errorValue = stuff->modifiers;
diff --git a/dix/property.c b/dix/property.c
index 92c25586c..bde2af8cf 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -108,12 +108,12 @@ dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom propertyName,
static void
deliverPropertyNotifyEvent(WindowPtr pWin, int state, Atom atom)
{
- xEvent event = {
- .u.property.window = pWin->drawable.id,
- .u.property.state = state,
- .u.property.atom = atom,
- .u.property.time = currentTime.milliseconds
- };
+ xEvent event;
+ UpdateCurrentTimeIf();
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = state;
+ event.u.property.atom = atom;
+ event.u.property.time = currentTime.milliseconds;
event.u.u.type = PropertyNotify;
DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
}
diff --git a/dix/selection.c b/dix/selection.c
index 4e994b1ec..d46103f70 100644
--- a/dix/selection.c
+++ b/dix/selection.c
@@ -279,6 +279,9 @@ ProcConvertSelection(ClientPtr client)
return BadAtom;
}
+ if (stuff->time == CurrentTime)
+ UpdateCurrentTime();
+
rc = dixLookupSelection(&pSel, stuff->selection, client, DixReadAccess);
memset(&event, 0, sizeof(xEvent));
diff --git a/randr/randr.c b/randr/randr.c
index ad1dda227..3aabb1981 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -676,6 +676,7 @@ ProcRRDispatch(ClientPtr client)
REQUEST(xReq);
if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
return BadRequest;
+ UpdateCurrentTimeIf();
return (*ProcRandrVector[stuff->data]) (client);
}
@@ -685,5 +686,6 @@ SProcRRDispatch(ClientPtr client)
REQUEST(xReq);
if (stuff->data >= RRNumberRequests || !SProcRandrVector[stuff->data])
return BadRequest;
+ UpdateCurrentTimeIf();
return (*SProcRandrVector[stuff->data]) (client);
}
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 10f9b2346..f009a78b9 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -153,6 +153,7 @@ CursorDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
if (pCursor != CursorCurrent[pDev->id]) {
CursorEventPtr e;
+ UpdateCurrentTimeIf();
CursorCurrent[pDev->id] = pCursor;
for (e = cursorEvents; e; e = e->next) {
if ((e->eventMask & XFixesDisplayCursorNotifyMask)) {
diff --git a/xfixes/select.c b/xfixes/select.c
index e964d588c..87a3ad777 100644
--- a/xfixes/select.c
+++ b/xfixes/select.c
@@ -75,6 +75,7 @@ XFixesSelectionCallback(CallbackListPtr *callbacks, void *data, void *args)
default:
return;
}
+ UpdateCurrentTimeIf();
for (e = selectionEvents; e; e = e->next) {
if (e->selection == selection->selection && (e->eventMask & eventMask)) {
xXFixesSelectionNotifyEvent ev = {