dix: Push UpdateCurrentTimeIf down out of the main loop
This was added in:
commit 312910b4e3
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>
This commit is contained in:
parent
ac164e5887
commit
137ac094e7
|
@ -881,6 +881,7 @@ SendShapeNotify(WindowPtr pWin, int which)
|
|||
default:
|
||||
return;
|
||||
}
|
||||
UpdateCurrentTimeIf();
|
||||
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
|
||||
xShapeNotifyEvent se = {
|
||||
.type = ShapeNotify + ShapeEventBase,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue