widget/windows/nsIdleServiceWin.cpp
author Gregory Szorc <gps@mozilla.com>
Wed, 28 Jan 2015 13:37:00 -0800
branchGECKO150_2012082116_RELBRANCH
changeset 120236 ad02f479b381c40651355b13806cf8ee08761ccd
parent 98529 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 102739 b405f493e834918e5513731d96975e1de7b5bbeb
permissions -rw-r--r--
Close old release branch GECKO150_2012082116_RELBRANCH

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
 */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsIdleServiceWin.h"
#include <windows.h>

NS_IMPL_ISUPPORTS2(nsIdleServiceWin, nsIIdleService, nsIdleService)

bool
nsIdleServiceWin::PollIdleTime(PRUint32 *aIdleTime)
{
    LASTINPUTINFO inputInfo;
    inputInfo.cbSize = sizeof(inputInfo);
    if (!::GetLastInputInfo(&inputInfo))
        return false;

    *aIdleTime = SAFE_COMPARE_EVEN_WITH_WRAPPING(GetTickCount(), inputInfo.dwTime);

    return true;
}

bool
nsIdleServiceWin::UsePollMode()
{
    return true;
}