提交 8ac893cf 编写于 作者: A asaha

Merge

...@@ -328,4 +328,5 @@ eaaa9a04b9fdcfa4a830b811ed209eb2c45a4a6b jdk8u25-b12 ...@@ -328,4 +328,5 @@ eaaa9a04b9fdcfa4a830b811ed209eb2c45a4a6b jdk8u25-b12
c3a855402b923d3ba819b05292a971953fc8ed0b jdk8u25-b13 c3a855402b923d3ba819b05292a971953fc8ed0b jdk8u25-b13
2a6df63ca0f0f59bb730638b05c72d77a23f93c8 jdk8u25-b14 2a6df63ca0f0f59bb730638b05c72d77a23f93c8 jdk8u25-b14
412d9ade90401d098f3662bd688ab393008423bd jdk8u25-b15 412d9ade90401d098f3662bd688ab393008423bd jdk8u25-b15
f07bc5dab84c67f5d1dccbab318ee1c5485c852d jdk8u25-b16
f935349e2c065487c745bc41f81ddc7869bd2d2d jdk8u31-b00 f935349e2c065487c745bc41f81ddc7869bd2d2d jdk8u31-b00
...@@ -105,6 +105,8 @@ public class LWWindowPeer ...@@ -105,6 +105,8 @@ public class LWWindowPeer
private final SecurityWarningWindow warningWindow; private final SecurityWarningWindow warningWindow;
private volatile boolean targetFocusable;
/** /**
* Current modal blocker or null. * Current modal blocker or null.
* *
...@@ -240,13 +242,12 @@ public class LWWindowPeer ...@@ -240,13 +242,12 @@ public class LWWindowPeer
if (!visible && warningWindow != null) { if (!visible && warningWindow != null) {
warningWindow.setVisible(false, false); warningWindow.setVisible(false, false);
} }
updateFocusableWindowState();
super.setVisibleImpl(visible); super.setVisibleImpl(visible);
// TODO: update graphicsConfig, see 4868278 // TODO: update graphicsConfig, see 4868278
platformWindow.setVisible(visible); platformWindow.setVisible(visible);
if (isSimpleWindow()) { if (isSimpleWindow()) {
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
if (visible) { if (visible) {
if (!getTarget().isAutoRequestFocus()) { if (!getTarget().isAutoRequestFocus()) {
return; return;
...@@ -397,6 +398,7 @@ public class LWWindowPeer ...@@ -397,6 +398,7 @@ public class LWWindowPeer
@Override @Override
public void updateFocusableWindowState() { public void updateFocusableWindowState() {
targetFocusable = getTarget().isFocusableWindow();
platformWindow.updateFocusableWindowState(); platformWindow.updateFocusableWindowState();
} }
...@@ -1220,13 +1222,13 @@ public class LWWindowPeer ...@@ -1220,13 +1222,13 @@ public class LWWindowPeer
} }
private boolean isFocusableWindow() { private boolean isFocusableWindow() {
boolean focusable = getTarget().isFocusableWindow(); boolean focusable = targetFocusable;
if (isSimpleWindow()) { if (isSimpleWindow()) {
LWWindowPeer ownerPeer = getOwnerFrameDialog(this); LWWindowPeer ownerPeer = getOwnerFrameDialog(this);
if (ownerPeer == null) { if (ownerPeer == null) {
return false; return false;
} }
return focusable && ownerPeer.getTarget().isFocusableWindow(); return focusable && ownerPeer.targetFocusable;
} }
return focusable; return focusable;
} }
......
...@@ -43,6 +43,7 @@ import java.io.IOException; ...@@ -43,6 +43,7 @@ import java.io.IOException;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.LinkedHashSet;
/** /**
* A container used to create a multiple-document interface or a virtual desktop. * A container used to create a multiple-document interface or a virtual desktop.
* You create <code>JInternalFrame</code> objects and add them to the * You create <code>JInternalFrame</code> objects and add them to the
...@@ -266,7 +267,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible ...@@ -266,7 +267,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible
private static Collection<JInternalFrame> getAllFrames(Container parent) { private static Collection<JInternalFrame> getAllFrames(Container parent) {
int i, count; int i, count;
Collection<JInternalFrame> results = new ArrayList<JInternalFrame>(); Collection<JInternalFrame> results = new LinkedHashSet<>();
count = parent.getComponentCount(); count = parent.getComponentCount();
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
Component next = parent.getComponent(i); Component next = parent.getComponent(i);
......
...@@ -6935,9 +6935,9 @@ Java_sun_awt_windows_WComponentPeer_nativeHandlesWheelScrolling (JNIEnv* env, ...@@ -6935,9 +6935,9 @@ Java_sun_awt_windows_WComponentPeer_nativeHandlesWheelScrolling (JNIEnv* env,
{ {
TRY; TRY;
return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall( return (jboolean)AwtToolkit::GetInstance().SyncCall(
(void *(*)(void *))AwtComponent::_NativeHandlesWheelScrolling, (void *(*)(void *))AwtComponent::_NativeHandlesWheelScrolling,
env->NewGlobalRef(self))); env->NewGlobalRef(self));
// global ref is deleted in _NativeHandlesWheelScrolling // global ref is deleted in _NativeHandlesWheelScrolling
CATCH_BAD_ALLOC_RET(NULL); CATCH_BAD_ALLOC_RET(NULL);
...@@ -6956,9 +6956,9 @@ Java_sun_awt_windows_WComponentPeer_isObscured(JNIEnv* env, ...@@ -6956,9 +6956,9 @@ Java_sun_awt_windows_WComponentPeer_isObscured(JNIEnv* env,
jobject selfGlobalRef = env->NewGlobalRef(self); jobject selfGlobalRef = env->NewGlobalRef(self);
return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall( return (jboolean)AwtToolkit::GetInstance().SyncCall(
(void*(*)(void*))AwtComponent::_IsObscured, (void*(*)(void*))AwtComponent::_IsObscured,
(void *)selfGlobalRef)); (void *)selfGlobalRef);
// selfGlobalRef is deleted in _IsObscured // selfGlobalRef is deleted in _IsObscured
CATCH_BAD_ALLOC_RET(NULL); CATCH_BAD_ALLOC_RET(NULL);
......
...@@ -1018,8 +1018,8 @@ Java_sun_awt_windows_WListPeer_isSelected(JNIEnv *env, jobject self, ...@@ -1018,8 +1018,8 @@ Java_sun_awt_windows_WListPeer_isSelected(JNIEnv *env, jobject self,
ses->list = env->NewGlobalRef(self); ses->list = env->NewGlobalRef(self);
ses->index = index; ses->index = index;
return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall( return (jboolean)AwtToolkit::GetInstance().SyncCall(
(void *(*)(void *))AwtList::_IsSelected, ses)); (void *(*)(void *))AwtList::_IsSelected, ses);
// global ref and ses are deleted in _IsSelected // global ref and ses are deleted in _IsSelected
CATCH_BAD_ALLOC_RET(FALSE); CATCH_BAD_ALLOC_RET(FALSE);
......
/*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 8047288
@summary Tests method isFocusable of Window component. It should be accessed only from EDT
@author artem.malinko@oracle.com
@library ../../regtesthelpers
@build Util
@run main WindowIsFocusableAccessByThreadsTest
*/
import test.java.awt.regtesthelpers.Util;
import javax.swing.*;
import java.awt.*;
import java.util.concurrent.atomic.AtomicBoolean;
public class WindowIsFocusableAccessByThreadsTest {
private static AtomicBoolean testPassed = new AtomicBoolean(true);
private static volatile TestFrame frame;
private static volatile TestWindow window;
private static volatile Button openWindowBtn;
public static void main(String[] args) {
frame = new TestFrame("Test EDT access to Window components");
window = new TestWindow(frame);
SwingUtilities.invokeLater(WindowIsFocusableAccessByThreadsTest::init);
Util.waitTillShown(frame);
Robot robot = Util.createRobot();
Util.clickOnComp(frame, robot, 100);
Util.clickOnComp(openWindowBtn, robot, 100);
Util.waitTillShown(window);
if (!testPassed.get()) {
throw new RuntimeException("Window component methods has been accessed not " +
"from Event Dispatching Thread");
}
}
private static void init() {
frame.setSize(400, 400);
frame.setLayout(new FlowLayout());
openWindowBtn = new Button("open window");
openWindowBtn.addActionListener(e -> {
window.setSize(100, 100);
window.setLocation(400, 100);
window.setVisible(true);
});
frame.add(openWindowBtn);
frame.setVisible(true);
}
private static void testThread() {
if (!SwingUtilities.isEventDispatchThread()) {
testPassed.set(false);
}
}
private static class TestWindow extends Window {
public TestWindow(Frame owner) {
super(owner);
}
// isFocusable method is final and we can't add this test to it.
// But it invokes getFocusableWindowState and here we can check
// if thread is EDT.
@Override
public boolean getFocusableWindowState() {
testThread();
return super.getFocusableWindowState();
}
}
private static class TestFrame extends Frame {
private TestFrame(String title) throws HeadlessException {
super(title);
}
// isFocusable method is final and we can't add this test to it.
// But it invokes getFocusableWindowState and here we can check
// if thread is EDT.
@Override
public boolean getFocusableWindowState() {
testThread();
return super.getFocusableWindowState();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册