Mercurial > hg > Applications > TreeVNC
changeset 303:1526c99f5d21
upgrade createOriginalInitData.
author | oc |
---|---|
date | Tue, 20 Jan 2015 11:40:16 +0900 |
parents | 7ef19658eb41 |
children | d2a56d7d4b2d |
files | src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionsHistory.java |
diffstat | 2 files changed, 35 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Mon Jan 19 22:39:02 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Tue Jan 20 11:40:16 2015 +0900 @@ -1,4 +1,5 @@ package jp.ac.u_ryukyu.treevnc; +import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.Socket; @@ -219,36 +220,54 @@ } void sendInitData(Writer os) throws TransportException { - int hdWidth = 1920; - int hdHeight = 1080; - byte[] initData = createOriginalInitData(hdWidth, hdHeight); - // In case of "-d" we have no context + int width = rfb.singleWidth; + int height = rfb.singleHeight; ProtocolContext context = rfb.context; - if (context != null){ -// os.write(context.getInitData()); - os.write(initData); + if (context != null) { + byte[] initData = createOriginalInitData(width, height, context.getRemoteDesktopName()); + if (rfb.filterSingleDisplay) { + os.write(initData); + } else { + os.write(context.getInitData()); + } } else { + // In case of "-d" we have no context // Send dummy data - os.write(initData); + // width : 1920 + // height : 1080 + // title : "girefly" + byte[] dummyInitData = {7, -128, 4, 56, 32, 24, 0, 1, 0, -1, 0, -1, 0, -1, 16, 8, 0, 0, 0, 0, 0, 0, 0, 7, 103, 105, 114, 101, 102, 108, 121}; + os.write(dummyInitData); } } - private byte[] createOriginalInitData(int width, int height) { - byte[] tail = {32, 24, 0, 1, 0, -1, 0, -1, 0, -1, 16, 8, 0, 0, 0, 0, 0, 0, 0, 7, 103, 105, 114, 101, 102, 108, 121}; - ByteBuffer initData = ByteBuffer.allocate(31); - initData.putChar((char) width); - initData.putChar((char) height); - initData.put(tail); + private byte[] createOriginalInitData(int width, int height, String desktopName) { + byte[] titleBytes = null; + int titleLength = 0; + byte[] pixelFormat = {32, 24, 0, 1, 0, -1, 0, -1, 0, -1, 16, 8, 0, 0, 0, 0, 0, 0, 0}; + try { + titleBytes = desktopName.getBytes("UTF-8"); + titleLength = titleBytes.length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + ByteBuffer initData = ByteBuffer.allocate(2+2+19+1+titleLength); // w+h+pixelFormat+titleLength+titleBytes + initData.putShort((short) width); + initData.putShort((short) height); + initData.put(pixelFormat); + initData.put((byte) titleLength); + initData.put(titleBytes); initData.flip(); return initData.array(); } public void waitForShutdown() { - if (acceptThread!=null) + if (acceptThread!=null) { try { acceptThread.join(); } catch (InterruptedException e) { } + } } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionsHistory.java Mon Jan 19 22:39:02 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionsHistory.java Tue Jan 20 11:40:16 2015 +0900 @@ -261,7 +261,7 @@ if (uiSettingsData != null) { uiSettingsDataMap.put(new ConnectionParams(connectionParams), new UiSettingsData(uiSettingsData)); } - uiSettingsData.setScalePercent(100); +// uiSettingsData.setScalePercent(100); } /**