Bug 1041667 - Fix positioning of the global webrtc sharing indicator if there are multiple screens, r=dolske.
--- a/browser/base/content/webrtcIndicator.js
+++ b/browser/base/content/webrtcIndicator.js
@@ -1,13 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-const Cu = Components.utils;
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/webrtcUI.jsm");
const BUNDLE_URL = "chrome://browser/locale/webrtcIndicator.properties";
let gStringBundle;
function init(event) {
gStringBundle = Services.strings.createBundle(BUNDLE_URL);
@@ -124,17 +124,22 @@ function onFirefoxButtonClick(event) {
}
let PositionHandler = {
positionCustomized: false,
threshold: 10,
adjustPosition: function() {
if (!this.positionCustomized) {
// Center the window horizontally on the screen (not the available area).
- window.moveTo((screen.width - document.documentElement.clientWidth) / 2, 0);
+ // Until we have moved the window to y=0, 'screen.width' may give a value
+ // for a secondary screen, so use values from the screen manager instead.
+ let width = {};
+ Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager)
+ .primaryScreen.GetRectDisplayPix({}, {}, width, {});
+ window.moveTo((width.value - document.documentElement.clientWidth) / 2, 0);
} else {
// This will ensure we're at y=0.
this.setXPosition(window.screenX);
}
},
setXPosition: function(desiredX) {
// Ensure the indicator isn't moved outside the available area of the screen.
let desiredX = Math.max(desiredX, screen.availLeft);