From 11fe10f0b5097ae2c3aecbb510f212ed50dc460c Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 19 Jun 2018 23:04:33 +0300 Subject: [PATCH] Get rid of animation and user notification in case of Remote Desktop Problems we had: 1) Registry key was in wrong state and we proceed all animation anyway 2) Notification is too confusing while actual difference in UI is minor --- .../intellij/ide/RemoteDesktopService.java | 6 ----- .../intellij/openapi/ui/LoadingDecorator.java | 3 ++- .../ui/components/ScrollSettings.java | 2 +- .../intellij/ide/RemoteDesktopDetector.java | 24 ++----------------- .../editor/impl/ScrollingModelImpl.java | 2 +- .../openapi/wm/impl/ToolWindowsPane.java | 4 ++-- .../src/com/intellij/ui/BalloonImpl.java | 2 +- .../src/messages/ApplicationBundle.properties | 2 -- .../util/resources/misc/registry.properties | 3 --- 9 files changed, 9 insertions(+), 39 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ide/RemoteDesktopService.java b/platform/platform-api/src/com/intellij/ide/RemoteDesktopService.java index 9b825c40b51c..8f81602139ca 100644 --- a/platform/platform-api/src/com/intellij/ide/RemoteDesktopService.java +++ b/platform/platform-api/src/com/intellij/ide/RemoteDesktopService.java @@ -2,8 +2,6 @@ package com.intellij.ide; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.registry.Registry; public abstract class RemoteDesktopService { public static RemoteDesktopService getInstance() { @@ -14,9 +12,5 @@ public abstract class RemoteDesktopService { return getInstance().isRemoteDesktopConnected(); } - public static boolean isAnimationDisabled() { - return (!SystemInfo.isWin8OrNewer || Registry.is("animation.disabled.on.remote.desktop")) && isRemoteSession(); - } - public abstract boolean isRemoteDesktopConnected(); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java index 20efec02a10d..81fba24a7e99 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.ui; +import com.intellij.ide.RemoteDesktopService; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Disposer; import com.intellij.ui.components.JBLayeredPane; @@ -58,7 +59,7 @@ public class LoadingDecorator { setLoadingText("Loading..."); - myFadeOutAnimator = new Animator("Loading", 10, 500, false) { + myFadeOutAnimator = new Animator("Loading", 10, RemoteDesktopService.isRemoteSession()? 2500 : 500, false) { public void paintNow(final int frame, final int totalFrames, final int cycle) { myLoadingLayer.setAlpha(1f - ((float)frame) / ((float)totalFrames)); } diff --git a/platform/platform-api/src/com/intellij/ui/components/ScrollSettings.java b/platform/platform-api/src/com/intellij/ui/components/ScrollSettings.java index 727e3d92cd63..c62b5c1ca127 100644 --- a/platform/platform-api/src/com/intellij/ui/components/ScrollSettings.java +++ b/platform/platform-api/src/com/intellij/ui/components/ScrollSettings.java @@ -38,7 +38,7 @@ final class ScrollSettings { Application application = getApplication(); if (application == null || application.isUnitTestMode()) return false; if (PowerSaveMode.isEnabled()) return false; - if (RemoteDesktopService.isAnimationDisabled()) return false; + if (RemoteDesktopService.isRemoteSession()) return false; UISettings settings = UISettings.getInstanceOrNull(); return settings != null && settings.getSmoothScrolling(); diff --git a/platform/platform-impl/src/com/intellij/ide/RemoteDesktopDetector.java b/platform/platform-impl/src/com/intellij/ide/RemoteDesktopDetector.java index b552022da06e..19686be937e0 100644 --- a/platform/platform-impl/src/com/intellij/ide/RemoteDesktopDetector.java +++ b/platform/platform-impl/src/com/intellij/ide/RemoteDesktopDetector.java @@ -1,21 +1,12 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide; -import com.intellij.notification.NotificationDisplayType; -import com.intellij.notification.NotificationGroup; -import com.intellij.notification.NotificationType; -import com.intellij.notification.Notifications; -import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; import com.sun.jna.platform.win32.User32; public class RemoteDesktopDetector extends RemoteDesktopService { private static final Logger LOG = Logger.getInstance(RemoteDesktopDetector.class); - private static final NotificationGroup NOTIFICATION_GROUP = - new NotificationGroup("Remote Desktop", NotificationDisplayType.BALLOON, false); - private volatile boolean myFailureDetected; private volatile boolean myRemoteDesktopConnected; @@ -31,19 +22,8 @@ public class RemoteDesktopDetector extends RemoteDesktopService { try { // This might not work in all cases, but hopefully is a more reliable method than the current one (checking for font smoothing) // see https://msdn.microsoft.com/en-us/library/aa380798%28v=vs.85%29.aspx - boolean newValue = User32.INSTANCE.GetSystemMetrics(0x1000) != 0; // 0x1000 is SM_REMOTESESSION - LOG.debug("Detected remote desktop: ", newValue); - if (newValue != myRemoteDesktopConnected) { - myRemoteDesktopConnected = newValue; - if (myRemoteDesktopConnected) { - // We postpone notification to avoid recursive initialization of RemoteDesktopDetector - // (in case it's initialized by request from com.intellij.notification.EventLog) - ApplicationManager.getApplication().invokeLater(() -> Notifications.Bus.notify( - NOTIFICATION_GROUP - .createNotification(ApplicationBundle.message("remote.desktop.detected.message"), NotificationType.INFORMATION) - .setTitle(ApplicationBundle.message("remote.desktop.detected.title")))); - } - } + myRemoteDesktopConnected = User32.INSTANCE.GetSystemMetrics(0x1000) != 0; // 0x1000 is SM_REMOTESESSION + LOG.debug("Detected remote desktop: ", myRemoteDesktopConnected); } catch (Throwable e) { myRemoteDesktopConnected = false; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java index a1fb05c78e10..97032828f5b6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java @@ -329,7 +329,7 @@ public class ScrollingModelImpl implements ScrollingModelEx { VisibleEditorsTracker editorsTracker = VisibleEditorsTracker.getInstance(); boolean useAnimation; //System.out.println("myCurrentCommandStart - myLastCommandFinish = " + (myCurrentCommandStart - myLastCommandFinish)); - if (!myEditor.getSettings().isAnimatedScrolling() || myAnimationDisabled || RemoteDesktopService.isAnimationDisabled()) { + if (!myEditor.getSettings().isAnimatedScrolling() || myAnimationDisabled || RemoteDesktopService.isRemoteSession()) { useAnimation = false; } else if (CommandProcessor.getInstance().getCurrentCommand() == null) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java index 8fa89cdb7a47..c24fa9f11051 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java @@ -887,7 +887,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi public final void run() { try { // Show component. - if (!myDirtyMode && UISettings.getInstance().getAnimateWindows() && !RemoteDesktopService.isAnimationDisabled()) { + if (!myDirtyMode && UISettings.getInstance().getAnimateWindows() && !RemoteDesktopService.isRemoteSession()) { // Prepare top image. This image is scrolling over bottom image. final Image topImage = myLayeredPane.getTopImage(); final Graphics topGraphics = topImage.getGraphics(); @@ -1104,7 +1104,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi public final void run() { try { final UISettings uiSettings = UISettings.getInstance(); - if (!myDirtyMode && uiSettings.getAnimateWindows() && !RemoteDesktopService.isAnimationDisabled()) { + if (!myDirtyMode && uiSettings.getAnimateWindows() && !RemoteDesktopService.isRemoteSession()) { final Rectangle bounds = myComponent.getBounds(); // Prepare top image. This image is scrolling over bottom image. It contains // picture of component is being removed. diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java index 8c6d261e506f..4fb14be888e7 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java @@ -2014,7 +2014,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui { } public boolean isAnimationEnabled() { - return myAnimationEnabled && myAnimationCycle > 0 && !RemoteDesktopService.isAnimationDisabled(); + return myAnimationEnabled && myAnimationCycle > 0 && !RemoteDesktopService.isRemoteSession(); } public boolean isBlockClicks() { diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index 774c182c8a65..863e76bd4cb2 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -764,8 +764,6 @@ editorsearch.toomuch=More than {0} matches code.style.other.file.types=Other File Types code.style.other.label=Text files and unsupported file types\: -remote.desktop.detected.title=Remote desktop detected -remote.desktop.detected.message=Animation disabled checkbox.line.comment.add.space=Add a space at comment start quarantine.cleaner=Quarantine Cleaner diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 49f2c8a333aa..9b8c76e03b4a 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -1595,9 +1595,6 @@ junit4.accept.inner.classes.description=If false, inner classes won't be include try.starting.dumb.mode.where.many.files.changed=true try.starting.dumb.mode.where.many.files.changed.description=Enables automatic start of dumb mode for all opened projects once more than certain number of files is changed -animation.disabled.on.remote.desktop=false -animation.disabled.on.remote.desktop.description=Allows to stop animation via RDP - editor.highlight.foldings=true editor.highlight.foldings.description=Highlight folded regions containing certain highlighters (e.g. for search results) ide.hide.real.module.name=false