Browse Source

Decorations: Only call implementation methods when supported. This protects against scenarios where those methods are called regardless of the outcome of #isCustomDecorationSupported e.g. when uninstalling popup decorations.

pull/245/head
weisj 4 years ago
parent
commit
ec79c4dcf6
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 3
      core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java
  2. 4
      core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java

3
core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java

@ -71,14 +71,17 @@ public class DecorationsHandler {
}
public CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window) {
if (!decorationsProvider.isCustomDecorationSupported()) return DefaultDecorationsProvider.createNoOPTitlePane();
return decorationsProvider.createTitlePane(rootPane, decorationStyle, window);
}
public void installPopupWindow(final Window window) {
if (!decorationsProvider.isCustomDecorationSupported()) return;
decorationsProvider.installPopupWindow(window);
}
public void uninstallPopupWindow(final Window window) {
if (!decorationsProvider.isCustomDecorationSupported()) return;
decorationsProvider.uninstallPopupWindow(window);
}

4
core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java

@ -32,6 +32,10 @@ import com.github.weisj.darklaf.platform.decorations.DecorationsProvider;
public class DefaultDecorationsProvider implements DecorationsProvider {
@Override
public CustomTitlePane createTitlePane(final JRootPane rootPane, final int decorationStyle, final Window window) {
return createNoOPTitlePane();
}
static CustomTitlePane createNoOPTitlePane() {
return new CustomTitlePane() {
@Override
public void uninstall(final boolean removeDecorations) {}

2
core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java

@ -178,6 +178,8 @@ public class DarkPopupFactory extends PopupFactory {
rootPane.putClientProperty("Window.shadow", !noDecorations);
}
if (noDecorations) {
// We also uninstall if decorations aren't enabled/supported as a reused window could be
// decorated previously.
DecorationsHandler.getSharedInstance().uninstallPopupWindow(window);
} else if (DecorationsHandler.getSharedInstance().isCustomDecorationSupported()) {
DecorationsHandler.getSharedInstance().installPopupWindow(window);

Loading…
Cancel
Save