diff --git a/mozilla/mail/base/content/newmailalert.js b/mozilla/mail/base/content/newmailalert.js index 58d15221a1d..8dfdb862a80 100644 --- a/mozilla/mail/base/content/newmailalert.js +++ b/mozilla/mail/base/content/newmailalert.js @@ -36,6 +36,10 @@ * * ***** END LICENSE BLOCK ***** */ +const HORIZONTAL = 1; +const LEFT = 2; +const TOP = 4; + var gSlideTime = 50; var gNumNewMsgsToShowInAlert = 4; // the more messages we show in the alert, the larger it will be var gOpenTime = 3000; // total time the alert should stay up once we are done animating. @@ -43,6 +47,7 @@ var gAlertListener = null; var gPendingPreviewFetchRequests = 0; var gUserInitiated = false; var gFadeIncrement = .05; +var gOrigin = 0; function prefillAlertInfo() { @@ -51,9 +56,11 @@ function prefillAlertInfo() // arguments[1] --> the observer to call back with notifications about the alert // arguments[2] --> user initiated boolean. true if the user initiated opening the alert // (which means skip the fade effect and don't auto close the alert) + // arguments[3] --> the alert origin returned by the look and feel var foldersWithNewMail = window.arguments[0]; gAlertListener = window.arguments[1]; gUserInitiated = window.arguments[2]; + gOrigin = window.arguments[3]; // for now just grab the first folder which should be a root folder // for the account that has new mail. @@ -168,7 +175,13 @@ function resizeAlert(aMoveOffScreen) // leftover hack to get the window properly hidden when we first open it if (aMoveOffScreen) window.outerHeight = 1; - window.moveTo(screen.availLeft + screen.availWidth - window.outerWidth, screen.availTop + screen.availHeight - window.outerHeight); + + // Determine position and move window + var x = gOrigin & LEFT ? screen.availLeft : + (screen.availLeft + screen.availWidth - window.outerWidth); + var y = gOrigin & TOP ? screen.availTop : + (screen.availTop + screen.availHeight - window.outerHeight); + window.moveTo(x, y); } function fadeOpen() diff --git a/mozilla/mailnews/base/src/nsMessengerWinIntegration.cpp b/mozilla/mailnews/base/src/nsMessengerWinIntegration.cpp index 23e0e3ba722..cf19abf5cc1 100644 --- a/mozilla/mailnews/base/src/nsMessengerWinIntegration.cpp +++ b/mozilla/mailnews/base/src/nsMessengerWinIntegration.cpp @@ -23,6 +23,7 @@ * Seth Spitzer * Bhuvan Racham * Howard Chu + * Jens Bannmann * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -62,6 +63,8 @@ #include "nsIDocShell.h" #include "nsIBaseWindow.h" #include "nsIWidget.h" +#include "nsWidgetsCID.h" +#include "nsILookAndFeel.h" #include "nsIMessengerWindowService.h" #include "prprf.h" @@ -543,7 +546,8 @@ nsresult nsMessengerWinIntegration::ShowNewAlertNotification(PRBool aUserInitiat NS_ENSURE_SUCCESS(rv, rv); ifptr->SetData(mFoldersWithNewMail); ifptr->SetDataIID(&NS_GET_IID(nsISupportsArray)); - argsArray->AppendElement(ifptr); + rv = argsArray->AppendElement(ifptr); + NS_ENSURE_SUCCESS(rv, rv); // pass in the observer ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv); @@ -551,13 +555,31 @@ nsresult nsMessengerWinIntegration::ShowNewAlertNotification(PRBool aUserInitiat nsCOMPtr supports = do_QueryInterface(NS_STATIC_CAST(nsIMessengerOSIntegration*, this)); ifptr->SetData(supports); ifptr->SetDataIID(&NS_GET_IID(nsIObserver)); - argsArray->AppendElement(ifptr); + rv = argsArray->AppendElement(ifptr); + NS_ENSURE_SUCCESS(rv, rv); // pass in the animation flag nsCOMPtr scriptableUserInitiated (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); scriptableUserInitiated->SetData(aUserInitiated); - argsArray->AppendElement(scriptableUserInitiated); + rv = argsArray->AppendElement(scriptableUserInitiated); + NS_ENSURE_SUCCESS(rv, rv); + + // pass in the alert origin + nsCOMPtr scriptableOrigin (do_CreateInstance(NS_SUPPORTS_PRUINT8_CONTRACTID)); + NS_ENSURE_TRUE(scriptableOrigin, NS_ERROR_FAILURE); + scriptableOrigin->SetData(0); + nsCOMPtr lookAndFeel = do_GetService("@mozilla.org/widget/lookandfeel;1"); + if (lookAndFeel) + { + PRInt32 origin; + lookAndFeel->GetMetric(nsILookAndFeel::eMetric_AlertNotificationOrigin, + origin); + if (origin && origin >= 0 && origin <= 7) + scriptableOrigin->SetData(origin); + } + rv = argsArray->AppendElement(scriptableOrigin); + NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr newWindow;