Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Discovering if Firefox window has focus.

17 views
Skip to first unread message

pgdan...@googlemail.com

unread,
Dec 3, 2007, 12:17:13 PM12/3/07
to
As far as I can tell, there is no way to determine whether or not a
Firefox window has focus:

nsIXULWindow -> docShell.hasFocus
Returns true only if there is more than one Firefox window open, and
the given window has focus within the Firefox application (ie it is on
top of other Firefox windows). The window itself may or may not have
focus from the OS.

document.commandDispatcher.focusedWindow
Returns an nsIDOMWindow regardless of whether Firefox itself is
focused or not (same as above).

window.getAttribute("sizemode")
Correctly returns "normal" and "maximized", but never
"minimized" (although it should).

Does anyone have any ideas? My end goal is to produce a system alert
(nsIAlertsService) only when the user is away from the browser window.

Neil

unread,
Dec 3, 2007, 1:07:51 PM12/3/07
to
pgdan...@googlemail.com wrote:

>Does anyone have any ideas? My end goal is to produce a system alert (nsIAlertsService) only when the user is away from the browser window.
>
>

That doesn't sound very useful. Maybe you should just use getAttention()?

--
Warning: May contain traces of nuts.

pgdan...@googlemail.com

unread,
Dec 4, 2007, 11:39:07 AM12/4/07
to
On Dec 3, 6:07 pm, Neil <n...@parkwaycc.co.uk> wrote:
> That doesn't sound very useful. Maybe you should just use getAttention()?

Thank you; I am using getAttention() already. The problem here is
different --- I don't want to bother the user with detailed
information in a system alert. If the user has the browser window
focused, he gets a detailed notification in the browser UI. The
system alert is to inform him of the general nature of the
notification, but the details are left for him to refer to in the
browser window. I don't want the system alert appearing when he's
already using the browser, because then the information pops up in two
places, and it all gets a bit overwhelming...

0 new messages