diff --git a/widget/cocoa/nsToolkit.mm b/widget/cocoa/nsToolkit.mm index 5b63e074fa2..84d97fd3b48 100644 --- a/widget/cocoa/nsToolkit.mm +++ b/widget/cocoa/nsToolkit.mm @@ -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; } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 0c1c84500cf..f6f9791827f 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -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 * diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 1f11854f12c..5e64e4a1128 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -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