--- old/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java 2017-07-30 20:14:52.010110155 +0530 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java 2017-07-30 20:14:51.762110155 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,8 @@ import java.security.PrivilegedAction; import java.lang.reflect.InvocationTargetException; import sun.util.logging.PlatformLogger; +import java.awt.geom.AffineTransform; +import sun.java2d.pipe.Region; public class XTrayIconPeer implements TrayIconPeer, InfoWindow.Balloon.LiveArguments, @@ -549,21 +551,35 @@ static class TrayIconCanvas extends IconCanvas { TrayIcon target; boolean autosize; + final int width, height; TrayIconCanvas(TrayIcon target, int width, int height) { super(width, height); this.target = target; + this.width = width; + this.height = height; } // Invoke on EDT. protected void repaintImage(boolean doClear) { boolean old_autosize = autosize; + int old_curW = curW, old_curH = curH; autosize = target.isImageAutoSize(); - - curW = autosize ? width : image.getWidth(observer); - curH = autosize ? height : image.getHeight(observer); - - super.repaintImage(doClear || (old_autosize != autosize)); + AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(). + getDefaultTransform(); + int w = Region.clipScale(width, tx.getScaleX()); + int h = Region.clipScale(height, tx.getScaleY()); + int imgWidth = Region.clipScale(image.getWidth(observer), tx.getScaleX()); + int imgHeight = Region.clipScale(image.getHeight(observer), tx.getScaleY()); + + curW = autosize ? w : imgWidth; + curH = autosize ? h : imgHeight; + + // update the size before repainting + super.updateSize(curW, curH); + super.repaintImage(doClear || (old_autosize != autosize) || + (old_curW != curW || old_curH != curH)); } public void dispose() { @@ -576,12 +592,16 @@ public static class IconCanvas extends Canvas { volatile Image image; IconObserver observer; - int width, height; int curW, curH; IconCanvas(int width, int height) { - this.width = curW = width; - this.height = curH = height; + curW = width; + curH = height; + } + + public void updateSize(int width, int height) { + curW = width; + curH = height; } // Invoke on EDT.