Bug 795887 - Document sleep and process suspend notifications. r=roc

This commit is contained in:
Brian R. Bondy 2012-11-09 10:34:10 -05:00
parent a910a25dcf
commit de23937f9a
3 changed files with 27 additions and 3 deletions

View File

@ -76,7 +76,7 @@ static void ToolkitSleepWakeCallback(void *refCon, io_service_t service, natural
{
case kIOMessageSystemWillSleep:
// System is going to sleep now.
nsToolkit::PostSleepWakeNotification("sleep_notification");
nsToolkit::PostSleepWakeNotification(NS_WIDGET_SLEEP_OBSERVER_TOPIC);
::IOAllowPowerChange(gRootPort, (long)messageArgument);
break;
@ -91,7 +91,7 @@ static void ToolkitSleepWakeCallback(void *refCon, io_service_t service, natural
case kIOMessageSystemHasPoweredOn:
// Handle wakeup.
nsToolkit::PostSleepWakeNotification("wake_notification");
nsToolkit::PostSleepWakeNotification(NS_WIDGET_WAKE_OBSERVER_TOPIC);
break;
}

View File

@ -160,6 +160,29 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
eZPlacementTop // top of the window stack
};
/**
* Before the OS goes to sleep, this topic is notified.
*/
#define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
/**
* After the OS wakes up, this topic is notified.
*/
#define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
/**
* Before the OS suspends the current process, this topic is notified. Some
* OS will kill processes that are suspended instead of resuming them.
* For that reason this topic may be useful to safely close down resources.
*/
#define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
/**
* After the current process resumes from being suspended, this topic is
* notified.
*/
#define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
/**
* Preference for receiving IME updates
*

View File

@ -5549,7 +5549,8 @@ void nsWindow::PostSleepWakeNotification(const bool aIsSleepMode)
mozilla::services::GetObserverService();
if (observerService)
observerService->NotifyObservers(nullptr,
aIsSleepMode ? "sleep_notification" : "wake_notification", nullptr);
aIsSleepMode ? NS_WIDGET_SLEEP_OBSERVER_TOPIC :
NS_WIDGET_WAKE_OBSERVER_TOPIC, nullptr);
}
// RemoveNextCharMessage() should be called by WM_KEYDOWN or WM_SYSKEYDOWM