mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 19:07:31 +09:00
Notifications - Run (Desktop) Notifications twice (and more) in a row does not work
This commit is contained in:
parent
41f567ee97
commit
c066de6ba2
2 changed files with 27 additions and 2 deletions
|
|
@ -7,7 +7,21 @@ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
// Copied from nsILookAndFeel.h, see comments on eMetric_AlertNotificationOrigin
|
/*
|
||||||
|
* This indicates from which corner of the screen alerts slide in,
|
||||||
|
* and from which direction (horizontal/vertical).
|
||||||
|
* 0, the default, represents bottom right, sliding vertically.
|
||||||
|
* Use any bitwise combination of the following constants:
|
||||||
|
* NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
|
||||||
|
*
|
||||||
|
* 6 4
|
||||||
|
* +-----------+
|
||||||
|
* 7| |5
|
||||||
|
* | |
|
||||||
|
* 3| |1
|
||||||
|
* +-----------+
|
||||||
|
* 2 0
|
||||||
|
*/
|
||||||
const NS_ALERT_HORIZONTAL = 1;
|
const NS_ALERT_HORIZONTAL = 1;
|
||||||
const NS_ALERT_LEFT = 2;
|
const NS_ALERT_LEFT = 2;
|
||||||
const NS_ALERT_TOP = 4;
|
const NS_ALERT_TOP = 4;
|
||||||
|
|
@ -41,6 +55,8 @@ function prefillAlertInfo() {
|
||||||
// arguments[11] -> the nsIURI.hostPort of the origin, optional
|
// arguments[11] -> the nsIURI.hostPort of the origin, optional
|
||||||
// arguments[12] -> the alert icon URL, optional
|
// arguments[12] -> the alert icon URL, optional
|
||||||
|
|
||||||
|
document.getElementById('alertTime').setAttribute('value', (new Date).getTime());
|
||||||
|
|
||||||
switch (window.arguments.length) {
|
switch (window.arguments.length) {
|
||||||
default:
|
default:
|
||||||
case 13: {
|
case 13: {
|
||||||
|
|
@ -235,7 +251,15 @@ function moveWindowToEnd() {
|
||||||
let windows = Services.wm.getEnumerator("alert:alert");
|
let windows = Services.wm.getEnumerator("alert:alert");
|
||||||
while (windows.hasMoreElements()) {
|
while (windows.hasMoreElements()) {
|
||||||
let alertWindow = windows.getNext();
|
let alertWindow = windows.getNext();
|
||||||
if (alertWindow != window) {
|
let alertWindowTime = Number(
|
||||||
|
alertWindow.document.getElementById('alertTime').getAttribute('value'));
|
||||||
|
let windowTime = Number(
|
||||||
|
window.document.getElementById('alertTime').getAttribute('value'));
|
||||||
|
// The time of window creation.
|
||||||
|
// Otherwise calling the notification twice (and more) in a row
|
||||||
|
// does not work.
|
||||||
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1263155
|
||||||
|
if ((alertWindow != window) && (alertWindowTime <= windowTime)) {
|
||||||
if (gOrigin & NS_ALERT_TOP) {
|
if (gOrigin & NS_ALERT_TOP) {
|
||||||
y = Math.max(y, alertWindow.screenY + alertWindow.outerHeight - WINDOW_SHADOW_SPREAD);
|
y = Math.max(y, alertWindow.screenY + alertWindow.outerHeight - WINDOW_SHADOW_SPREAD);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
<script type="application/javascript" src="chrome://global/content/alerts/alert.js"/>
|
<script type="application/javascript" src="chrome://global/content/alerts/alert.js"/>
|
||||||
|
|
||||||
<vbox id="alertBox" class="alertBox">
|
<vbox id="alertBox" class="alertBox">
|
||||||
|
<label id="alertTime" value="" hidden="true"/>
|
||||||
<box id="alertTitleBox">
|
<box id="alertTitleBox">
|
||||||
<image id="alertIcon"/>
|
<image id="alertIcon"/>
|
||||||
<label id="alertTitleLabel" class="alertTitle plain" crop="end"/>
|
<label id="alertTitleLabel" class="alertTitle plain" crop="end"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue