summaryrefslogtreecommitdiffstats
path: root/chrome/browser/idle_mac.cc
blob: 383e4c766db273af1f59944df39b6a6cbb4fdf45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/idle.h"

#include <CoreGraphics/CGEventSource.h>

IdleState CalculateIdleState(unsigned int idle_threshold) {
  unsigned int idle_time = CGEventSourceSecondsSinceLastEventType(
     kCGEventSourceStateCombinedSessionState,
     kCGAnyInputEventType);
  if (idle_time >= idle_threshold)
    return IDLE_STATE_IDLE;
  return IDLE_STATE_ACTIVE;
}