Bug 1735458 - Do not show mail notification on Windows if running fullscreen app. r=mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D128427

--HG--
extra : amend_source : db4b4e7c3baca7329e40eb02ac9918d1961baaf4
This commit is contained in:
Ping Chen 2021-10-15 13:10:04 +03:00
Родитель df19d1a041
Коммит c2be3c081e
3 изменённых файлов: 22 добавлений и 1 удалений

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

@ -13,4 +13,7 @@ interface nsIMessengerWindowsIntegration : nsIMessengerOSIntegration {
void hideWindow(in nsIBaseWindow aWindow); void hideWindow(in nsIBaseWindow aWindow);
void showWindow(in mozIDOMWindowProxy aWindow); void showWindow(in mozIDOMWindowProxy aWindow);
/** Do not show notifications in some states, e.g. when running a fullscreen app. */
readonly attribute boolean suppressNotification;
}; };

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

@ -77,6 +77,7 @@ class MailNotificationManager {
if (AppConstants.platform == "win") { if (AppConstants.platform == "win") {
Services.obs.addObserver(this, "windows-refresh-badge-tray"); Services.obs.addObserver(this, "windows-refresh-badge-tray");
Services.prefs.addObserver("mail.biff.show_badge", this); Services.prefs.addObserver("mail.biff.show_badge", this);
this._osIntegration.QueryInterface(Ci.nsIMessengerWindowsIntegration);
} }
} }
@ -133,6 +134,12 @@ class MailNotificationManager {
if (!Services.prefs.getBoolPref("mail.biff.show_alert")) { if (!Services.prefs.getBoolPref("mail.biff.show_alert")) {
return; return;
} }
if (
AppConstants.platform == "win" &&
this._osIntegration.suppressNotification
) {
return;
}
this._logger.debug( this._logger.debug(
`onFolderIntPropertyChanged; property=${property}: ${oldValue} => ${newValue}, folder.URI=${folder.URI}` `onFolderIntPropertyChanged; property=${property}: ${oldValue} => ${newValue}, folder.URI=${folder.URI}`
@ -166,7 +173,7 @@ class MailNotificationManager {
} }
/** /**
* Show an alert according the changed folder. * Show an alert according to the changed folder.
* @param {nsIMsgFolder} changedFolder - The folder that emitted the change * @param {nsIMsgFolder} changedFolder - The folder that emitted the change
* event, can be a root folder or a real folder. * event, can be a root folder or a real folder.
*/ */

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

@ -226,6 +226,17 @@ nsMessengerWinIntegration::ShowWindow(mozIDOMWindowProxy* aWindow) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsMessengerWinIntegration::GetSuppressNotification(bool* suppressNotification) {
*suppressNotification = false;
QUERY_USER_NOTIFICATION_STATE qstate;
if (SUCCEEDED(SHQueryUserNotificationState(&qstate)) &&
qstate != QUNS_ACCEPTS_NOTIFICATIONS) {
*suppressNotification = true;
}
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsMessengerWinIntegration::UpdateUnreadCount(uint32_t unreadCount, nsMessengerWinIntegration::UpdateUnreadCount(uint32_t unreadCount,
const nsAString& unreadTooltip) { const nsAString& unreadTooltip) {