diff --git a/CHANGELOG.md b/CHANGELOG.md index 097b77b..18305a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## v0.2.1 +- Improve Dialogs.getDefaultOwner() logic https://github.com/qupath/qupath-fxtras/pull/60 + +## v0.2.0 +- Update gradle, version https://github.com/qupath/qupath-fxtras/pull/48 +- FXUtils commands to get stages https://github.com/qupath/qupath-fxtras/pull/47 +- Convert to kotlin https://github.com/qupath/qupath-fxtras/pull/49 +- Make the use of country codes optional https://github.com/qupath/qupath-fxtras/pull/50 +- Fix publishing https://github.com/qupath/qupath-fxtras/pull/51 +- Update version https://github.com/qupath/qupath-fxtras/pull/52 +- Improve file chooser behavior https://github.com/qupath/qupath-fxtras/pull/53 + +## v0.1.7 +- Improve screen choice for input display https://github.com/qupath/qupath-fxtras/pull/44 + ## v0.1.6 - Allow default directory to be set when prompting for a file with FileChoosers (https://github.com/qupath/qupath-fxtras/issues/40) diff --git a/build.gradle.kts b/build.gradle.kts index c3098fb..24a95ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { base { group = "io.github.qupath" - version = "0.2.0" + version = "0.2.1" description = "Extra classes built on JavaFX that are used to help create the QuPath user interface. " + "These don't depend on other QuPath modules, so can be reused elsewhere." } diff --git a/src/main/java/qupath/fx/dialogs/Dialogs.java b/src/main/java/qupath/fx/dialogs/Dialogs.java index e2c404e..7c1f8b7 100644 --- a/src/main/java/qupath/fx/dialogs/Dialogs.java +++ b/src/main/java/qupath/fx/dialogs/Dialogs.java @@ -505,14 +505,27 @@ static Window getDefaultOwner() { .thenComparing(w -> w.isFocused() ? -1 : 1) // Prefer focused windows .thenComparing(w -> w == primaryWindow) // Prefer the primary window .thenComparing(Dialogs::getTitle); // Finally sort by title - var owner = Window.getWindows().stream() - .filter(w -> !(w instanceof PopupWindow)) // Avoid popup windows (they don't work well as owners) - .sorted(comparator) - .findFirst() + // Avoid popup windows (they don't work well as owners) + return Window.getWindows().stream() + .filter(Dialogs::maybeOwner) + .min(comparator) .orElse(primaryWindow); - return owner; } + private static boolean maybeOwner(Window window) { + // Don't accept popup windows + if (window instanceof PopupWindow || !window.isShowing()) + return false; + // Only accept 'normal', decorated, non-transparent stages + if (window instanceof Stage stage) { + return switch (stage.getStyle()) { + case UNDECORATED, TRANSPARENT, UTILITY -> false; + default -> true; + }; + } + return true; + } + private static String getTitle(Window window) { String title = null; if (window instanceof Stage stage)