Wallpaper: do not eat cpu cycles if not configured

This commit is contained in:
Gregory.Shrago
2015-06-30 17:26:16 +03:00
parent cfb817381d
commit 6e8713e25c
2 changed files with 13 additions and 3 deletions
@@ -57,11 +57,11 @@ public class IdeBackgroundUtil {
}
public static void initEditorPainters(@NotNull PaintersHelper painters) {
painters.addPainter(PaintersHelper.newWallpaperPainter("idea.wallpaper.editor"), null);
PaintersHelper.initWallpaperPainter("idea.wallpaper.editor", painters);
}
public static void initFramePainters(@NotNull PaintersHelper painters) {
painters.addPainter(PaintersHelper.newWallpaperPainter("idea.wallpaper.ide"), null);
PaintersHelper.initWallpaperPainter("idea.wallpaper.ide", painters);
ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
String path = UIUtil.isUnderDarcula()? appInfo.getEditorBackgroundImageUrl() : null;
@@ -120,7 +120,17 @@ final class PaintersHelper implements Painter.Listener {
TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT
}
public static AbstractPainter newWallpaperPainter(final String propertyName) {
public static void initWallpaperPainter(@NotNull String propertyName, @NotNull PaintersHelper painters) {
String value = System.getProperty(propertyName);
if (value == null && !new File(PathManager.getConfigPath(), propertyName + ".png").exists()) {
// property not set & there's no default
return;
}
ImagePainter painter = (ImagePainter)newWallpaperPainter(propertyName);
painters.addPainter(painter, null);
}
private static AbstractPainter newWallpaperPainter(@NotNull final String propertyName) {
return new ImagePainter() {
Image image;
float alpha;