From bbdc339af86551597aac9dd8f0136421ff496e15 Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Thu, 23 Feb 2006 17:02:45 +0000 Subject: [PATCH] Bug 179056 "Check for new message every" stops after hibernate. patch by Masatoshi Kimura (emk) r=emaijala+sfraser, sr=roc git-svn-id: svn://10.0.0.236/trunk@191035 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/windows/nsWindow.cpp | 32 +++++++++++++++++++++++++ mozilla/widget/src/windows/nsWindow.h | 2 ++ mozilla/xpcom/threads/TimerThread.cpp | 1 + 3 files changed, 35 insertions(+) diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index f777211d101..f35febd9255 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -71,6 +71,7 @@ #include "nsRect.h" #include "nsTransform2D.h" #include "nsIEventQueue.h" +#include "nsIObserverService.h" #include "imgIContainer.h" #include "gfxIImageFrame.h" #include "nsNativeCharsetUtils.h" @@ -3996,6 +3997,17 @@ void nsWindow::DispatchPendingEvents() } } +#ifndef WINCE +void nsWindow::PostSleepWakeNotification(const char* aNotification) +{ + nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1"); + if (observerService) + { + observerService->NotifyObservers(nsnull, aNotification, nsnull); + } +} +#endif + PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue) { static UINT vkKeyCached = 0; // caches VK code fon WM_KEYDOWN @@ -4115,6 +4127,26 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT } break; +#ifndef WINCE + case WM_POWERBROADCAST: + // only hidden window handle this + // to prevent duplicate notification + if (mWindowType == eWindowType_invisible) { + switch (wParam) + { + case PBT_APMSUSPEND: + PostSleepWakeNotification("sleep_notification"); + break; + case PBT_APMRESUMEAUTOMATIC: + case PBT_APMRESUMECRITICAL: + case PBT_APMRESUMESUSPEND: + PostSleepWakeNotification("wake_notification"); + break; + } + } + break; +#endif + case WM_MOVE: // Window moved { PRInt32 x = GET_X_LPARAM(lParam); // horizontal position in screen coordinates diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index 4dc9193ac7b..dba5d3e88f0 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -267,6 +267,8 @@ protected: static void RegisterSpecialDropdownHooks(); static void UnregisterSpecialDropdownHooks(); + + static void PostSleepWakeNotification(const char* aNotification); #endif static BOOL DealWithPopups (HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult); diff --git a/mozilla/xpcom/threads/TimerThread.cpp b/mozilla/xpcom/threads/TimerThread.cpp index a6d87ba2d88..1fc949cb0fb 100644 --- a/mozilla/xpcom/threads/TimerThread.cpp +++ b/mozilla/xpcom/threads/TimerThread.cpp @@ -428,6 +428,7 @@ void TimerThread::DoBeforeSleep() void TimerThread::DoAfterSleep() { + mSleeping = PR_TRUE; // wake may be notified without preceding sleep notification for (PRInt32 i = 0; i < mTimers.Count(); i ++) { nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl*, mTimers[i]); // get and set the delay to cause its timeout to be recomputed