summaryrefslogtreecommitdiff
path: root/Xext
diff options
context:
space:
mode:
Diffstat (limited to 'Xext')
-rw-r--r--Xext/Makefile.am1
-rw-r--r--Xext/sync.c121
-rw-r--r--Xext/xcmisc.c13
-rw-r--r--Xext/xvmain.c8
-rw-r--r--Xext/xvmc.c2
5 files changed, 136 insertions, 9 deletions
diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index 6ea3d7445..d0d23b77f 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -34,7 +34,6 @@ MODULE_SRCS = \
xcmisc.c
# Extra configuration files ship with some extensions
-SERVERCONFIGdir = $(libdir)/xserver
SERVERCONFIG_DATA =
# Optional sources included if extension enabled by configure.ac rules
diff --git a/Xext/sync.c b/Xext/sync.c
index 531b48cc1..6fc2dcc7c 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -243,6 +243,11 @@ SyncInitServerTime(
void
);
+static void
+SyncInitIdleTime(
+ void
+);
+
static void
SyncResetProc(
ExtensionEntry * /* extEntry */
@@ -2400,6 +2405,7 @@ SyncExtensionInit(INITARGS)
* because there is always a servertime counter.
*/
SyncInitServerTime();
+ SyncInitIdleTime();
#ifdef DEBUG
fprintf(stderr, "Sync Extension %d.%d\n",
@@ -2509,7 +2515,7 @@ ServertimeBracketValues(pCounter, pbracket_less, pbracket_greater)
}
static void
-SyncInitServerTime()
+SyncInitServerTime(void)
{
CARD64 resolution;
@@ -2520,3 +2526,116 @@ SyncInitServerTime()
ServertimeQueryValue, ServertimeBracketValues);
pnext_time = NULL;
}
+
+
+
+/*
+ * IDLETIME implementation
+ */
+
+static pointer IdleTimeCounter;
+static XSyncValue *pIdleTimeValueLess;
+static XSyncValue *pIdleTimeValueGreater;
+
+static void
+IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
+{
+ CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+ XSyncIntsToValue (pValue_return, idle, 0);
+}
+
+static void
+IdleTimeBlockHandler (pointer env,
+ struct timeval **wt,
+ pointer LastSelectMask)
+{
+ XSyncValue idle;
+
+ if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+ return;
+
+ IdleTimeQueryValue (NULL, &idle);
+
+ if (pIdleTimeValueLess &&
+ XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
+ {
+ AdjustWaitForDelay (wt, 0);
+ }
+ else if (pIdleTimeValueGreater)
+ {
+ unsigned long timeout = 0;
+
+ if (XSyncValueLessThan (idle, *pIdleTimeValueGreater))
+ {
+ XSyncValue value;
+ Bool overflow;
+
+ XSyncValueSubtract (&value, *pIdleTimeValueGreater,
+ idle, &overflow);
+ timeout = XSyncValueLow32 (value);
+ }
+
+ AdjustWaitForDelay (wt, timeout);
+ }
+}
+
+static void
+IdleTimeWakeupHandler (pointer env,
+ int rc,
+ pointer LastSelectMask)
+{
+ XSyncValue idle;
+
+ if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+ return;
+
+ IdleTimeQueryValue (NULL, &idle);
+
+ if ((pIdleTimeValueGreater &&
+ XSyncValueGreaterThan (idle, *pIdleTimeValueGreater)) ||
+ (pIdleTimeValueLess && XSyncValueLessThan (idle, *pIdleTimeValueLess)))
+ {
+ SyncChangeCounter (IdleTimeCounter, idle);
+ }
+}
+
+static void
+IdleTimeBracketValues (pointer pCounter,
+ CARD64 *pbracket_less,
+ CARD64 *pbracket_greater)
+{
+ Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater);
+
+ if (registered && !pbracket_less && !pbracket_greater)
+ {
+ RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler,
+ IdleTimeWakeupHandler,
+ NULL);
+ }
+ else if (!registered && (pbracket_less || pbracket_greater))
+ {
+ RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler,
+ IdleTimeWakeupHandler,
+ NULL);
+ }
+
+ pIdleTimeValueGreater = pbracket_greater;
+ pIdleTimeValueLess = pbracket_less;
+}
+
+static void
+SyncInitIdleTime (void)
+{
+ CARD64 resolution;
+ XSyncValue idle;
+
+ IdleTimeQueryValue (NULL, &idle);
+ XSyncIntToValue (&resolution, 4);
+
+ IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution,
+ XSyncCounterUnrestricted,
+ IdleTimeQueryValue,
+ IdleTimeBracketValues);
+
+ pIdleTimeValueLess = pIdleTimeValueGreater = NULL;
+}
diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c
index f26218e97..8c7a86e6a 100644
--- a/Xext/xcmisc.c
+++ b/Xext/xcmisc.c
@@ -42,6 +42,12 @@ from The Open Group.
#include <X11/extensions/xcmiscstr.h>
#include "modinit.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
#if 0
static unsigned char XCMiscCode;
#endif
@@ -143,7 +149,10 @@ ProcXCMiscGetXIDList(client)
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
- pids = (XID *)ALLOCATE_LOCAL(stuff->count * sizeof(XID));
+ if (stuff->count > UINT32_MAX / sizeof(XID))
+ return BadAlloc;
+
+ pids = (XID *)Xalloc(stuff->count * sizeof(XID));
if (!pids)
{
return BadAlloc;
@@ -164,7 +173,7 @@ ProcXCMiscGetXIDList(client)
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
}
- DEALLOCATE_LOCAL(pids);
+ Xfree(pids);
return(client->noClientException);
}
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 22339011c..ddf3d1d6b 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -153,7 +153,7 @@ static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int);
*/
void
-XvExtensionInit()
+XvExtensionInit(void)
{
ExtensionEntry *extEntry;
@@ -205,7 +205,7 @@ XvExtensionInit()
}
static Bool
-CreateResourceTypes()
+CreateResourceTypes(void)
{
@@ -335,13 +335,13 @@ XvResetProc(ExtensionEntry* extEntry)
}
_X_EXPORT int
-XvGetScreenIndex()
+XvGetScreenIndex(void)
{
return XvScreenIndex;
}
_X_EXPORT unsigned long
-XvGetRTPort()
+XvGetRTPort(void)
{
return XvRTPort;
}
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 737fc5dfd..ae358936e 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -675,7 +675,7 @@ SProcXvMCDispatch (ClientPtr client)
}
void
-XvMCExtensionInit()
+XvMCExtensionInit(void)
{
ExtensionEntry *extEntry;