Skip to content

Commit

Permalink
Backport f203723fc72c5d92c8745d4c595f360a9b50c512
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Jun 5, 2024
1 parent ab84520 commit 4836ab6
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, 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
Expand Down Expand Up @@ -454,7 +454,7 @@ protected void initializeDesktopProperties() {
desktopProperties.put("awt.multiClickInterval", getMultiClickTime());

// These DnD properties must be set, otherwise Swing ends up spewing NPEs
// all over the place. The values came straight off of MToolkit.
// all over the place. The values came straight off of XToolkit.
desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50));
desktopProperties.put("DnD.Autoscroll.interval", Integer.valueOf(50));
desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5));
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/sun/awt/SunToolkit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
Expand Down Expand Up @@ -205,7 +205,7 @@ public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
* access to Xlib, OpenGL, etc. However, these methods are implemented
* in SunToolkit so that they can be called from shared code (e.g.
* from the OGL pipeline) or from the X11 pipeline regardless of whether
* XToolkit or MToolkit is currently in use. There are native macros
* XToolkit is currently in use. There are native macros
* (such as AWT_LOCK) defined in awt.h, so if the implementation of these
* methods is changed, make sure it is compatible with the native macros.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
Expand Down Expand Up @@ -67,7 +67,7 @@ public Object run() {
System.loadLibrary("awt");

/*
* Note: The MToolkit object depends on the static initializer
* Note: The XToolkit object depends on the static initializer
* of X11GraphicsEnvironment to initialize the connection to
* the X11 server.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
Expand Down Expand Up @@ -216,7 +216,7 @@ public String toString() {
}

/**
* The following methods are invoked from MToolkit or XToolkit.java and
* The following methods are invoked from XToolkit.java and
* X11ComponentPeer.java rather than having the X11-dependent
* implementations hardcoded in those classes. This way the appropriate
* actions are taken based on the peer's GraphicsConfig, whether it is
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/unix/native/common/awt/awt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2022, 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
Expand Down Expand Up @@ -41,7 +41,7 @@ typedef char Boolean;
#endif /* !HEADLESS && !MACOSX */


/* The JVM instance: defined in awt_MToolkit.c */
/* The JVM instance: defined in awt_LoadLibrary.c */
extern JavaVM *jvm;

extern jclass tkClass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
Expand Down Expand Up @@ -131,7 +131,7 @@ private static void testKeyOnChoice(int button, int key) {

if (toolkit.equals("sun.awt.X11.XToolkit") &&
keyTypedOnTextField) {
throw new RuntimeException("Test failed. (XToolkit/MToolkit). KeyEvent was addressed to TextField.");
throw new RuntimeException("Test failed. (XToolkit). KeyEvent was addressed to TextField.");
}

System.out.println("Test passed. Unfocusable Choice doesn't react on keys.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, 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
Expand Down Expand Up @@ -69,11 +69,6 @@ public void eventDispatched(AWTEvent e) {
}

public void start() {
if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("No testing on Motif. Test passed.");
return;
}

System.out.println("\nTest started:\n");

// Test 1.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, 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
Expand Down Expand Up @@ -293,43 +293,39 @@ public void run() {
// 6. Show unblocking modal Dialog.
///////////////////////////////////

if ("sun.awt.motif.MToolkit".equals(toolkitClassName)) {
System.out.println("Stage 6 - Skiping.");
} else {
System.out.println("Stage 6 in progress...");
System.out.println("Stage 6 in progress...");

// ---
// Testing the bug of activating invisible modal Dialog (awt_Window::SetAndActivateModalBlocker).
// Having some window not excluded from modality, so that it would be blocked.
Frame f = new Frame("Aux. Frame");
f.setSize(100, 100);
setVisible(f, true);
// ---
// ---
// Testing the bug of activating invisible modal Dialog (awt_Window::SetAndActivateModalBlocker).
// Having some window not excluded from modality, so that it would be blocked.
Frame f = new Frame("Aux. Frame");
f.setSize(100, 100);
setVisible(f, true);
// ---

setVisible(focusedFrame, true);
setVisible(focusedFrame, true);
if (!focusOwner.hasFocus()) {
Util.clickOnComp(focusOwner, robot);
Util.waitForIdle(robot);
if (!focusOwner.hasFocus()) {
Util.clickOnComp(focusOwner, robot);
Util.waitForIdle(robot);
if (!focusOwner.hasFocus()) {
throw new Error("Test error: the frame couldn't be focused.");
}
throw new Error("Test error: the frame couldn't be focused.");
}
}

dialog.setModal(true);
dialog.setAutoRequestFocus(false);
focusedFrame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
dialog.setModal(true);
dialog.setAutoRequestFocus(false);
focusedFrame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);

TestHelper.invokeLaterAndWait(new Runnable() {
public void run() {
dialog.setVisible(true);
}
}, robot);
TestHelper.invokeLaterAndWait(new Runnable() {
public void run() {
dialog.setVisible(true);
}
}, robot);

if (dialog.isFocused()) {
throw new TestFailedException("the unblocking dialog shouldn't gain focus but it did!");
}
setVisible(dialog, false);
if (dialog.isFocused()) {
throw new TestFailedException("the unblocking dialog shouldn't gain focus but it did!");
}
setVisible(dialog, false);

System.out.println("Test passed.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, 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
Expand Down Expand Up @@ -202,26 +202,22 @@ public void start() {
// Focused frame is excluded from modality.
////////////////////////////////////////////////

if (!"sun.awt.motif.MToolkit".equals(toolkitClassName)) {
recreateGUI();
auxFrame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
recreateGUI();
auxFrame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);

Test.setWindows(modalDialog, modalDialog, new Window[] {modalDialog, frame3});
Test.test("Test stage 6.1 in progress", modalDlgButton);
}
Test.setWindows(modalDialog, modalDialog, new Window[] {modalDialog, frame3});
Test.test("Test stage 6.1 in progress", modalDlgButton);


// 6.2. Owner Frame (with owned modal Dialog).
// Focused frame is excluded from modality.
////////////////////////////////////////////////

if (!"sun.awt.motif.MToolkit".equals(toolkitClassName)) {
recreateGUI();
auxFrame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
recreateGUI();
auxFrame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);

Test.setWindows(frame3, modalDialog, new Window[] {modalDialog, frame3});
Test.test("Test stage 6.2 in progress", modalDlgButton, true);
}
Test.setWindows(frame3, modalDialog, new Window[] {modalDialog, frame3});
Test.test("Test stage 6.2 in progress", modalDlgButton, true);

///////////////////////////////////////////////////
// 7. Calling setVisible(true) for the shown Frame.
Expand Down Expand Up @@ -422,4 +418,3 @@ class TestFailedException extends RuntimeException {
super("Test failed: " + msg);
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2022, 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
Expand Down Expand Up @@ -47,11 +47,6 @@ public static void main(String[] args) {
}

public void start() {
if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("The test is not for MToolkit.");
return;
}

dialog.setBounds(800, 0, 200, 100);
frame.setBounds(800, 150, 200, 100);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
Expand Down Expand Up @@ -57,12 +57,6 @@ public void init() {
}

public void start() {

if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("No testing on MToolkit.");
return;
}

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionPerformed = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
Expand Down Expand Up @@ -56,12 +56,6 @@ public void init() {
}

public void start() {

if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("No testing on MToolkit.");
return;
}

try {
EventQueue.invokeLater(new Runnable() {
public void run() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, 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
Expand Down Expand Up @@ -56,12 +56,6 @@ public class SimpleWindowActivationTest {
private static Robot robot;

public static void main(String[] args) throws Exception {

if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("No testing on Motif. Test passed.");
return;
}

robot = new Robot();
robot.setAutoDelay(50);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
Expand Down Expand Up @@ -63,11 +63,6 @@ public void init() {
}

public void start() {
if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
System.out.println("No testing on Motif.");
return;
}

test(new Frame("Frame owner"));
Frame dialog_owner = new Frame("dialog's owner");
test(new Dialog(dialog_owner));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, 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
Expand Down Expand Up @@ -105,7 +105,7 @@ public void mouseReleased(MouseEvent e) {
//XToolkit: extra buttons should report MOVED events only
//WToolkit: extra buttons should report DRAGGED events only
if (i > 2){ //extra buttons only
if (tk.equals("sun.awt.X11.XToolkit") || tk.equals("sun.awt.motif.MToolkit")) {
if (tk.equals("sun.awt.X11.XToolkit")) {
if (!moved || dragged) {
throw new RuntimeException("Test failed."+ tk +" Button = " +(i+1) + " moved = "+moved +" : dragged = " +dragged);
}
Expand Down Expand Up @@ -152,4 +152,3 @@ public static void dragMouse(int button, int x0, int y0, int x1, int y1){
}

}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, 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
Expand Down Expand Up @@ -57,7 +57,7 @@ public static void main(String []s){

//MouseInfo.getNumberOfButtons() reports two more buttons on XToolkit
//as they reserved for wheel (both directions).
if (tk.equals("sun.awt.X11.XToolkit") || tk.equals("sun.awt.motif.MToolkit")) {
if (tk.equals("sun.awt.X11.XToolkit")) {
buttonsNum = buttonsNum - 2;
}
System.out.println("Number Of Buttons = "+ buttonsNum);
Expand Down
7 changes: 1 addition & 6 deletions test/jdk/java/awt/Window/GrabSequence/GrabSequence.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
Expand Down Expand Up @@ -40,11 +40,6 @@ public class GrabSequence
{
private static void init()
{
String toolkit = Toolkit.getDefaultToolkit().getClass().getName();
if ( toolkit.equals("sun.awt.motif.MToolkit")){
System.out.println("This test is for XToolkit and WToolkit only. Now using " + toolkit + ". Automatically passed.");
return;
}
Frame frame = new Frame("Frame");
frame.setBackground(Color.green);
frame.setForeground(Color.green);
Expand Down
Loading

0 comments on commit 4836ab6

Please sign in to comment.