Skip to content

Commit

Permalink
8280990: [XWayland] XTest emulated mouse click does not bring window …
Browse files Browse the repository at this point in the history
…to front.
  • Loading branch information
azvegint committed May 27, 2024
1 parent be1d374 commit 4ec05c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024, 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 @@ -35,6 +35,9 @@ public class FrameToFrontModelessTest {

private boolean isModeless;

private static final boolean IS_ON_WAYLAND =
System.getenv("WAYLAND_DISPLAY") != null;

public FrameToFrontModelessTest(boolean modeless) throws Exception {
isModeless = modeless;
robot = new ExtendedRobot();
Expand Down Expand Up @@ -76,6 +79,9 @@ public void doTest() throws Exception {
robot.waitForIdle(delay);

// show the right frame appear on top of the dialog
if (IS_ON_WAYLAND) {
rightFrame.toFront();
}
rightFrame.clickDummyButton(robot);
robot.waitForIdle(delay);

Expand Down
11 changes: 10 additions & 1 deletion test/jdk/java/awt/Modal/helpers/TestDialog.java
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, 2024, 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 @@ -45,6 +45,9 @@ public class TestDialog extends Dialog implements ActionListener,
public static int delay = 500;
public static int keyDelay = 100;

private static final boolean IS_ON_WAYLAND =
System.getenv("WAYLAND_DISPLAY") != null;

public TestDialog(Frame frame) {
super(frame);
initializeGUI();
Expand Down Expand Up @@ -287,6 +290,9 @@ public void transferFocusToDialog(ExtendedRobot robot,
String message,
Button b) throws Exception {
focusGained.reset();
if (IS_ON_WAYLAND) {
toFront();
}
clickInside(robot);
focusGained.waitForFlagTriggered();
assertTrue(focusGained.flag(),
Expand All @@ -303,6 +309,9 @@ public void transferFocusToBlockedDialog(ExtendedRobot robot,
String message,
Button b) throws Exception {
focusGained.reset();
if (IS_ON_WAYLAND) {
toFront();
}
clickInside(robot);
robot.waitForIdle(delay);

Expand Down
12 changes: 10 additions & 2 deletions test/jdk/java/awt/Modal/helpers/TestFrame.java
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, 2024, 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 @@ -43,6 +43,8 @@ public class TestFrame extends Frame implements ActionListener,

public static int delay = 500;
public static int keyDelay = 100;
private static final boolean IS_ON_WAYLAND =
System.getenv("WAYLAND_DISPLAY") != null;

public TestFrame() {
super();
Expand Down Expand Up @@ -251,7 +253,7 @@ public void clickDummyButton(ExtendedRobot robot,
String message) throws Exception {
dummyClicked.reset();
clickButton(dummyButton, robot);
dummyClicked.waitForFlagTriggered();
dummyClicked.waitForFlagTriggered(attempts);

String msg = "Clicking the frame Dummy button " + (refState ?
"did not trigger an action." :
Expand All @@ -277,6 +279,9 @@ public void transferFocusToFrame(ExtendedRobot robot,
String message,
Button b) throws Exception {
focusGained.reset();
if (IS_ON_WAYLAND) {
toFront();
}
clickInside(robot);

focusGained.waitForFlagTriggered();
Expand All @@ -293,6 +298,9 @@ public void transferFocusToBlockedFrame(ExtendedRobot robot,
String message,
Button b) throws Exception {
focusGained.reset();
if (IS_ON_WAYLAND) {
toFront();
}
clickInside(robot);

robot.waitForIdle(delay);
Expand Down

0 comments on commit 4ec05c5

Please sign in to comment.