Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8324597

PopupWindow pushed outside secondary screen when owner window is set full screen

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      The problem occurs only on macOS.

      A DESCRIPTION OF THE PROBLEM :
      Moving a window, owner of a visible PopupWindow, on a secondary screen, then set the window full screen pushes the popup outside the secondary screen boundaries, and the only way to find it is using App Exposé.

      The test application uses a Popup instance, but in my application I have the same problem with a class inherited from PopupControl.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - Execute the test code.
      - Press the Open PopUp button: a yellow popup appears below the button.
      - Move the window to a secondary screen: the popup moves with the window.
      - Make the window full screen pressing the green button on the left side of the window's titlebar: the popup disappear (but it is still open).
      - Press again the green button on the left side of the window's titlebar to exit full screen: the window's size is restored but the popup is still not visible (because outside the screen boundaries).
      - Activate App Exposé (on my mac swiping down with four fingers on the trackpad, or pressing F12 to show all application windows), and you'll see the popup very far from the owner window.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Having the popup always visible, more or less at the same position relative to its owner window.
      ACTUAL -
      The popup is pushed outside the boundary of the secondary screen, and clipped out.

      ---------- BEGIN SOURCE ----------
      package com.cropster.test.macosmovebug;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.geometry.Bounds;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.Region;
      import javafx.scene.layout.VBox;
      import javafx.stage.Popup;
      import javafx.stage.Stage;

      public class App extends Application {

        public static void main(String[] args) {
          launch();
        }

        @Override
        public void start(Stage stage) {

          String javaVersion = System.getProperty("java.version");
          String javafxVersion = System.getProperty("javafx.version");

          Label label =
              new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
          Button button = new Button("Open PopUp");
          VBox root = new VBox(16);

          button.setOnAction(this::openPopUp);

          root.setAlignment(Pos.CENTER);
          root.getChildren().addAll(label, button);

          stage.setScene(new Scene(root, 640, 480));
          stage.show();
        }

        private void openPopUp(ActionEvent e) {

          Popup popup = new Popup();
          Label label = new Label(" PopUp ");

          label.setStyle("-fx-background-color: yellow; -fx-border-color: blue;");
          popup.getContent().add(label);

          Region owner = (Region) e.getSource();
          Bounds bounds = owner.localToScreen(owner.getBoundsInLocal());

          popup.show(owner, bounds.getMinX(), bounds.getMaxY() + 2);
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The tests that I've made using my production code that uses a PopupControl, I've seen that the problem is not on setting the application full screen (and you can see that when setting full screen the window on the main screen, the popup is still visible), but having moved the main window on a different screen before setting it full screen.
      So my current workaround is:
      - save the screen containing the window (really only its top-left point) when it is visible is made visible,
      - when the window is moved (listeners to X and Y properties) checking if the screen is still the same, and if not
      - programmatically close the popup (and save the new screen).

      FREQUENCY : always


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: