Bug 1152852 - Notification sound for highlights in chats not played if chat tab is selected, even when Thunderbird is not the currently focused application. r=clokep
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 14 Apr 2015 14:38:30 +0200
changeset 17747 1e8d5c907a77b0e6c8af6bedf849994df6046f5e
parent 17746 229d24ef55e9ed460458d31f5b770304180f615e
child 17748 4206a732aea5f710a9e74fb7648586116f0a7091
push id10930
push userarchaeopteryx@coole-files.de
push dateTue, 14 Apr 2015 12:38:53 +0000
treeherdercomm-central@1e8d5c907a77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep
bugs1152852
Bug 1152852 - Notification sound for highlights in chats not played if chat tab is selected, even when Thunderbird is not the currently focused application. r=clokep
mail/components/im/modules/chatNotifications.jsm
--- a/mail/components/im/modules/chatNotifications.jsm
+++ b/mail/components/im/modules/chatNotifications.jsm
@@ -38,17 +38,18 @@ var Notifications = {
   // Sender of the last message.
   _lastMessageSender: null,
   // timeout Id for the set timeout for showing notification.
   _timeoutId: null,
 
   _showMessageNotification: function(aMessage, aCounter = 0) {
     // We are about to show the notification, so let's play the notification sound.
     // We play the sound if the user is away from TB window or even away from chat tab.
-    if (Services.wm.getMostRecentWindow("mail:3pane").document
+    if (!Services.focus.activeWindow ||
+        Services.wm.getMostRecentWindow("mail:3pane").document
                 .getElementById("tabmail").currentTabInfo.mode.name != "chat")
       Services.obs.notifyObservers(aMessage, "play-chat-notification-sound", false);
 
     // If TB window has focus, there's no need to show the notification..
     if (Services.wm.getMostRecentWindow("mail:3pane").document.hasFocus()) {
       this._heldMessage = null;
       this._msgCounter = 0;
       return;