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:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
|
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
|
||||||
xShapeNotifyEvent se = {
|
xShapeNotifyEvent se = {
|
||||||
.type = ShapeNotify + ShapeEventBase,
|
.type = ShapeNotify + ShapeEventBase,
|
||||||
|
|
|
@ -406,6 +406,7 @@ ProcIDispatch(ClientPtr client)
|
||||||
if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
|
if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
return (*ProcIVector[stuff->data]) (client);
|
return (*ProcIVector[stuff->data]) (client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,6 +426,7 @@ SProcIDispatch(ClientPtr client)
|
||||||
if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
|
if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
return (*SProcIVector[stuff->data]) (client);
|
return (*SProcIVector[stuff->data]) (client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -622,6 +622,7 @@ XIDeleteAllDeviceProperties(DeviceIntPtr device)
|
||||||
XIPropertyPtr prop, next;
|
XIPropertyPtr prop, next;
|
||||||
XIPropertyHandlerPtr curr_handler, next_handler;
|
XIPropertyHandlerPtr curr_handler, next_handler;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
for (prop = device->properties.properties; prop; prop = next) {
|
for (prop = device->properties.properties; prop; prop = next) {
|
||||||
next = prop->next;
|
next = prop->next;
|
||||||
send_property_event(device, prop->propertyName, XIPropertyDeleted);
|
send_property_event(device, prop->propertyName, XIPropertyDeleted);
|
||||||
|
@ -672,6 +673,7 @@ XIDeleteDeviceProperty(DeviceIntPtr device, Atom property, Bool fromClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop) {
|
if (prop) {
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
*prev = prop->next;
|
*prev = prop->next;
|
||||||
send_property_event(device, prop->propertyName, XIPropertyDeleted);
|
send_property_event(device, prop->propertyName, XIPropertyDeleted);
|
||||||
XIDestroyDeviceProperty(prop);
|
XIDestroyDeviceProperty(prop);
|
||||||
|
@ -793,9 +795,11 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
|
||||||
dev->properties.properties = prop;
|
dev->properties.properties = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendevent)
|
if (sendevent) {
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
send_property_event(dev, prop->propertyName,
|
send_property_event(dev, prop->propertyName,
|
||||||
(add) ? XIPropertyCreated : XIPropertyModified);
|
(add) ? XIPropertyCreated : XIPropertyModified);
|
||||||
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,6 +281,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
|
||||||
dev->startup = autoStart;
|
dev->startup = autoStart;
|
||||||
|
|
||||||
/* device grab defaults */
|
/* device grab defaults */
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
dev->deviceGrab.grabTime = currentTime;
|
dev->deviceGrab.grabTime = currentTime;
|
||||||
dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
|
dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
|
||||||
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
|
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
|
||||||
|
@ -336,12 +337,13 @@ void
|
||||||
SendDevicePresenceEvent(int deviceid, int type)
|
SendDevicePresenceEvent(int deviceid, int type)
|
||||||
{
|
{
|
||||||
DeviceIntRec dummyDev = { .id = XIAllDevices };
|
DeviceIntRec dummyDev = { .id = XIAllDevices };
|
||||||
devicePresenceNotify ev = {
|
devicePresenceNotify ev;
|
||||||
.type = DevicePresenceNotify,
|
|
||||||
.time = currentTime.milliseconds,
|
UpdateCurrentTimeIf();
|
||||||
.devchange = type,
|
ev.type = DevicePresenceNotify;
|
||||||
.deviceid = deviceid
|
ev.time = currentTime.milliseconds;
|
||||||
};
|
ev.devchange = type;
|
||||||
|
ev.deviceid = deviceid;
|
||||||
|
|
||||||
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
||||||
(xEvent *) &ev, 1);
|
(xEvent *) &ev, 1);
|
||||||
|
@ -1403,6 +1405,7 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev)
|
||||||
focc = malloc(sizeof(FocusClassRec));
|
focc = malloc(sizeof(FocusClassRec));
|
||||||
if (!focc)
|
if (!focc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
focc->win = PointerRootWin;
|
focc->win = PointerRootWin;
|
||||||
focc->revert = None;
|
focc->revert = None;
|
||||||
focc->time = currentTime;
|
focc->time = currentTime;
|
||||||
|
@ -2354,6 +2357,7 @@ ProcGetMotionEvents(ClientPtr client)
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
if (mouse->valuator->motionHintWindow)
|
if (mouse->valuator->motionHintWindow)
|
||||||
MaybeStopHint(mouse, client);
|
MaybeStopHint(mouse, client);
|
||||||
rep = (xGetMotionEventsReply) {
|
rep = (xGetMotionEventsReply) {
|
||||||
|
|
|
@ -393,11 +393,8 @@ Dispatch(void)
|
||||||
client->smart_priority--;
|
client->smart_priority--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* now, finally, deal with client requests */
|
|
||||||
|
|
||||||
/* Update currentTime so request time checks, such as for input
|
/* now, finally, deal with client requests */
|
||||||
* device grabs, are calculated correctly */
|
|
||||||
UpdateCurrentTimeIf();
|
|
||||||
result = ReadRequestFromClient(client);
|
result = ReadRequestFromClient(client);
|
||||||
if (result <= 0) {
|
if (result <= 0) {
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
|
|
|
@ -782,6 +782,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
|
||||||
DeviceIntPtr mouse;
|
DeviceIntPtr mouse;
|
||||||
int btlen, len, i;
|
int btlen, len, i;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
|
mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
|
||||||
|
|
||||||
/* XI 2 event */
|
/* XI 2 event */
|
||||||
|
|
|
@ -1822,6 +1822,7 @@ ProcAllowEvents(ClientPtr client)
|
||||||
REQUEST(xAllowEventsReq);
|
REQUEST(xAllowEventsReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xAllowEventsReq);
|
REQUEST_SIZE_MATCH(xAllowEventsReq);
|
||||||
|
UpdateCurrentTime();
|
||||||
time = ClientTimeToServerTime(stuff->time);
|
time = ClientTimeToServerTime(stuff->time);
|
||||||
|
|
||||||
mouse = PickPointer(client);
|
mouse = PickPointer(client);
|
||||||
|
@ -2241,6 +2242,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
|
||||||
this mask is the mask of the grab. */
|
this mask is the mask of the grab. */
|
||||||
int type = pEvents->u.u.type;
|
int type = pEvents->u.u.type;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
/* Deliver to window owner */
|
/* Deliver to window owner */
|
||||||
if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0) {
|
if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0) {
|
||||||
enum EventDeliveryState rc;
|
enum EventDeliveryState rc;
|
||||||
|
@ -4952,6 +4954,7 @@ ProcChangeActivePointerGrab(ClientPtr client)
|
||||||
return Success;
|
return Success;
|
||||||
if (!SameClient(grab, client))
|
if (!SameClient(grab, client))
|
||||||
return Success;
|
return Success;
|
||||||
|
UpdateCurrentTime();
|
||||||
time = ClientTimeToServerTime(stuff->time);
|
time = ClientTimeToServerTime(stuff->time);
|
||||||
if ((CompareTimeStamps(time, currentTime) == LATER) ||
|
if ((CompareTimeStamps(time, currentTime) == LATER) ||
|
||||||
(CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER))
|
(CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER))
|
||||||
|
@ -5132,6 +5135,7 @@ ProcGrabKeyboard(ClientPtr client)
|
||||||
GrabMask mask;
|
GrabMask mask;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xGrabKeyboardReq);
|
REQUEST_SIZE_MATCH(xGrabKeyboardReq);
|
||||||
|
UpdateCurrentTime();
|
||||||
|
|
||||||
mask.core = KeyPressMask | KeyReleaseMask;
|
mask.core = KeyPressMask | KeyReleaseMask;
|
||||||
|
|
||||||
|
@ -5544,6 +5548,7 @@ ProcGrabButton(ClientPtr client)
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xGrabButtonReq);
|
REQUEST_SIZE_MATCH(xGrabButtonReq);
|
||||||
|
UpdateCurrentTime();
|
||||||
if ((stuff->pointerMode != GrabModeSync) &&
|
if ((stuff->pointerMode != GrabModeSync) &&
|
||||||
(stuff->pointerMode != GrabModeAsync)) {
|
(stuff->pointerMode != GrabModeAsync)) {
|
||||||
client->errorValue = stuff->pointerMode;
|
client->errorValue = stuff->pointerMode;
|
||||||
|
@ -5632,6 +5637,7 @@ ProcUngrabButton(ClientPtr client)
|
||||||
DeviceIntPtr ptr;
|
DeviceIntPtr ptr;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xUngrabButtonReq);
|
REQUEST_SIZE_MATCH(xUngrabButtonReq);
|
||||||
|
UpdateCurrentTime();
|
||||||
if ((stuff->modifiers != AnyModifier) &&
|
if ((stuff->modifiers != AnyModifier) &&
|
||||||
(stuff->modifiers & ~AllModifiersMask)) {
|
(stuff->modifiers & ~AllModifiersMask)) {
|
||||||
client->errorValue = stuff->modifiers;
|
client->errorValue = stuff->modifiers;
|
||||||
|
|
|
@ -108,12 +108,12 @@ dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom propertyName,
|
||||||
static void
|
static void
|
||||||
deliverPropertyNotifyEvent(WindowPtr pWin, int state, Atom atom)
|
deliverPropertyNotifyEvent(WindowPtr pWin, int state, Atom atom)
|
||||||
{
|
{
|
||||||
xEvent event = {
|
xEvent event;
|
||||||
.u.property.window = pWin->drawable.id,
|
UpdateCurrentTimeIf();
|
||||||
.u.property.state = state,
|
event.u.property.window = pWin->drawable.id;
|
||||||
.u.property.atom = atom,
|
event.u.property.state = state;
|
||||||
.u.property.time = currentTime.milliseconds
|
event.u.property.atom = atom;
|
||||||
};
|
event.u.property.time = currentTime.milliseconds;
|
||||||
event.u.u.type = PropertyNotify;
|
event.u.u.type = PropertyNotify;
|
||||||
DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
|
DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,6 +279,9 @@ ProcConvertSelection(ClientPtr client)
|
||||||
return BadAtom;
|
return BadAtom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stuff->time == CurrentTime)
|
||||||
|
UpdateCurrentTime();
|
||||||
|
|
||||||
rc = dixLookupSelection(&pSel, stuff->selection, client, DixReadAccess);
|
rc = dixLookupSelection(&pSel, stuff->selection, client, DixReadAccess);
|
||||||
|
|
||||||
memset(&event, 0, sizeof(xEvent));
|
memset(&event, 0, sizeof(xEvent));
|
||||||
|
|
|
@ -676,6 +676,7 @@ ProcRRDispatch(ClientPtr client)
|
||||||
REQUEST(xReq);
|
REQUEST(xReq);
|
||||||
if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
|
if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
return (*ProcRandrVector[stuff->data]) (client);
|
return (*ProcRandrVector[stuff->data]) (client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,5 +686,6 @@ SProcRRDispatch(ClientPtr client)
|
||||||
REQUEST(xReq);
|
REQUEST(xReq);
|
||||||
if (stuff->data >= RRNumberRequests || !SProcRandrVector[stuff->data])
|
if (stuff->data >= RRNumberRequests || !SProcRandrVector[stuff->data])
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
return (*SProcRandrVector[stuff->data]) (client);
|
return (*SProcRandrVector[stuff->data]) (client);
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ CursorDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
||||||
if (pCursor != CursorCurrent[pDev->id]) {
|
if (pCursor != CursorCurrent[pDev->id]) {
|
||||||
CursorEventPtr e;
|
CursorEventPtr e;
|
||||||
|
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
CursorCurrent[pDev->id] = pCursor;
|
CursorCurrent[pDev->id] = pCursor;
|
||||||
for (e = cursorEvents; e; e = e->next) {
|
for (e = cursorEvents; e; e = e->next) {
|
||||||
if ((e->eventMask & XFixesDisplayCursorNotifyMask)) {
|
if ((e->eventMask & XFixesDisplayCursorNotifyMask)) {
|
||||||
|
|
|
@ -75,6 +75,7 @@ XFixesSelectionCallback(CallbackListPtr *callbacks, void *data, void *args)
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
UpdateCurrentTimeIf();
|
||||||
for (e = selectionEvents; e; e = e->next) {
|
for (e = selectionEvents; e; e = e->next) {
|
||||||
if (e->selection == selection->selection && (e->eventMask & eventMask)) {
|
if (e->selection == selection->selection && (e->eventMask & eventMask)) {
|
||||||
xXFixesSelectionNotifyEvent ev = {
|
xXFixesSelectionNotifyEvent ev = {
|
||||||
|
|
Loading…
Reference in New Issue