Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to keep track of the state of a Firefox window ("maximized", "minimized", "normal", "fullscreen"; see here). However, whatever I've tried, I never get to see the minimized event; the others doing fine. For example, if I add listeners to the window such as

window.addEventListener("activate", function(event) { dump("activate " + window.windowState + " " + window.screenX + " " + window.screenY + "
"); }, false);
window.addEventListener("deactivate", function(event) { dump("deactivate " + window.windowState + " " + window.screenX + " " + window.screenY + "
"); }, false);
window.addEventListener("resize", function(event) { dump("resize " + window.windowState + " " + window.screenX + " " + window.screenY + "
"); }, false);

I never see 2 as the window.windowState (2 = STATE_MINIMIZED). I've tried a workaround using screenX and screenY, but that doesn't help. When I minimize the window the deactivate - not the resize - event fires with window.windowState being 3 (STATE_NORMAL) and the old screenX/screenY values.

Is there any way to detect when the Firefox window is being minimized? I'm at my wits' end.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
361 views
Welcome To Ask or Share your Answers For Others

1 Answer

You should be listening to the sizemodechange event. That's the event firing after the window is minimized or maximized. The resize event doesn't fire for window minimization because technically the window isn't resized - it is hidden. And the deactivate event likely fires before the window is minimized, when it still has the normal state (I didn't check however).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...