In my Firefox extension, I am trying to track when a window is actually an active window. To do this, I add the following two listeners to the window:
window.addEventListener("deactivate", function(event) { alert("deactivate"); }, false); window.addEventListener("activate", function(event) { alert("activate"); }, false);
In principle, everything is working fine. When I switch between different windows or minimize / maximize Firefox, events fire as I expected. However, both events also fire when I move the window, even if it is already active. When I start moving the window, the “deactivate” event occurs; when I stop moving and release the mouse button, the activate event is activated. I have no idea how I can detect and ignore this behavior. Intuitively the window is actively working.
I tried to check before handling the “deactivate” event if the mouse button is clicked. However, adding a click event to the window does not include the window title bar. Any idea how I can tell if "really" deactivate the window and move the window? Thank you very much in advance!
source share