From af82ec0d9ef03384f9d1b75927488d29a6d9b57b Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Wed, 30 Mar 2022 22:28:49 +0200 Subject: [PATCH] Restore window bounds after uninstalling decorations --- .../darklaf/platform/macos/ui/MacOSDecorationsUtil.java | 6 +++++- .../weisj/darklaf/platform/macos/ui/MacOSTitlePane.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java index 5df4600e6..91c7b8225 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java @@ -78,14 +78,18 @@ private static void setFullSizeContent(final long windowHandle, final boolean en } } - static void uninstallDecorations(final DecorationInformation information) { + static void uninstallDecorations(final Window window, final DecorationInformation information) { if (information == null || information.windowHandle == 0) { return; } if (information.useColoredTitleBar) { + // As for the case when removing decorations, adding them back will cause the window to + // change it's size. + Rectangle bounds = window.getBounds(); JNIDecorationsMacOS.uninstallDecorations(information.windowHandle, information.fullWindowContentEnabled, information.transparentTitleBarEnabled); + window.setBounds(bounds); } JNIDecorationsMacOS.setTitleEnabled(information.windowHandle, true); JNIDecorationsMacOS.releaseWindow(information.windowHandle); diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java index 939dd7070..280565a4a 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java @@ -159,7 +159,7 @@ public void uninstall(final boolean removeDecorations) { uninstallListeners(); if (decorationInformation != null) { if (removeDecorations || decorationInformation.useColoredTitleBar != isUseColoredTitleBar(getRootPane())) { - MacOSDecorationsUtil.uninstallDecorations(decorationInformation); + MacOSDecorationsUtil.uninstallDecorations(window, decorationInformation); decorationInformation = null; } }