# HG changeset patch # User one # Date 1466078899 -32400 # Node ID cee43ceac9b35f3d50756a2507b64a0c43f0f1ff # Parent eaf6dbcb42dc63021b6abbc1c4e08798efaa0de7 send thatscreen position INIT_DATA diff -r eaf6dbcb42dc -r cee43ceac9b3 src/main/java/com/glavsoft/rfb/protocol/Protocol.java --- a/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Thu Jun 16 20:35:44 2016 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Thu Jun 16 21:08:19 2016 +0900 @@ -126,6 +126,7 @@ @Override public void setFbWidth(int fbWidth) { this.fbWidth = fbWidth; + if (rfb != null) rfb.setWidth(fbWidth); } @Override @@ -146,6 +147,7 @@ @Override public void setFbHeight(int fbHeight) { this.fbHeight = fbHeight; + if (rfb != null) rfb.setHeight(fbHeight); } @Override @@ -324,8 +326,7 @@ @Override public int getNumberOfRectangle() { - int numberOfRectangles = receiverTask.numberOfRectangles; - return numberOfRectangles; + return receiverTask.numberOfRectangles; } @Override @@ -334,6 +335,16 @@ } @Override + public void setX(int x) { + if (rfb != null) rfb.setX(x); + } + + @Override + public void setY(int y) { + if (rfb != null) rfb.setY(y); + } + + @Override public void setTight(boolean isTight) { this.isTight = isTight; } diff -r eaf6dbcb42dc -r cee43ceac9b3 src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java --- a/src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java Thu Jun 16 20:35:44 2016 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java Thu Jun 16 21:08:19 2016 +0900 @@ -80,6 +80,10 @@ TreeRFBProto getRfb(); + void setX(int x); + + void setY(int y); + /** * TreeVNC expension command (server to client) * 0 : command byte @@ -88,7 +92,7 @@ * length : text * */ - public enum TreeCommand { + enum TreeCommand { FIND_ROOT (220), FIND_ROOT_REPLY (221), WHERE_TO_CONNECT (222), diff -r eaf6dbcb42dc -r cee43ceac9b3 src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Thu Jun 16 20:35:44 2016 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Thu Jun 16 21:08:19 2016 +0900 @@ -294,19 +294,21 @@ if (rect.getEncodingType() == EncodingType.INIT_DATA) { // VNCServer is changed, initiarize new screen. int length = reader.readInt32(); - byte[] initData = new byte[length]; + short id = reader.readInt16(); + byte[] initData = new byte[length-2]; reader.read(initData); String name = new String(initData, 24, length - 24, "UTF-8"); context.setRemoteDesktopName(name); context.setInitData(initData); context.setFbWidth(rect.width); context.setFbHeight(rect.height); + context.setX(rect.x); + context.setY(rect.y); repaintController.updateRemoteDesktopName(context); reader.reset(); // All children multicastqueue should be discarded here. // rfb.clearChildrenTransmission(); rfb.readSendData(length + 20, reader, null, rect); // size of UpdateRectangleMessage with initData. - short id = (short) rect.x; visible = (id != rfb.getId()); } synchronized (renderer.getLock()) { @@ -321,7 +323,7 @@ rfb.getViewer().setFitScreen(); } if (rfb.isTreeManager()) { - context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); + context.sendMessage(new FramebufferUpdateRequestMessage(rect.x, rect.y, rect.width, rect.height, false)); } } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { diff -r eaf6dbcb42dc -r cee43ceac9b3 src/main/java/jp/ac/u_ryukyu/treevnc/ChangeDesktopSize.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/ChangeDesktopSize.java Thu Jun 16 20:35:44 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ChangeDesktopSize.java Thu Jun 16 21:08:19 2016 +0900 @@ -10,21 +10,19 @@ private ByteBuffer msg; public ChangeDesktopSize(int width, int height, - int x, int y, byte[] initData, EncodingType desktopSize, short id) { + int x, int y, EncodingType desktopSize, byte[] initData, short id) { msg = ByteBuffer.allocate(16+4+initData.length).order(ByteOrder.BIG_ENDIAN); msg.put((byte) 0); // FrameBufferUpdate msg.put((byte) 0); // padding msg.putShort((short) 1); // number of rectangle - msg.putShort((short) id); - msg.putShort((short) 0); + msg.putShort((short) x); + msg.putShort((short) y); msg.putShort((short) width); msg.putShort((short) height); - msg.putShort((short) x); - msg.putShort((short) y); msg.putInt(desktopSize.getId()); - msg.putInt(initData.length); + msg.putInt(initData.length+2); + msg.putShort(id); msg.put(initData); - msg.flip(); } diff -r eaf6dbcb42dc -r cee43ceac9b3 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Thu Jun 16 20:35:44 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Thu Jun 16 21:08:19 2016 +0900 @@ -509,10 +509,9 @@ int height = context.getFbHeight(); if (filterSingleDisplay) { originalInitData = createOriginalInitData(singleWidth, singleHeight, context.getRemoteDesktopName()); -// desktopSize.add(new ChengeDesktopSize(singleWidth, singleHeight, EncodingType.INIT_DATA, originalInitData, id).getMessage()); - desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); + desktopSize.add(new ChangeDesktopSize(width, height, x, y, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); } else { - desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); + desktopSize.add(new ChangeDesktopSize(width, height, x, y, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); } if (addSerialNum) { addSerialNumber(desktopSize); @@ -991,4 +990,20 @@ } multicastqueue.put(errorAnnounce); } + + public void setX(int x) { + this.x = x; + } + + public void setY(int y) { + this.y = y; + } + + public void setWidth(int width) { + this.frameSizeWidth = width; + } + + public void setHeight(int height) { + this.frameSizeHeight = height; + } } \ No newline at end of file diff -r eaf6dbcb42dc -r cee43ceac9b3 src/viewer_swing/java/com/glavsoft/viewer/Viewer.java --- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Thu Jun 16 20:35:44 2016 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Thu Jun 16 21:08:19 2016 +0900 @@ -339,7 +339,7 @@ public void changeToDirectConnectedServer(String hostName, Reader is, Writer os, int x, int y, int width, int height, int scale) { final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, (short) -1, x, y, width, height, scale); connectionPresenter.startVNCConnection(this, true, is, os); - }; + } private ConnectionPresenter createNewConnectionPresenter(String hostName, short newVNCServerId, int x, int y, int width, int height, int scale) { final boolean hasJsch = checkJsch(); @@ -509,7 +509,7 @@ public void setFitScreen() { SwingViewerWindow v = connectionPresenter.getViewer(); if (v != null) { - v.zoomToFit(); + v.fitScreen(); } }