Mercurial > hg > Applications > TreeVNC
changeset 257:11b59b223222
add function of fixing display size
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Mon Dec 01 17:03:27 2014 +0900 @@ -282,6 +282,7 @@ @Override public void sendRefreshMessage() { sendMessage(new FramebufferUpdateRequestMessage(0, 0, fbWidth, fbHeight, false)); + // sendMessage(new FramebufferUpdateRequestMessage(0, 0, 1920, 1080, false)); logger.fine("sent: full FB Refresh"); }
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Dec 01 17:03:27 2014 +0900 @@ -226,13 +226,13 @@ this.firstTime = false; } - if(rfb.fixRetinaDisplay) { + if(rfb.fixingSize) { timer = new Timer(true); timer.schedule(new TimerTask() { @Override public void run() { - context.setFbWidth(1280); - context.setFbHeight(800); + context.setFbWidth(rfb.fixingSizeWidth); + context.setFbHeight(rfb.fixingSizeHeight); context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true)); } }, 0, 100);
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Mon Dec 01 17:03:27 2014 +0900 @@ -21,22 +21,28 @@ public class ScreenChangeRequest implements ClientToServerMessage { final String bytes; private short id; + private int frameSizeWidth; + private int frameSizeHeight; - public ScreenChangeRequest(String adr, short id) { + public ScreenChangeRequest(String adr, short id, int width, int height) { this.bytes = adr; this.id = id; + this.frameSizeWidth = width; + this.frameSizeHeight = height; System.out.println("Client send change screen server request :" + adr); } @Override public void send(Writer writer) throws TransportException { - ByteBuffer out = ByteBuffer.allocate(bytes.length()+16); + ByteBuffer out = ByteBuffer.allocate(bytes.length()+25); out.order(ByteOrder.BIG_ENDIAN); out.put(SERVER_CHANGE_REQUEST); - out.put((byte)0); - out.putShort(id); // padding + out.put((byte)0); // padding + out.putShort(id); out.putInt(bytes.length()); out.put(bytes.getBytes()); + out.putInt(frameSizeWidth); + out.putInt(frameSizeHeight); writer.write(out.array(), 0, out.position()); writer.flush(); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Mon Dec 01 17:03:27 2014 +0900 @@ -19,7 +19,6 @@ import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.client.ClientToServerMessage; -import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.rfb.protocol.Protocol; import com.glavsoft.rfb.protocol.ProtocolContext; @@ -67,7 +66,12 @@ public LinkedList<TreeVNCNode> nodeList; public boolean checkDelay = false; public boolean addSerialNum = false; - public boolean fixRetinaDisplay = false; + public boolean fixingSize = false; + public int frameSizeWidth; + public int frameSizeHeight; + public int fixingSizeWidth; + public int fixingSizeHeight; + public TreeRFBProto(boolean isTreeManager) { @@ -157,27 +161,28 @@ if (permitChangeScreen()) { ByteBuffer buf = ByteBuffer.wrap(b); buf.order(ByteOrder.BIG_ENDIAN); - short id = buf.getShort(2); - int length = buf.getInt(4); + buf.get(); + buf.get(); + short id = buf.getShort(); + int length = buf.getInt(); if (length == 0) - continue; - String newHostName = new String(b, 8, length); + continue; + byte[] byteAddress = new byte[length]; + buf.get(byteAddress); + String newHostName = new String(byteAddress, "UTF-8"); + int frameSizeWidth = buf.getInt(); + int frameSizeHeight = buf.getInt(); System.out.println("Root server change request :" + newHostName); // please remove these numbers. if (viewer != null) { - changeVNCServer(viewer, newHostName, 3200, 1980, id); + changeVNCServer(viewer, newHostName, frameSizeWidth, frameSizeHeight, id); } } else { continue; } } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) { - - //int numberOfRectangle = context.getNumberOfRectangle(); - //System.out.println("numberOfRectAngle : " + numberOfRectangle); - ByteBuffer buf = ByteBuffer.wrap(b); buf.order(ByteOrder.BIG_ENDIAN); - // getNodeNum(port, hostname, localhostname); buf.getShort(); Long time = buf.getLong(); int port = buf.getInt(); @@ -690,6 +695,12 @@ */ public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int width, int height, short id) throws UnknownHostException, IOException, InterruptedException { + + this.fixingSizeWidth = vncProxyService.getFixingWidth(); + this.fixingSizeHeight = vncProxyService.getFixingHeight(); + this.frameSizeWidth = width; + this.frameSizeHeight = height; + // stop reader stop stopReceiverTask(); reconnectingId = id; @@ -775,7 +786,7 @@ return nodeNum; } - public void setFixRetinaDisplay(boolean fixRetinaDisplay) { - this.fixRetinaDisplay = fixRetinaDisplay; + public void setFixingSize(boolean fixingSize) { + this.fixingSize = fixingSize; } } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Mon Dec 01 17:03:27 2014 +0900 @@ -31,7 +31,7 @@ InetAddress mAddr = InetAddress.getByName(McastAddr); soc = new MulticastSocket(ConnectionParams.DEFAULT_VNC_ROOT_FINDER); DatagramPacket recvPacket = new DatagramPacket(buf, BufSize); - soc.joinGroup(mAddr); + soc.joinGroup(mAddr); while (!stopFlag) { soc.receive(recvPacket); String hostname = recvPacket.getAddress().getHostAddress(); @@ -58,7 +58,7 @@ if(stopFlag) break; } } catch (Exception e) { - System.out.println("tree-root-find-listener :" + e.getMessage()); + System.out.println("tree-root-find-listener :" + e.getMessage()); } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Mon Dec 01 17:03:27 2014 +0900 @@ -259,7 +259,7 @@ } @Override - public void proxyStart(String[] args, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixRetinaDisplay) { + public void proxyStart(String[] args, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize) { } @@ -292,5 +292,34 @@ height = h; } + @Override + public int getFixingWidth() { + return 0; + } + + @Override + public int getFixingHeight() { + return 0; + } + + @Override + public void setFixingSize(int width, int height) { + + } + + @Override + public int getFrameWidth() { + return 0; + } + + @Override + public int getFrameHeight() { + return 0; + } + + @Override + public void setFrameSize(int width, int height) { + + } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Mon Dec 01 17:03:27 2014 +0900 @@ -8,13 +8,16 @@ private boolean cui = false; private int width; private int height; + private int fixingSizeWidth; + private int fixingSizeHeight; private String hostName = null; private boolean noConnection = false; private boolean permitChangeScreen = true; private boolean showTree = false; private boolean checkDelay = false; private boolean addSerialNum = false; - private boolean fixRetinaDisplay = false; + private boolean fixingSizeDisplay = false; + public static void main(String[] args) { new TreeViewer().vncStart(args); @@ -31,6 +34,9 @@ if (viewer) { ViewerInterface v = cui ? new CuiViewer() : new Viewer(); setWidthAndHeight(v); + if(fixingSizeDisplay) { + setFixingSizeDisplay(v); + } if (treeProxy) { // this viewer also works as tree root ( display mode -d flag ) // start with no connection waiting server change request @@ -45,7 +51,7 @@ public void rootStart(String[] args, ViewerInterface v) { v.setNoConnection(noConnection); // should we accept host name here? - v.proxyStart(args,width,height, showTree, checkDelay, addSerialNum, fixRetinaDisplay); + v.proxyStart(args,width,height, showTree, checkDelay, addSerialNum, fixingSizeDisplay); v.getRfb().setHasViewer(viewer); if (!permitChangeScreen ) v.getRfb().setPermitChangeScreen(false); v.getRfb().getAcceptThread().waitForShutdown(); @@ -79,12 +85,12 @@ permitChangeScreen = false; } else if ("--noScreenChange".equals(args[i])) { permitChangeScreen = false; - } else if ("--retina".equals(args[i])) { + } else if ("--fixingSize".equals(args[i])) { // retina display too large for TreeVNC. // restrict display size. - width = 1280; - height = 800; - fixRetinaDisplay = true; + fixingSizeWidth = 1280; + fixingSizeHeight = 800; + fixingSizeDisplay = true; } else if ("--width".equals(args[i])) { width = Integer.parseInt(args[i+1]); i++; @@ -125,7 +131,11 @@ v.setWidth(width); v.setHeight(height); } - } + } + + public void setFixingSizeDisplay(ViewerInterface v) { + v.setFixingSize(fixingSizeWidth, fixingSizeHeight); + } private boolean isInteger(String num) { try {
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Mon Dec 01 17:03:27 2014 +0900 @@ -72,6 +72,10 @@ private boolean showTree = false; public int width; public int height; + public int fixingSizeWidth; + public int fixingSizeHeight; + public int frameSizeWidth; + public int frameSizeHeight; public static void main(String[] args) { @@ -363,7 +367,7 @@ run(); } - public void proxyStart(String[] argv, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixRetinaDisplay) { + public void proxyStart(String[] argv, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize) { fbWidth = width; this.showTree = showTree; // input into arguments Decision @@ -381,7 +385,7 @@ rfb.setShowTree(showTree); rfb.setCheckDelay(checkDelay); rfb.setAddSerialNum(addSerialNum); - rfb.setFixRetinaDisplay(fixRetinaDisplay); + rfb.setFixingSize(fixingSize); rfb.setViewer(this); rfb.setCuiVersion(false); rfb.setHasViewer(true); // this flag will be overwrited after this method. Do we have to set here? @@ -430,4 +434,36 @@ height = h; } + @Override + public int getFixingWidth() { + return fixingSizeWidth; + } + + @Override + public int getFixingHeight() { + return fixingSizeHeight; + } + + @Override + public void setFixingSize(int width, int height) { + this.fixingSizeWidth = width; + this.fixingSizeHeight = height; + } + + @Override + public int getFrameWidth() { + return frameSizeWidth; + } + + @Override + public int getFrameHeight() { + return frameSizeHeight; + } + + @Override + public void setFrameSize(int width, int height) { + this.frameSizeWidth = width; + this.frameSizeHeight = height; + } + }
--- a/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Mon Dec 01 17:03:27 2014 +0900 @@ -29,7 +29,7 @@ public void inhelitClients(ViewerInterface vncProxyService, String hostName); - public void proxyStart(String[] args, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixRetinaDisplay); + public void proxyStart(String[] args, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize); public void setNoConnection(boolean noConnection); @@ -43,4 +43,16 @@ public void setHeight(int height); + public int getFixingWidth(); + + public int getFixingHeight(); + + public void setFixingSize(int width, int height); + + public int getFrameWidth(); + + public int getFrameHeight(); + + public void setFrameSize(int width, int height); + }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Nov 18 14:10:53 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Mon Dec 01 17:03:27 2014 +0900 @@ -85,6 +85,7 @@ public int width; public int height; + private boolean isZoomToFitSelected; private List<JComponent> kbdButtons; @@ -152,7 +153,7 @@ } }; Dimension outerPanelSize = outerPanel.getSize(); - double width = outerPanel.getSize().getWidth(); + double width = outerPanelSize.getWidth(); double height = outerPanelSize.getHeight(); outerPanel.setBackground(Color.DARK_GRAY); lpane = new JLayeredPane() { @@ -846,7 +847,11 @@ // before change server, data from previous server // should be stopped. viewer.setCuiVersion(false); - if (viewer.getRfb().isTreeManager()) { + + Dimension size = frame.getSize(); + viewer.setFrameSize(size.width, size.height); + + if (viewer.getRfb().isTreeManager()) { try { viewer.getRfb().changeVNCServer(viewer, "127.0.0.1", 1980, 1090, viewer.getRfb().getId()); } catch (Exception e1) { @@ -855,7 +860,7 @@ return; } String adr = viewer.getRfb().getMyAddress(); - context.sendMessage(new ScreenChangeRequest(adr, viewer.getRfb().getId())); + context.sendMessage(new ScreenChangeRequest(adr, viewer.getRfb().getId(), size.width, size.height)); } }); kbdButtons.add(screenButton);