Open Bug 324570 Opened 19 years ago Updated 1 year ago

Make simultaneous notifications from alerts service work

Categories

(Toolkit :: Alerts Service, defect)

defect

Tracking

()

People

(Reporter: asqueella, Unassigned)

References

Details

A notification from alerts service looks like this: http://developer.mozilla.org/en/docs/nsIAlertsService If someone tries to display two notifications at a time, the second one overlaps the first. It's actually a Toolkit issue, but I'm filing it here because of lack of an appropriate component in Toolkit.
The problem with this is that it's not obvious what should UI be for multiple notifications. I had an idea of Google Talk-like notifications, which slide on top of each other (not sure I can explain that - http://frittle.org/webblog/images/59.jpg ). That requires all notifications be of the same width, which is not currently the case. It is possible to make them all have the same width, but that may change the look of existing Firefox notifications, and I'm not sure if it is fine.
I think this might be a good thing to take a look at for Firefox 3. The mac implementation (pending) already handles this properly, so other systems should too.
With the number of uses we are making of the alerts service now we are starting to see conflicting alerts (as in bug 412052). We might want to resolve this for Firefox 3
Flags: blocking-firefox3?
This does not block the final release of Firefox 3.
Flags: wanted-firefox3+
Flags: blocking-firefox3?
Flags: blocking-firefox3-
Component: General → XUL Widgets
Flags: wanted-firefox3+
Flags: blocking-firefox3-
Product: Firefox → Toolkit
QA Contact: general → xul.widgets
OS: Windows XP → All
Hardware: PC → All
This should be working with the XULAlerts implementation of the alerts service. See: Bug 782211 and https://hg.mozilla.org/mozilla-central/rev/d068e438438d
Depends on: 782211
Flags: needinfo?(asqueella)
Flags: needinfo?(archaeopteryx)
Whiteboard: [WORKSFORME?]
(In reply to Philip Chee from comment #7) > This should be working with the XULAlerts implementation of the alerts > service. Tried to call two notifications in two subsequent lines: Neither works for nsIAlertService nor for |new Notification| (single instance works).
Flags: needinfo?(archaeopteryx)
Yes, it still doesn't work, neither on Windows (XP), not on Mac (Mavericks): var alertsService = Components.classes["@mozilla.org/alerts-service;1"] .getService(Components.interfaces.nsIAlertsService); alertsService.showAlertNotification(null, "test", "test") alertsService.showAlertNotification(null, "test2", "test2")
Flags: needinfo?(asqueella)
Whiteboard: [WORKSFORME?]
I also tried to load the alert.xul directly, and still not work for TB 29 nightly, Win7. let win = Services.ww.openWindow(null, 'chrome://global/content/alerts/alert.xul', "_blank", 'chrome,titlebar=no,popup=yes', args); let win2 = Services.ww.openWindow(null, 'chrome://global/content/alerts/alert.xul', "_blank", 'chrome,titlebar=no,popup=yes', args); The issue is related with how alert.js calculate the position of the new alert window, eg with default settings, the new alert window will be moved to the end(top) of all the alert windows in function moveWindowToEnd(), but moveWindowToEnd expect all other alert windows was shown already, if not, the new alert window might be moved out of screen and can't be seen. If I change the line: y = Math.min(y, alertWindow.screenY - window.outerHeight); to if ( alertWindow.screenY > window.outerHeight ) { y = Math.min(y, alertWindow.screenY - window.outerHeight); } Then all the alert windows will show correctly ( for default setting that gReplacedWindow is null and gOrigin is 0 ). The same issue might also exists in moveWindowToReplace() / onAlertBeforeUnload() .
William Chen, could you comment on Comment 10 as you are the author of the code referenced? Thank you.
Flags: needinfo?(wchen)
If you are using the nsIAlertsService, you need to give your notifications a unique name. http://dxr.mozilla.org/mozilla-central/source/toolkit/components/alerts/nsIAlertsService.idl#61 With the web notifications API, it will show multiple notification simultaneously by default, but Notification with the same tag will only display a single notification. http://notifications.spec.whatwg.org/#tags-example
Flags: needinfo?(wchen)
(In reply to William Chen [:wchen] from comment #12) > If you are using the nsIAlertsService, you need to give your notifications a > unique name. Tried and not works, as I said in comment 10, the alert windows are there but can't be seen because they were moved out of the screen. let alertsService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService); let cookie = Date.now(); alertsService.showAlertNotification('', 'title1', 'msg1', true, cookie, null, cookie); cookie = Date.now(); // with the below line, nothing will shown, comments the below line, will show one alert window alertsService.showAlertNotification('', 'title2', 'msg2', true, cookie, null, cookie);
Flags: needinfo?(wchen)
Here's a workaround (for both Linux and Windows): Use gBrowser to open a plain (skeleton) HTML file. Then fill in that document with your message: var newTab= window.gBrowser.selectedTab = window.gBrowser.addTab( 'chrome://your-extension/content/extensions/message.html' ); var newTabBrowser = window.gBrowser.getBrowserForTab( newTab ); newTabBrowser.addEventListener( "load", function () { newTabBrowser.contentDocument.body.innerHTML= message; }, true ); If you need to do that when your XPI is loaded (e.g. from an overlay of browser.xul), it seems to require a delay, e.g.: window.setTimeout( function() { // all from the above }, 3000 );
Blocks: 1083558
Is this still reproducible?
Flags: needinfo?(wchen)
Yes, this still reproduces with the code from comment 9 in latest Nightly on Windows 8.1. You can see a shadow line (for me in the top left corner) if you try to show two notifications. Clicking on the shadow closes it. If only one notification gets requested, it works as expected.
I confirm this bug.
Severity: normal → S3

The severity field for this bug is relatively low, S3. However, the bug has 5 duplicates.
:tspurway, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(tspurway)
Flags: needinfo?(tspurway)
Component: Notifications and Alerts → Alerts Service
You need to log in before you can comment on or make changes to this bug.