[PATCH 8/9] Change lastDeviceIdleTime to be per-device

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 13 22:47:25 PDT 2012


Preparation work for per-device idle counters.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xext/saver.c           |    7 +++++--
 Xext/sync.c            |    2 +-
 Xi/exevents.c          |    2 +-
 dix/events.c           |   13 +++++++------
 dix/globals.c          |    2 +-
 dix/window.c           |    4 +++-
 hw/kdrive/src/kinput.c |    3 ++-
 include/dix.h          |    3 +--
 include/dixstruct.h    |    2 +-
 os/WaitFor.c           |    2 +-
 os/xdmcp.c             |    2 +-
 11 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/Xext/saver.c b/Xext/saver.c
index 18d5e46..6f51073 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -47,6 +47,7 @@ in this Software without prior written authorization from the X Consortium.
 #include "cursorstr.h"
 #include "colormapst.h"
 #include "xace.h"
+#include "inputstr.h"
 #ifdef PANORAMIX
 #include "panoramiX.h"
 #include "panoramiXsrv.h"
@@ -414,8 +415,10 @@ ScreenSaverFreeSuspend (pointer value, XID id)
 	if (screenIsSaved != SCREEN_SAVER_ON)
 #endif
 	{
+	    DeviceIntPtr dev;
 	    UpdateCurrentTimeIf();
-	    lastDeviceEventTime = currentTime;
+	    nt_list_for_each_entry(dev, inputInfo.devices, next)
+		lastDeviceEventTime[dev->id] = currentTime;
 	    SetScreenSaverTimer();
 	}
     }
@@ -708,7 +711,7 @@ ProcScreenSaverQueryInfo (ClientPtr client)
     pPriv = GetScreenPrivate (pDraw->pScreen);
 
     UpdateCurrentTime ();
-    lastInput = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+    lastInput = GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds;
 
     rep.type = X_Reply;
     rep.length = 0;
diff --git a/Xext/sync.c b/Xext/sync.c
index 81f20db..13c9a91 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2741,7 +2741,7 @@ typedef struct {
 static void
 IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
 {
-    CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+    CARD32 idle = GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds;
     XSyncIntsToValue (pValue_return, idle, 0);
 }
 
diff --git a/Xi/exevents.c b/Xi/exevents.c
index f390f67..664aafb 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1642,7 +1642,7 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device)
             GetSpritePosition(device, &rootX, &rootY);
             event->root_x = rootX;
             event->root_y = rootY;
-            NoticeEventTime((InternalEvent*)event);
+            NoticeEventTime((InternalEvent*)event, device);
             event->corestate = corestate;
             key = event->detail.key;
             break;
diff --git a/dix/events.c b/dix/events.c
index 9244795..162f540 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1089,19 +1089,20 @@ MonthChangedOrBadTime(InternalEvent *ev)
 }
 
 static void
-NoticeTime(InternalEvent *ev)
+NoticeTime(InternalEvent *ev, DeviceIntPtr dev)
 {
     if (ev->any.time < currentTime.milliseconds)
         MonthChangedOrBadTime(ev);
     currentTime.milliseconds = ev->any.time;
-    lastDeviceEventTime = currentTime;
+    lastDeviceEventTime[XIAllDevices] = currentTime;
+    lastDeviceEventTime[dev->id] = currentTime;
 }
 
 void
-NoticeEventTime(InternalEvent *ev)
+NoticeEventTime(InternalEvent *ev, DeviceIntPtr dev)
 {
     if (!syncEvents.playingEvents)
-	NoticeTime(ev);
+	NoticeTime(ev, dev);
 }
 
 /**************************************************************************
@@ -1125,7 +1126,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);
+    NoticeTime((InternalEvent*)event, device);
 
     /* Fix for key repeating bug. */
     if (device->key != NULL && device->key->xkbInfo != NULL &&
@@ -5378,6 +5379,7 @@ InitEvents(void)
     for (i = 0; i < MAXDEVICES; i++)
     {
         memcpy(&event_filters[i], default_filter, sizeof(default_filter));
+        lastDeviceEventTime[i] = currentTime;
     }
 
     syncEvents.replayDev = (DeviceIntPtr)NULL;
@@ -5391,7 +5393,6 @@ InitEvents(void)
     syncEvents.time.milliseconds = 0;	/* hardly matters */
     currentTime.months = 0;
     currentTime.milliseconds = GetTimeInMillis();
-    lastDeviceEventTime = currentTime;
     for (i = 0; i < DNPMCOUNT; i++)
     {
 	DontPropagateMasks[i] = 0;
diff --git a/dix/globals.c b/dix/globals.c
index 0a6b170..6bd739c 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -120,7 +120,7 @@ Bool party_like_its_1989 = FALSE;
 Bool whiteRoot = FALSE;
 
 TimeStamp currentTime;
-TimeStamp lastDeviceEventTime;
+TimeStamp lastDeviceEventTime[MAXDEVICES];
 
 int defaultColorVisualClass = -1;
 int monitorResolution = 0;
diff --git a/dix/window.c b/dix/window.c
index 823294b..cf0a024 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3324,8 +3324,10 @@ dixSaveScreens(ClientPtr client, int on, int mode)
     screenIsSaved = what;
     if (mode == ScreenSaverReset) {
 	if (on == SCREEN_SAVER_FORCER) {
+	    DeviceIntPtr dev;
 	    UpdateCurrentTimeIf();
-	    lastDeviceEventTime = currentTime;
+	    nt_list_for_each_entry(dev, inputInfo.devices, next)
+		lastDeviceEventTime[dev->id] = currentTime;
 	}
 	SetScreenSaverTimer();
     }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 968ebb1..5690a16 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -339,7 +339,8 @@ KdEnableInput (void)
 
     /* reset screen saver */
     ev.any.time = GetTimeInMillis ();
-    NoticeEventTime (&ev);
+    NoticeEventTime (&ev, pi->dixdev);
+    NoticeEventTime (&ev, ki->dixdev);
 
     KdUnblockSigio ();
 }
diff --git a/include/dix.h b/include/dix.h
index f3f68d3..8a0a015 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -333,8 +333,7 @@ extern _X_EXPORT WindowPtr GetCurrentRootWindow(DeviceIntPtr pDev);
 
 extern _X_EXPORT WindowPtr GetSpriteWindow(DeviceIntPtr pDev);
 
-
-extern _X_EXPORT void NoticeEventTime(InternalEvent *ev);
+extern _X_EXPORT void NoticeEventTime(InternalEvent *ev, DeviceIntPtr dev);
 
 extern void EnqueueEvent(
     InternalEvent * /* ev */,
diff --git a/include/dixstruct.h b/include/dixstruct.h
index 0a85f40..5126adf 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -155,7 +155,7 @@ typedef struct _WorkQueue {
 }           WorkQueueRec;
 
 extern _X_EXPORT TimeStamp currentTime;
-extern _X_EXPORT TimeStamp lastDeviceEventTime;
+extern _X_EXPORT TimeStamp lastDeviceEventTime[MAXDEVICES];
 
 extern _X_EXPORT int CompareTimeStamps(
     TimeStamp /*a*/,
diff --git a/os/WaitFor.c b/os/WaitFor.c
index 867cb04..859b239 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -583,7 +583,7 @@ NextDPMSTimeout(INT32 timeout)
 static CARD32
 ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
 {
-    INT32 timeout      = now - lastDeviceEventTime.milliseconds;
+    INT32 timeout      = now - lastDeviceEventTime[XIAllDevices].milliseconds;
     CARD32 nextTimeout = 0;
 
 #ifdef DPMSExtension
diff --git a/os/xdmcp.c b/os/xdmcp.c
index 77f02da..a3ef47f 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -1430,7 +1430,7 @@ recv_alive_msg (unsigned length)
     	{
 	    /* backoff dormancy period */
 	    state = XDM_RUN_SESSION;
-	    if ((GetTimeInMillis() - lastDeviceEventTime.milliseconds) >
+	    if ((GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds) >
 		keepaliveDormancy * 1000)
 	    {
 		keepaliveDormancy <<= 1;
-- 
1.7.7.6



More information about the xorg-devel mailing list