From 019edb2e148f0670cfa3d5c4e15842985c9640fd Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 30 Jul 2019 18:56:19 +0200 Subject: [PATCH] Deprecate AWTUtilitiesWrapper and use Java 1.7 API for translucency GitOrigin-RevId: dcf3a966f6e7ad62ffd945354a94b9eaa4d69303 --- .../openapi/wm/impl/AWTUtilitiesWrapper.java | 7 +++++++ .../openapi/wm/impl/WindowManagerImpl.java | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java index 69d1b9aa74ba..7cf9fff157da 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java @@ -15,10 +15,17 @@ */ package com.intellij.openapi.wm.impl; +import org.jetbrains.annotations.ApiStatus; + import java.awt.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +/** + * @deprecated use Java 1.7 API + */ +@Deprecated +@ApiStatus.ScheduledForRemoval(inVersion = "2019.3") public class AWTUtilitiesWrapper { private static Class awtUtilitiesClass; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 4ed95f849074..2212e0ade2b6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -256,8 +256,8 @@ public final class WindowManagerImpl extends WindowManagerEx implements Persiste ((JFrame)window).getRootPane().putClientProperty("Window.alpha", 1.0f - ratio); } } - else if (AWTUtilitiesWrapper.isTranslucencySupported(AWTUtilitiesWrapper.TRANSLUCENT)) { - AWTUtilitiesWrapper.setWindowOpacity(window, 1.0f - ratio); + else if (isTranslucencySupported()) { + window.setOpacity(1.0f - ratio); } else { WindowUtils.setWindowAlpha(window, 1.0f - ratio); @@ -271,8 +271,8 @@ public final class WindowManagerImpl extends WindowManagerEx implements Persiste @Override public void setWindowMask(final Window window, @Nullable final Shape mask) { try { - if (AWTUtilitiesWrapper.isTranslucencySupported(AWTUtilitiesWrapper.PERPIXEL_TRANSPARENT)) { - AWTUtilitiesWrapper.setWindowShape(window, mask); + if (isPerPixelTransparencySupported()) { + window.setShape(mask); } else { WindowUtils.setWindowMask(window, mask); @@ -752,6 +752,16 @@ public final class WindowManagerImpl extends WindowManagerEx implements Persiste return !SystemInfo.isMac && getInstance().isFullScreenSupportedInCurrentOS(); } + static boolean isTranslucencySupported() { + GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + return device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT); + } + + static boolean isPerPixelTransparencySupported() { + GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + return device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT); + } + /** * Converts the frame bounds b/w the user space (JRE-managed HiDPI mode) and the device space (IDE-managed HiDPI mode). * See {@link JreHiDpiUtil#isJreHiDPIEnabled()}