summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-05-27 23:14:26 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-05-27 23:14:26 (GMT)
commit99166f48dd544d3fef849683b0b40175d7238547 (patch)
tree628e1802dd6cb304781edf0f4c92998bc0d943cf /macosx
parent1c838522c0b377c7567543d50640f9290e506db4 (diff)
downloadtk-99166f48dd544d3fef849683b0b40175d7238547.zip
tk-99166f48dd544d3fef849683b0b40175d7238547.tar.gz
tk-99166f48dd544d3fef849683b0b40175d7238547.tar.bz2
Partial implementation of TIP#245; thanks Reinhard!
Diffstat (limited to 'macosx')
-rw-r--r--macosx/Wish.pbproj/project.pbxproj33
-rw-r--r--macosx/tkMacOSXXStubs.c97
2 files changed, 129 insertions, 1 deletions
diff --git a/macosx/Wish.pbproj/project.pbxproj b/macosx/Wish.pbproj/project.pbxproj
index 2a4def9..6f960ea 100644
--- a/macosx/Wish.pbproj/project.pbxproj
+++ b/macosx/Wish.pbproj/project.pbxproj
@@ -101,6 +101,36 @@
//4C2
//4C3
//4C4
+//950
+//951
+//952
+//953
+//954
+ 95911CC7081532D8006F6BCB = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = IOKit.framework;
+ path = /System/Library/Frameworks/IOKit.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+ 95911CC8081532D8006F6BCB = {
+ fileRef = 95911CC7081532D8006F6BCB;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 95911CC9081532D8006F6BCB = {
+ fileRef = 95911CC7081532D8006F6BCB;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+//950
+//951
+//952
+//953
+//954
//F50
//F51
//F52
@@ -2167,6 +2197,7 @@ Initial MacOS X Port by Jim Ingham &lt;jingham@apple.com&gt; &amp; Ian Reid, Cop
files = (
F537567E016C3ADB01DC9062,
F50D96130196176E01DC9062,
+ 95911CC9081532D8006F6BCB,
);
isa = PBXFrameworksBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -3075,6 +3106,7 @@ Initial MacOS X Port by Jim Ingham &lt;jingham@apple.com&gt; &amp; Ian Reid, Cop
};
F537567C016C3ADB01DC9062 = {
children = (
+ 95911CC7081532D8006F6BCB,
F50D96120196176E01DC9062,
F5875C7B016FEF1D01DC9062,
F537567D016C3ADB01DC9062,
@@ -3427,6 +3459,7 @@ Initial MacOS X Port by Jim Ingham &lt;jingham@apple.com&gt; &amp; Ian Reid, Cop
F53756A7016C4DD401DC9062,
F50D96140196176E01DC9062,
F5877FB9031F9F49016F146B,
+ 95911CC8081532D8006F6BCB,
);
isa = PBXFrameworksBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index 892b4fc..d79cf12 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.9 2005/05/15 21:09:34 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.10 2005/05/27 23:14:29 dkf Exp $
*/
#include "tkInt.h"
@@ -30,6 +30,8 @@
#include "tkPort.h"
#include "tkMacOSXEvent.h"
+#include <IOKit/IOKitLib.h>
+
/*
* Because this file is still under major development Debugger statements are
* used through out this file. The define TCL_DEBUG will decide whether
@@ -967,3 +969,96 @@ TkGetDefaultScreenName(
#endif
return macScreenName;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tk_GetUserInactiveTime --
+ *
+ * Return the number of milliseconds the user was inactive.
+ *
+ * Results:
+ * The number of milliseconds the user has been inactive,
+ * or -1 if querying the inactive time is not supported.
+ *
+ * Side effects:
+ * None.
+ *----------------------------------------------------------------------
+ */
+
+long
+Tk_GetUserInactiveTime(Display *dpy)
+{
+ io_registry_entry_t regEntry;
+ CFMutableDictionaryRef props = NULL;
+ CFTypeRef timeObj;
+ long ret = -1l;
+ uint64_t time;
+
+ regEntry = IOServiceGetMatchingService(kIOMasterPortDefault,
+ IOServiceMatching("IOHIDSystem"));
+
+ if (regEntry == NULL) {
+ return -1l;
+ }
+
+ IOReturn result = IORegistryEntryCreateCFProperties(regEntry, &props,
+ kCFAllocatorDefault, 0);
+ IOObjectRelease(regEntry);
+
+ if (result != KERN_SUCCESS || props == NULL) {
+ return -1l;
+ }
+
+ timeObj = CFDictionaryGetValue(props, CFSTR("HIDIdleTime"));
+
+ if (timeObj) {
+ CFRetain(timeObj);
+ CFTypeID type = CFGetTypeID(timeObj);
+
+ if (type == CFDataGetTypeID()) { /* Jaguar */
+ CFDataGetBytes((CFDataRef) timeObj,
+ CFRangeMake(0, sizeof(time)), (UInt8 *) &time);
+ /* Convert nanoseconds to milliseconds. */
+ /* ret /= kMillisecondScale; */
+ ret = (long)(time/kMillisecondScale);
+ } else if (type == CFNumberGetTypeID()) { /* Panther+ */
+ CFNumberGetValue((CFNumberRef)timeObj,
+ kCFNumberSInt64Type, &time);
+ /* Convert nanoseconds to milliseconds. */
+ /* ret /= kMillisecondScale; */
+ ret = (long)(time/kMillisecondScale);
+ } else {
+ ret = -1l;
+ }
+
+ CFRelease(timeObj);
+ }
+ /* Cleanup */
+ CFRelease(props);
+
+ return ret;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tk_ResetUserInactiveTime --
+ *
+ * Reset the user inactivity timer
+ *
+ * Results:
+ * none
+ *
+ * Side effects:
+ * The user inactivity timer of the underlaying windowing system
+ * is reset to zero.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+Tk_ResetUserInactiveTime(Display *dpy)
+{
+ UpdateSystemActivity(0);
+}