# HG changeset patch # User riono # Date 1588070978 -32400 # Node ID 7071b01621c29bae03e59213432a05db4a9a0166 # Parent 710c26fd3ebeb2184edf4edcbd86f23af2b6c29a Determine ipv4 or ipv6 and fix scond display diff -r 710c26fd3ebe -r 7071b01621c2 build.gradle --- a/build.gradle Sun Mar 22 20:04:21 2020 +0900 +++ b/build.gradle Tue Apr 28 19:49:38 2020 +0900 @@ -7,8 +7,8 @@ apply plugin: 'application' -sourceCompatibility = JavaVersion.VERSION_13 -targetCompatibility = JavaVersion.VERSION_13 +sourceCompatibility = JavaVersion.VERSION_12 +targetCompatibility = JavaVersion.VERSION_12 version = '3.0.0' project.ext.baseName = 'tightvnc-jviewer' diff -r 710c26fd3ebe -r 7071b01621c2 src/main/java/jp/ac/u_ryukyu/treevnc/FindRoot.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/FindRoot.java Sun Mar 22 20:04:21 2020 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/FindRoot.java Tue Apr 28 19:49:38 2020 +0900 @@ -5,10 +5,7 @@ import java.io.BufferedReader; import java.io.IOException; -import java.net.DatagramPacket; -import java.net.InetAddress; -import java.net.MulticastSocket; -import java.net.ServerSocket; +import java.net.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -29,9 +26,17 @@ */ public FindRoot(int _port, CreateConnectionParam createConnectionParam) { port = _port; + boolean isIpv6Address = false; try { - soc = TreeRootFinderListener.createMulticastSocket(); - mAddr = InetAddress.getByName(TreeRootFinderListener.McastAddr); + mAddr = InetAddress.getByName(TreeRootFinderListener.McastAddr); + if(mAddr instanceof Inet6Address) { + isIpv6Address = true; + System.out.println("connect ipv6"); + } else if(mAddr instanceof Inet4Address) { + isIpv6Address = false; + System.out.println("connect ipv4"); + } + soc = TreeRootFinderListener.createMulticastSocket(isIpv6Address); System.out.println("FindRoot socket on " + TreeRootFinderListener.McastAddr + " " + mAddr + " port " + _port); } catch (IOException e) { System.out.println("cannot create FindRoot socket. " + e); diff -r 710c26fd3ebe -r 7071b01621c2 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Sun Mar 22 20:04:21 2020 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Tue Apr 28 19:49:38 2020 +0900 @@ -15,7 +15,7 @@ public class TreeRootFinderListener implements Runnable { public static final String Ipv4McastAddr = "224.0.0.1"; public static final String Ipv6McastAddr = "ff02::1"; - public static String McastAddr = Ipv4McastAddr; + public static String McastAddr = Ipv6McastAddr; static final int BufSize = 1024; private boolean stopFlag = false; @@ -26,24 +26,28 @@ public TreeRootFinderListener(ViewerInterface vncProxyService) { vps = vncProxyService; try { - soc = createMulticastSocket(); + soc = + createMulticastSocket(true); System.out.println("FindRoot listening on "+ InetAddress.getByName(McastAddr)); } catch (IOException e) { e.printStackTrace(); } } - public static MulticastSocket createMulticastSocket() throws IOException { + public static MulticastSocket createMulticastSocket(boolean isIpv6Address) throws IOException { MulticastSocket soc = new MulticastSocket(ConnectionParams.DEFAULT_VNC_ROOT_FINDER); - try { - soc.joinGroup(InetAddress.getByName(McastAddr)); - } catch (SocketException e) { - System.out.println("join to " + Ipv4McastAddr + " failed."); - } - try { - soc.joinGroup(InetAddress.getByName(Ipv6McastAddr)); - } catch (SocketException e) { - System.out.println("join to " + Ipv6McastAddr + " failed."); + if (isIpv6Address) { + try { + soc.joinGroup(InetAddress.getByName(Ipv6McastAddr)); + } catch (SocketException e) { + System.out.println("join to " + Ipv6McastAddr + " failed."); + } + } else { + try { + soc.joinGroup(InetAddress.getByName(McastAddr)); + } catch (SocketException e) { + System.out.println("join to " + Ipv4McastAddr + " failed."); + } } return soc; } diff -r 710c26fd3ebe -r 7071b01621c2 src/viewer_swing/java/com/glavsoft/viewer/Viewer.java --- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Sun Mar 22 20:04:21 2020 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Tue Apr 28 19:49:38 2020 +0900 @@ -554,7 +554,7 @@ FbRectangle fbRectanglesPrev = fbRectangles.get(0); for (int i = 1; i < fbRectangles.size(); i++) { FbRectangle fbRect = fbRectangles.get(i); - if (fbRect.getIsRetina()) { + if (fbRectanglesPrev.getRetinaScale() != 1) { if (fbRectanglesPrev.x + fbRectanglesPrev.width <= fbRect.x) { // previous screen is touch with this screen, fix retina scale offset retinaOffsetX += fbRectanglesPrev.getWidth() * (fbRectanglesPrev.retinaScale - 1); @@ -570,7 +570,7 @@ fbRectanglesPrev = fbRectangles.get(0); for (int i = 1; i < fbRectangles.size(); i++) { FbRectangle fbRect = fbRectangles.get(i); - if (fbRect.getIsRetina()) { + if (fbRectanglesPrev.getRetinaScale() != 1) { if (fbRectanglesPrev.y + fbRectanglesPrev.height <= fbRect.y) { // previous screen is touch with this screen, fix retina scale offset retinaOffsetY += fbRectanglesPrev.getHeight() * (fbRectanglesPrev.retinaScale - 1); @@ -609,6 +609,7 @@ final GraphicsDevice[] devices = env.getScreenDevices(); GraphicsConfiguration conf = devices[shareScreenNumber].getDefaultConfiguration(); scale = (int)conf.getDefaultTransform().getScaleX(); + System.out.println("scale:" + scale + "\n\n"); return scale; }