提交 3ecdf18d 编写于 作者: A alexsch

8012330: [macosx] Sometimes the applet showing the modal dialog itself loses...

8012330: [macosx] Sometimes the applet showing the modal dialog itself loses the ability to gain focus
Reviewed-by: serb, ant
上级 871d0f9d
...@@ -38,7 +38,8 @@ import java.awt.event.*; ...@@ -38,7 +38,8 @@ import java.awt.event.*;
public class CEmbeddedFrame extends EmbeddedFrame { public class CEmbeddedFrame extends EmbeddedFrame {
private CPlatformResponder responder; private CPlatformResponder responder;
private boolean focused = true; private static final Object classLock = new Object();
private static volatile CEmbeddedFrame focusedWindow;
private boolean parentWindowActive = true; private boolean parentWindowActive = true;
public CEmbeddedFrame() { public CEmbeddedFrame() {
...@@ -104,9 +105,16 @@ public class CEmbeddedFrame extends EmbeddedFrame { ...@@ -104,9 +105,16 @@ public class CEmbeddedFrame extends EmbeddedFrame {
responder.handleInputEvent(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) { public void handleFocusEvent(boolean focused) {
this.focused = focused; synchronized (classLock) {
if (focused) { // 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 // see bug 8010925
// we can't put this to handleWindowFocusEvent because // we can't put this to handleWindowFocusEvent because
// it won't be invoced if focuse is moved to a html element // it won't be invoced if focuse is moved to a html element
...@@ -119,11 +127,14 @@ public class CEmbeddedFrame extends EmbeddedFrame { ...@@ -119,11 +127,14 @@ public class CEmbeddedFrame extends EmbeddedFrame {
} }
} }
// 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.
public void handleWindowFocusEvent(boolean parentWindowActive) { public void handleWindowFocusEvent(boolean parentWindowActive) {
this.parentWindowActive = parentWindowActive; this.parentWindowActive = parentWindowActive;
// ignore focus "lost" native request as it may mistakenly // ignore focus "lost" native request as it may mistakenly
// deactivate active window (see 8001161) // deactivate active window (see 8001161)
if (focused && parentWindowActive) { if (focusedWindow == this && parentWindowActive) {
responder.handleWindowFocusEvent(parentWindowActive, null); responder.handleWindowFocusEvent(parentWindowActive, null);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册