Bug 472548 - Improves the nsIdleService on Maemo. r=gijskruitbosch, sr=stuart

This commit is contained in:
Doug Turner 2009-02-25 10:45:42 -08:00
Родитель d4fe8c73d7
Коммит 61521b6ca4
2 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -213,6 +213,19 @@ private:
};
#ifdef NS_OSSO
static void OssoDisplayCallback(osso_display_state_t state, gpointer data)
{
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
if (!os)
return;
if (state == OSSO_DISPLAY_ON)
os->NotifyObservers(nsnull, "system-display-on", nsnull);
else
os->NotifyObservers(nsnull, "system-display-dimmed-or-off", nsnull);
}
static void OssoHardwareCallback(osso_hw_state_t *state, gpointer data)
{
NS_ASSERTION(state, "osso_hw_state_t must not be null.");
@ -308,6 +321,14 @@ nsNativeAppSupportUnix::Start(PRBool *aRetVal)
OssoHardwareCallback,
&m_hw_state);
osso_hw_set_display_event_cb(m_osso_context,
OssoDisplayCallback,
nsnull);
#endif
*aRetVal = PR_TRUE;

Просмотреть файл

@ -47,8 +47,8 @@ nsIdleServiceOSSO::nsIdleServiceOSSO()
: mIdle(PR_FALSE)
{
nsCOMPtr<nsIObserverService> obsServ = do_GetService("@mozilla.org/observer-service;1");
obsServ->AddObserver(this, "system-idle", PR_FALSE);
obsServ->AddObserver(this, "system-active", PR_FALSE);
obsServ->AddObserver(this, "system-display-on", PR_FALSE);
obsServ->AddObserver(this, "system-display-dimmed-or-off", PR_FALSE);
}
nsIdleServiceOSSO::~nsIdleServiceOSSO()
@ -70,11 +70,11 @@ nsIdleServiceOSSO::GetIdleTime(PRUint32 *aTimeDiff)
NS_IMETHODIMP
nsIdleServiceOSSO::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{
if (!strcmp(aTopic, "system-idle")) {
if (!strcmp(aTopic, "system-display-dimmed-or-off") && mIdle == PR_FALSE) {
mIdle = PR_TRUE;
mIdleSince = PR_Now();
}
else if (!strcmp(aTopic, "system-active")) {
else if (!strcmp(aTopic, "system-display-on")) {
mIdle = PR_FALSE;
}