summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-10-16 09:36:01 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-10-16 14:24:35 +1000
commit5f0df5f532c1e91611e62c536990223cc40d734d (patch)
tree939f3d0e4bce891371d9d0f150639f610fcbe5cc
parent92805af8c5423e6dcd271da86be96ee685dec889 (diff)
dix: provide an accessor methods for the last device event time
And now that we have the accessors, localize it. No functional changes, just preparing for a future change. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--Xext/saver.c6
-rw-r--r--Xext/sync.c2
-rw-r--r--dix/events.c41
-rw-r--r--dix/globals.c1
-rw-r--r--dix/window.c4
-rw-r--r--include/dix.h5
-rw-r--r--include/dixstruct.h1
-rw-r--r--os/WaitFor.c2
-rw-r--r--os/xdmcp.c2
9 files changed, 41 insertions, 23 deletions
diff --git a/Xext/saver.c b/Xext/saver.c
index fe81bc4d7..e06f40837 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -392,9 +392,7 @@ ScreenSaverFreeSuspend(pointer value, XID id)
DeviceIntPtr dev;
UpdateCurrentTimeIf();
nt_list_for_each_entry(dev, inputInfo.devices, next)
- lastDeviceEventTime[dev->id] = currentTime;
- lastDeviceEventTime[XIAllDevices] = currentTime;
- lastDeviceEventTime[XIAllMasterDevices] = currentTime;
+ NoticeTime(dev, currentTime);
SetScreenSaverTimer();
}
}
@@ -681,7 +679,7 @@ ProcScreenSaverQueryInfo(ClientPtr client)
pPriv = GetScreenPrivate(pDraw->pScreen);
UpdateCurrentTime();
- lastInput = GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds;
+ lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds;
rep = (xScreenSaverQueryInfoReply) {
.type = X_Reply,
diff --git a/Xext/sync.c b/Xext/sync.c
index f8eb02a60..ed891b169 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2605,7 +2605,7 @@ IdleTimeQueryValue(pointer pCounter, CARD64 * pValue_return)
}
else
deviceid = XIAllDevices;
- idle = GetTimeInMillis() - lastDeviceEventTime[deviceid].milliseconds;
+ idle = GetTimeInMillis() - LastEventTime(deviceid).milliseconds;
XSyncIntsToValue(pValue_return, idle, 0);
}
diff --git a/dix/events.c b/dix/events.c
index 7a1b1c3c6..c803721f3 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -262,6 +262,8 @@ InputInfo inputInfo;
EventSyncInfoRec syncEvents;
+static TimeStamp lastDeviceEventTime[MAXDEVICES];
+
/**
* The root window the given device is currently on.
*/
@@ -1043,33 +1045,47 @@ XineramaGetCursorScreen(DeviceIntPtr pDev)
#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
static void
-MonthChangedOrBadTime(InternalEvent *ev)
+MonthChangedOrBadTime(CARD32 *ms)
{
/* If the ddx/OS is careless about not processing timestamped events from
* different sources in sorted order, then it's possible for time to go
* backwards when it should not. Here we ensure a decent time.
*/
- if ((currentTime.milliseconds - ev->any.time) > TIMESLOP)
+ if ((currentTime.milliseconds - *ms) > TIMESLOP)
currentTime.months++;
else
- ev->any.time = currentTime.milliseconds;
+ *ms = currentTime.milliseconds;
}
-static void
-NoticeTime(InternalEvent *ev, DeviceIntPtr dev)
+void
+NoticeTime(const DeviceIntPtr dev, TimeStamp time)
{
- if (ev->any.time < currentTime.milliseconds)
- MonthChangedOrBadTime(ev);
- currentTime.milliseconds = ev->any.time;
lastDeviceEventTime[XIAllDevices] = currentTime;
lastDeviceEventTime[dev->id] = currentTime;
}
+static void
+NoticeTimeMillis(const DeviceIntPtr dev, CARD32 *ms)
+{
+ TimeStamp time;
+ if (*ms < currentTime.milliseconds)
+ MonthChangedOrBadTime(ms);
+ time.months = currentTime.months;
+ time.milliseconds = *ms;
+ NoticeTime(dev, time);
+}
+
void
NoticeEventTime(InternalEvent *ev, DeviceIntPtr dev)
{
if (!syncEvents.playingEvents)
- NoticeTime(ev, dev);
+ NoticeTimeMillis(dev, &ev->any.time);
+}
+
+TimeStamp
+LastEventTime(int deviceid)
+{
+ return lastDeviceEventTime[deviceid];
}
/**************************************************************************
@@ -1093,7 +1109,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
if (!xorg_list_is_empty(&syncEvents.pending))
tail = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
- NoticeTime((InternalEvent *)event, device);
+ NoticeTimeMillis(device, &ev->any.time);
/* Fix for key repeating bug. */
if (device->key != NULL && device->key->xkbInfo != NULL &&
@@ -5276,8 +5292,11 @@ InitEvents(void)
inputInfo.pointer = (DeviceIntPtr) NULL;
for (i = 0; i < MAXDEVICES; i++) {
+ DeviceIntRec dummy;
memcpy(&event_filters[i], default_filter, sizeof(default_filter));
- lastDeviceEventTime[i] = currentTime;
+
+ dummy.id = i;
+ NoticeTime(&dummy, currentTime);
}
syncEvents.replayDev = (DeviceIntPtr) NULL;
diff --git a/dix/globals.c b/dix/globals.c
index 332b91f5c..ad9145b01 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -122,7 +122,6 @@ Bool party_like_its_1989 = FALSE;
Bool whiteRoot = FALSE;
TimeStamp currentTime;
-TimeStamp lastDeviceEventTime[MAXDEVICES];
int defaultColorVisualClass = -1;
int monitorResolution = 0;
diff --git a/dix/window.c b/dix/window.c
index cff341b65..92df1eb4c 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3089,9 +3089,7 @@ dixSaveScreens(ClientPtr client, int on, int mode)
DeviceIntPtr dev;
UpdateCurrentTimeIf();
nt_list_for_each_entry(dev, inputInfo.devices, next)
- lastDeviceEventTime[dev->id] = currentTime;
- lastDeviceEventTime[XIAllDevices] = currentTime;
- lastDeviceEventTime[XIAllMasterDevices] = currentTime;
+ NoticeTime(dev, currentTime);
}
SetScreenSaverTimer();
}
diff --git a/include/dix.h b/include/dix.h
index 171e56e11..fd2490fbd 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -315,8 +315,13 @@ extern _X_EXPORT WindowPtr
GetSpriteWindow(DeviceIntPtr pDev);
extern _X_EXPORT void
+NoticeTime(const DeviceIntPtr dev,
+ TimeStamp time);
+extern _X_EXPORT void
NoticeEventTime(InternalEvent *ev,
DeviceIntPtr dev);
+extern _X_EXPORT TimeStamp
+LastEventTime(int deviceid);
extern void
EnqueueEvent(InternalEvent * /* ev */ ,
diff --git a/include/dixstruct.h b/include/dixstruct.h
index 0be7f0e27..7711cde99 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -144,7 +144,6 @@ typedef struct _WorkQueue {
} WorkQueueRec;
extern _X_EXPORT TimeStamp currentTime;
-extern _X_EXPORT TimeStamp lastDeviceEventTime[MAXDEVICES];
extern _X_EXPORT int
CompareTimeStamps(TimeStamp /*a */ ,
diff --git a/os/WaitFor.c b/os/WaitFor.c
index 393890f19..c5f4cd78b 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -561,7 +561,7 @@ NextDPMSTimeout(INT32 timeout)
static CARD32
ScreenSaverTimeoutExpire(OsTimerPtr timer, CARD32 now, pointer arg)
{
- INT32 timeout = now - lastDeviceEventTime[XIAllDevices].milliseconds;
+ INT32 timeout = now - LastEventTime(XIAllDevices).milliseconds;
CARD32 nextTimeout = 0;
#ifdef DPMSExtension
diff --git a/os/xdmcp.c b/os/xdmcp.c
index 0538ac53e..11f11333d 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -1391,7 +1391,7 @@ recv_alive_msg(unsigned length)
if (SessionRunning && AliveSessionID == SessionID) {
/* backoff dormancy period */
state = XDM_RUN_SESSION;
- if ((GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds) >
+ if ((GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds) >
keepaliveDormancy * 1000) {
keepaliveDormancy <<= 1;
if (keepaliveDormancy > XDM_MAX_DORMANCY)