mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Window centering improvements
This commit is contained in:
parent
d77925540e
commit
6dd0e6d255
2 changed files with 11 additions and 6 deletions
|
@ -146,6 +146,8 @@ public class AppMainWindow {
|
|||
AtomicBoolean shown = new AtomicBoolean(false);
|
||||
stage.setOnShown(event -> {
|
||||
PlatformThread.runLaterIfNeeded(() -> {
|
||||
// On some platforms, e.g. KDE with wayland, the screen size is not known when the window is first shown
|
||||
// This fixes the alignment in these cases
|
||||
if (state == null && !shown.get()) {
|
||||
Platform.runLater(() -> {
|
||||
stage.centerOnScreen();
|
||||
|
|
|
@ -85,12 +85,14 @@ public class AppWindowHelper {
|
|||
|
||||
stage.setOnShown(e -> {
|
||||
AppTheme.initThemeHandlers(stage);
|
||||
centerToMainWindow(stage);
|
||||
clampWindow(stage).ifPresent(rectangle2D -> {
|
||||
stage.setX(rectangle2D.getMinX());
|
||||
stage.setY(rectangle2D.getMinY());
|
||||
stage.setWidth(rectangle2D.getWidth());
|
||||
stage.setHeight(rectangle2D.getHeight());
|
||||
Platform.runLater(() -> {
|
||||
centerToMainWindow(stage);
|
||||
clampWindow(stage).ifPresent(rectangle2D -> {
|
||||
stage.setX(rectangle2D.getMinX());
|
||||
stage.setY(rectangle2D.getMinY());
|
||||
stage.setWidth(rectangle2D.getWidth());
|
||||
stage.setHeight(rectangle2D.getHeight());
|
||||
});
|
||||
});
|
||||
});
|
||||
return stage;
|
||||
|
@ -98,6 +100,7 @@ public class AppWindowHelper {
|
|||
|
||||
private static void centerToMainWindow(Window childStage) {
|
||||
if (App.getApp() == null) {
|
||||
childStage.centerOnScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue