summaryrefslogtreecommitdiffstats
path: root/chrome/browser/idle_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/idle_mac.mm')
-rw-r--r--chrome/browser/idle_mac.mm14
1 files changed, 11 insertions, 3 deletions
diff --git a/chrome/browser/idle_mac.mm b/chrome/browser/idle_mac.mm
index d13da03..8547ff5 100644
--- a/chrome/browser/idle_mac.mm
+++ b/chrome/browser/idle_mac.mm
@@ -50,7 +50,7 @@
}
- (void)dealloc {
- [[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
+ [[NSDistributedNotificationCenter defaultCenter] removeObject:self];
[super dealloc];
}
@@ -84,11 +84,19 @@ void StopIdleMonitor() {
g_screenMonitor = nil;
}
-void CalculateIdleTime(IdleTimeCallback notify) {
+void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
+ if (CheckIdleStateIsLocked()) {
+ notify.Run(IDLE_STATE_LOCKED);
+ return;
+ }
+
CFTimeInterval idle_time = CGEventSourceSecondsSinceLastEventType(
kCGEventSourceStateCombinedSessionState,
kCGAnyInputEventType);
- notify.Run(static_cast<int>(idle_time));
+ if (idle_time >= idle_threshold)
+ notify.Run(IDLE_STATE_IDLE);
+ else
+ notify.Run(IDLE_STATE_ACTIVE);
}
bool CheckIdleStateIsLocked() {