src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java

Print this page

        

*** 37,46 **** --- 37,47 ---- public class CEmbeddedFrame extends EmbeddedFrame { private CPlatformResponder responder; private static final Object classLock = new Object(); private static volatile CEmbeddedFrame focusedWindow; + private CEmbeddedFrame previousFocusedWindow; private boolean parentWindowActive = true; public CEmbeddedFrame() { show(); }
*** 143,152 **** --- 144,172 ---- // handleWindowFocusEvent is called for all applets, when the browser // becomes active/inactive. This event should be filtered out for // non-focused applet. This method can be called from different threads. public void handleWindowFocusEvent(boolean parentWindowActive) { this.parentWindowActive = parentWindowActive; + // If several applets are running in different browser's windows, it is necessary to + // detect the switching between the parent windows and update focusedWindow accordingly. + synchronized (classLock) { + if (!parentWindowActive) { + this.previousFocusedWindow = focusedWindow; + } + if (parentWindowActive && focusedWindow != this && + (focusedWindow == null || (focusedWindow != null && !focusedWindow.isParentWindowActive()))) { + // It looks like we have switched to another browser window, let's restore focus to + // the previously focused applet in this window. + if (this.previousFocusedWindow != null) { + focusedWindow = this.previousFocusedWindow; + } else { + // No applets were focused in this window, so set focus to the first + // applet in the window + focusedWindow = this; + } + } + } // ignore focus "lost" native request as it may mistakenly // deactivate active window (see 8001161) if (focusedWindow == this && parentWindowActive) { responder.handleWindowFocusEvent(parentWindowActive, null); }