Mercurial > hg > Applications > TreeVNC
changeset 356:2b4251bd5996
set next display size
author | oc |
---|---|
date | Tue, 24 Feb 2015 18:10:24 +0900 |
parents | 82825c322044 |
children | 7c763b2a01a5 |
files | .idea/gradle.xml .idea/libraries/Gradle__com_jcraft_jsch_0_1_50.xml TreeVNC.iml src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 6 files changed, 40 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/.idea/gradle.xml Mon Feb 23 18:46:48 2015 +0900 +++ b/.idea/gradle.xml Tue Feb 24 18:10:24 2015 +0900 @@ -14,4 +14,5 @@ </GradleProjectSettings> </option> </component> -</project> \ No newline at end of file +</project> +
--- a/.idea/libraries/Gradle__com_jcraft_jsch_0_1_50.xml Mon Feb 23 18:46:48 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -<component name="libraryTable"> - <library name="Gradle: com.jcraft:jsch:0.1.50"> - <CLASSES> - <root url="jar://$PROJECT_DIR$/src/libs/jsch-0.1.50.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> -</component> \ No newline at end of file
--- a/TreeVNC.iml Mon Feb 23 18:46:48 2015 +0900 +++ b/TreeVNC.iml Tue Feb 24 18:10:24 2015 +0900 @@ -1,23 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> -<module external.linked.project.id="TreeVNC" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="2.7.2" type="JAVA_MODULE" version="4"> +<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="2.7.2" type="JAVA_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="false"> <output url="file://$MODULE_DIR$/build/classes/main" /> <output-test url="file://$MODULE_DIR$/build/classes/test" /> <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/viewerSwing/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/viewer_swing/java" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/viewerSwing/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/viewerSwing/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/viewer_swing/resources" type="java-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/viewerSwing/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> <excludeFolder url="file://$MODULE_DIR$/.gradle" /> <excludeFolder url="file://$MODULE_DIR$/build" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" exported="" name="Gradle: com.jcraft:jsch:0.1.50" level="project" /> + <orderEntry type="library" exported="" name="Gradle: jsch-0.1.50" level="project" /> </component> -</module> \ No newline at end of file +</module> +
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Mon Feb 23 18:46:48 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Tue Feb 24 18:10:24 2015 +0900 @@ -21,20 +21,24 @@ private short id; private int frameSizeWidth; private int frameSizeHeight; + private int nextSingleWidth; + private int nextSingleHeight; private int port; - public ScreenChangeRequest(String adr, int port, short id, int width, int height) { + public ScreenChangeRequest(String adr, int port, short id, int width, int height, int nextSingleWidth, int nextSingleHeight) { this.bytes = adr; this.port = port; this.id = id; this.frameSizeWidth = width; this.frameSizeHeight = height; + this.nextSingleWidth = nextSingleWidth; + this.nextSingleHeight = nextSingleHeight; System.out.println("Client send change screen server request :" + adr); } @Override public void send(Writer writer) throws TransportException { - ByteBuffer out = ByteBuffer.allocate(bytes.length()+25); + ByteBuffer out = ByteBuffer.allocate(bytes.length()+25+8); out.order(ByteOrder.BIG_ENDIAN); out.put(SERVER_CHANGE_REQUEST); out.put((byte)0); // padding @@ -43,6 +47,8 @@ out.put(bytes.getBytes()); out.putInt(frameSizeWidth); out.putInt(frameSizeHeight); + out.putInt(nextSingleWidth); + out.putInt(nextSingleHeight); out.putInt(port); writer.write(out.array(), 0, out.position()); writer.flush();
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Mon Feb 23 18:46:48 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Feb 24 18:10:24 2015 +0900 @@ -78,6 +78,8 @@ private byte[] originalInitData = null; private boolean childrenMulticast = true; + public int nextSingleWidth; + public int nextSingleHeight; public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) { rThread = new RequestScreenThread(this); @@ -212,9 +214,13 @@ String newHostName = new String(byteAddress, "UTF-8"); int frameSizeWidth = buf.getInt(); int frameSizeHeight = buf.getInt(); + int nextSingleWidth = buf.getInt(); + int nextSingleHeight = buf.getInt(); + setSingleDisplaySize(frameSizeWidth, frameSizeHeight); + setNextSingleDisplaySize(nextSingleWidth, nextSingleHeight); int port = buf.getInt(); System.out.println("Root server change request :" + newHostName + " : " + port); - changeVNCServer(viewer, newHostName, port, frameSizeWidth, frameSizeHeight, id); + changeVNCServer(viewer, newHostName, port, id); if (viewer != null) { viewer.setFitScreen(); } @@ -806,20 +812,11 @@ * @param vncProxyService * @param hostName * HostAddress - * @param width - * FrameWidth - * @param height - * FrameHeight * @param newVNCServerId */ - public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, int width, int height, short newVNCServerId) + public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, short newVNCServerId) throws IOException { - this.frameSizeWidth = width; - this.frameSizeHeight = height; - singleWidth = frameSizeWidth; - singleHeight = frameSizeHeight; - if (newVNCServerId == -1) { // change to the tree vnc root on other network. // send whereToConnect. @@ -934,6 +931,11 @@ this.singleHeight = singleHeight; } + public void setNextSingleDisplaySize(int singleWidth, int singleHeight) { + this.nextSingleWidth = singleWidth; + this.nextSingleWidth = singleHeight; + } + public int getSingleWidth() { return singleWidth; }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Mon Feb 23 18:46:48 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Feb 24 18:10:24 2015 +0900 @@ -854,17 +854,22 @@ public void actionPerformed(ActionEvent e) { viewer.setVisible(false); - float scaleFactor = getMyDisplayScaleFactor(); + ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); int leftScreenNumber = 0; - int singleWidth = (int) (rectangles.get(leftScreenNumber).getWidth() * scaleFactor); - int singleHeight = (int) (rectangles.get(leftScreenNumber).getHeight() * scaleFactor); - viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); + int rightScreenNumber = 1; + int singleWidth = (int) (rectangles.get(leftScreenNumber).getWidth()); + int singleHeight = (int) (rectangles.get(leftScreenNumber).getHeight()); + int nextSingleWidth = (int) (rectangles.get(rightScreenNumber).getWidth()); + int nextSingleHeight = (int) (rectangles.get(rightScreenNumber).getHeight()); + if (viewer.getRfb().hasParent()) { String adr = viewer.getRfb().getMyAddress(); - context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, viewer.getRfb().getId(), singleWidth, singleHeight)); + context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, viewer.getRfb().getId(), singleWidth, singleHeight, nextSingleWidth, nextSingleHeight)); } if (viewer.getRfb().isTreeManager()) { + viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); + viewer.getRfb().setNextSingleDisplaySize(nextSingleWidth, nextSingleHeight); changeVncServer(viewer, singleWidth, singleHeight, viewer.getRfb().getId()); return; } @@ -928,13 +933,6 @@ setButtonsBarVisible(true, container); } - private float getMyDisplayScaleFactor() { - final String CONTENT_SCALE_FACTOR = "java.awt.contentScaleFactor"; - Float scaleFactor = (Float) Toolkit.getDefaultToolkit().getDesktopProperty(CONTENT_SCALE_FACTOR); - - return scaleFactor == null ? 1.0f : scaleFactor; - } - public void fitScreen() { ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); int leftScreenNumber = 0; @@ -1021,7 +1019,7 @@ private void changeVncServer(ViewerInterface viewer, int width, int height, short id) { String localhost = "127.0.0.1"; // InetAddress.getLocalHost().getHostName() try { - viewer.getRfb().changeVNCServer(viewer, localhost, ConnectionParams.DEFAULT_RFB_PORT, width, height, id); + viewer.getRfb().changeVNCServer(viewer, localhost, ConnectionParams.DEFAULT_RFB_PORT, id); } catch (Exception e1) { System.out.println("can't change server :" + e1.getMessage()); }