Mercurial > hg > Applications > TreeVNC
changeset 626:b37ae3e512cc
try to use affin transform for retina display
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Mar 2020 19:08:36 +0900 |
parents | 4d141e0b73cc |
children | 08de91a43141 |
files | src/viewer_swing/java/com/glavsoft/viewer/FbRectangle.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 3 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/FbRectangle.java Mon Mar 09 18:31:56 2020 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/FbRectangle.java Wed Mar 18 19:08:36 2020 +0900 @@ -1,22 +1,26 @@ package com.glavsoft.viewer; import java.awt.Rectangle; +import java.awt.geom.AffineTransform; /** * Created by one on 6/23/16. */ public class FbRectangle extends Rectangle { + AffineTransform aft; int retinaScale; int xfb; int yfb; int screenNumber; boolean isRetina; - public FbRectangle(int x, int y, int width, int height, int screenNumber, int scale, boolean isRetina) { + + public FbRectangle(int x, int y, int width, int height, int screenNumber, int scaleX, boolean b, AffineTransform aft) { super(x, y, width, height); this.screenNumber = screenNumber; - this.retinaScale = scale; + this.retinaScale = scaleX; this.isRetina = isRetina; + this.aft = aft; this.xfb = x; this.yfb = y; } @@ -59,6 +63,6 @@ @Override public String toString() { - return "FRectangle(x="+x+",y="+y+",xFb="+xfb+",yFb="+yfb+",w="+width+",h="+height+")"; + return "FRectangle(x="+x+",y="+y+",xFb="+xfb+",yFb="+yfb+",w="+width+",h="+height + ", "+ aft +")"; } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Mon Mar 09 18:31:56 2020 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Wed Mar 18 19:08:36 2020 +0900 @@ -39,6 +39,8 @@ import java.awt.*; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; import java.io.IOException; import java.io.InputStream; import java.net.Socket; @@ -368,10 +370,15 @@ @Override public boolean getIsRetinaDisplay(int shareScreenNumber) { + AffineTransform defaultTransform = getAffineTransform(shareScreenNumber); + return ! defaultTransform.isIdentity(); + } + + private AffineTransform getAffineTransform(int shareScreenNumber) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = env.getScreenDevices(); GraphicsConfiguration conf = devices[shareScreenNumber].getDefaultConfiguration(); - return ! conf.getDefaultTransform().isIdentity(); + return conf.getDefaultTransform(); } private ConnectionPresenter createNewConnectionPresenter(String hostName, short newVNCServerId, int x, int y, int width, int height, int scale) { @@ -533,7 +540,8 @@ ArrayList<FbRectangle> fbRectangles = new ArrayList<FbRectangle>(); int screenNumber = 0; for (Rectangle rect : rectangles) { - FbRectangle fbrect = new FbRectangle(rect.x, rect.y, rect.width, rect.height, screenNumber, retinaScale(screenNumber), getIsRetinaDisplay(screenNumber)); + AffineTransform aft = getAffineTransform(screenNumber); + FbRectangle fbrect = new FbRectangle(rect.x, rect.y, rect.width, rect.height, screenNumber, (int)aft.getScaleX(), !aft.isIdentity(),aft); fbrect.setXfb(rect.x + offset.x); fbrect.setYfb(rect.y + offset.y); fbRectangles.add(fbrect); @@ -571,6 +579,10 @@ fbRect.setYfb((int) (fbRect.getYfb() + retinaOffsetY)); fbRectanglesPrev = fbRect; } + for (int i = 1; i < fbRectangles.size(); i++) { + FbRectangle rect = fbRectangles.get(i); + double[] r = { rect.x, rect.y , rect.x+rect.width, rect.y+rect.height}; + } return fbRectangles; } @@ -586,6 +598,7 @@ return new Point(-offsetx,-offsety); } + @Override public int retinaScale(int shareScreenNumber) { int scale = 1; GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Mon Mar 09 18:31:56 2020 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Wed Mar 18 19:08:36 2020 +0900 @@ -906,7 +906,6 @@ int thisScreenWidth = (int) rectangles.get(thisScreenNumber).getWidth(); int thisScreenHeight = (int) rectangles.get(thisScreenNumber).getHeight(); - int thisRetinaScale = viewer.retinaScale(thisScreenNumber); final int thatScreenX = presenter.getX(); final int thatScreenY = presenter.getY();