diff options
author | Adam Jackson <ajax@redhat.com> | 2016-04-01 22:44:26 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2016-05-04 10:58:01 -0400 |
commit | 137ac094e7ab8c871f3b36e40ad826ac797f0e26 (patch) | |
tree | 176d84564ba28a563152634d5726ada7ce613969 /dix | |
parent | ac164e58870d70640381e68b776eb95578c7fbd3 (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>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/devices.c | 16 | ||||
-rw-r--r-- | dix/dispatch.c | 5 | ||||
-rw-r--r-- | dix/enterleave.c | 1 | ||||
-rw-r--r-- | dix/events.c | 6 | ||||
-rw-r--r-- | dix/property.c | 12 | ||||
-rw-r--r-- | dix/selection.c | 3 |
6 files changed, 27 insertions, 16 deletions
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)); |