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

Print this page

        

*** 36,46 **** import java.awt.event.*; public class CEmbeddedFrame extends EmbeddedFrame { private CPlatformResponder responder; ! private boolean focused = true; private boolean parentWindowActive = true; public CEmbeddedFrame() { show(); } --- 36,47 ---- import java.awt.event.*; public class CEmbeddedFrame extends EmbeddedFrame { private CPlatformResponder responder; ! private static final Object classLock = new Object(); ! private static volatile CEmbeddedFrame focusedWindow; private boolean parentWindowActive = true; public CEmbeddedFrame() { show(); }
*** 108,120 **** public void handleInputEvent(String text) { responder.handleInputEvent(text); } public void handleFocusEvent(boolean focused) { ! this.focused = focused; ! if (focused) { // see bug 8010925 // we can't put this to handleWindowFocusEvent because // it won't be invoced if focuse is moved to a html element // on the same page. CClipboard clipboard = (CClipboard) Toolkit.getDefaultToolkit().getSystemClipboard(); --- 109,128 ---- public void handleInputEvent(String text) { responder.handleInputEvent(text); } + // handleFocusEvent is called when the applet becames focused/unfocused. + // This method can be called from different threads. public void handleFocusEvent(boolean focused) { ! synchronized (classLock) { ! // In some cases an applet may not receive the focus lost event ! // from the parent window (see 8012330) ! focusedWindow = (focused) ? this ! : ((focusedWindow == this) ? null : focusedWindow); ! } ! if (focusedWindow == this) { // see bug 8010925 // we can't put this to handleWindowFocusEvent because // it won't be invoced if focuse is moved to a html element // on the same page. CClipboard clipboard = (CClipboard) Toolkit.getDefaultToolkit().getSystemClipboard();
*** 124,133 **** --- 132,145 ---- responder.handleWindowFocusEvent(focused, null); } } /** + * handleWindowFocusEvent is called for all applets, when the browser + * becames active/inactive. This event should be filtered out for + * non-focused applet. This method can be called from different threads. + * * When the window is activated and had focus before the deactivation * calling this method triggers focus events in the following order: * 1. WINDOW_ACTIVATED for this EmbeddedFrame * 2. WINDOW_GAINED_FOCUS for this EmbeddedFrame * 3. FOCUS_GAINED for the most recent focus owner in this EmbeddedFrame
*** 138,148 **** */ public void handleWindowFocusEvent(boolean parentWindowActive) { this.parentWindowActive = parentWindowActive; // ignore focus "lost" native request as it may mistakenly // deactivate active window (see 8001161) ! if (focused && parentWindowActive) { responder.handleWindowFocusEvent(parentWindowActive, null); } } public boolean isParentWindowActive() { --- 150,160 ---- */ public void handleWindowFocusEvent(boolean parentWindowActive) { this.parentWindowActive = parentWindowActive; // ignore focus "lost" native request as it may mistakenly // deactivate active window (see 8001161) ! if (focusedWindow == this && parentWindowActive) { responder.handleWindowFocusEvent(parentWindowActive, null); } } public boolean isParentWindowActive() {