user1256960
user1256960

Reputation: 303

Firefox extension detect windows taskbar position

I am developing a firefox extension and I use a xul:panel. I want to position it on right-bottom, but i don't want to be under the windows taskbar. I use openPopupAtScreen and screen coordinates to position it My problem is when the user has the windows taskbar on the right of the screen, vertical. The my panel is under the taskbar. Is there any way to detect the taskbar position or an workaround to draw it according to that?

Upvotes: 2

Views: 227

Answers (1)

Wladimir Palant
Wladimir Palant

Reputation: 57681

You should use nsIScreenManager for that:

var screenManager = Components.classes["@mozilla.org/gfx/screenmanager;1"]
                              .getService(Components.interfaces.nsIScreenManager);
var screen = screenManager.primaryScreen;
var left = {};
var top = {};
var width = {};
var height = {};
screen.GetAvailRect(left, top, width, height);
alert("Available screen area: " + left.value + "," + top.value + " x " +
      width.value + "," + height.value);

Please note that this is looking at the primary screen only - which might not be the best solution if the user has more than one screen. One alternative would be getting the screen that corresponds with the coordinates of the Firefox window you are running in and then looking at its available area.

Upvotes: 2

Related Questions