зеркало из https://github.com/mozilla/gecko-dev.git
bug 475361 - idle service for windows ce r=emaijala
This commit is contained in:
Родитель
9c763defb2
Коммит
5386f577fa
|
@ -43,14 +43,33 @@
|
|||
|
||||
NS_IMPL_ISUPPORTS1(nsIdleServiceWin, nsIIdleService)
|
||||
|
||||
|
||||
#ifdef WINCE
|
||||
// The last user input event time in microseconds. If there are any pending
|
||||
// native toolkit input events it returns the current time. The value is
|
||||
// compatible with PR_IntervalToMicroseconds(PR_IntervalNow()).
|
||||
// DEFINED IN widget/src/windows/nsWindow.cpp
|
||||
extern PRUint32 gLastInputEventTime;
|
||||
#endif
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIdleServiceWin::GetIdleTime(PRUint32 *aTimeDiff)
|
||||
{
|
||||
LASTINPUTINFO inputInfo;
|
||||
inputInfo.cbSize = sizeof(inputInfo);
|
||||
if (!::GetLastInputInfo(&inputInfo))
|
||||
return NS_ERROR_FAILURE;
|
||||
#ifndef WINCE
|
||||
LASTINPUTINFO inputInfo;
|
||||
inputInfo.cbSize = sizeof(inputInfo);
|
||||
if (!::GetLastInputInfo(&inputInfo))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aTimeDiff = GetTickCount() - inputInfo.dwTime;
|
||||
return NS_OK;
|
||||
*aTimeDiff = SAFE_COMPARE_EVEN_WITH_WRAPPING(GetTickCount(), inputInfo.dwTime);
|
||||
#else
|
||||
// NOTE: nowTime is not necessarily equivalent to GetTickCount() return value
|
||||
// we need to compare apples to apples - hence the nowTime variable
|
||||
PRUint32 nowTime = PR_IntervalToMicroseconds(PR_IntervalNow());
|
||||
|
||||
*aTimeDiff = SAFE_COMPARE_EVEN_WITH_WRAPPING(nowTime, gLastInputEventTime);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -43,11 +43,19 @@
|
|||
|
||||
#include "nsIdleService.h"
|
||||
|
||||
|
||||
/* NOTE: Compare of GetTickCount() could overflow. This corrects for
|
||||
* overflow situations.
|
||||
***/
|
||||
#ifndef SAFE_COMPARE_EVEN_WITH_WRAPPING
|
||||
#define SAFE_COMPARE_EVEN_WITH_WRAPPING(A, B) (((int)((long)A - (long)B) & 0xFFFFFFFF))
|
||||
#endif
|
||||
|
||||
|
||||
class nsIdleServiceWin : public nsIdleService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetIdleTime(PRUint32* idleTime);
|
||||
};
|
||||
|
||||
|
|
|
@ -455,7 +455,10 @@ static BYTE gLastMouseButton = 0;
|
|||
// The last user input event time in microseconds. If there are any pending
|
||||
// native toolkit input events it returns the current time. The value is
|
||||
// compatible with PR_IntervalToMicroseconds(PR_IntervalNow()).
|
||||
static PRUint32 gLastInputEventTime = 0;
|
||||
#ifdef WINCE
|
||||
static
|
||||
#endif
|
||||
PRUint32 gLastInputEventTime = 0;
|
||||
|
||||
static int gTrimOnMinimize = 2; // uninitialized, but still true
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче