# HG changeset patch # User oc # Date 1425957644 -32400 # Node ID 62a6c779fd7fc06c0e99604ec5c8f3dc354e7c8b # Parent 59b1ef1b0a89ddeed17112c5689cee0ab0e96edf remove function about catch next display size diff -r 59b1ef1b0a89 -r 62a6c779fd7f src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Mar 03 17:58:41 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Mar 10 12:20:44 2015 +0900 @@ -70,13 +70,6 @@ private long checkCounter = 0; public int numberOfRectangles = 0; private Timer timer = null; - private int singleWidth; - private int singleHeight; - private int nextWidth; - private int nextHeight; - private boolean isHiDPI = false; - private int hiDPIWidth; - private int hiDPIHeight; public ReceiverTask(Reader reader, IRepaintController repaintController, ClipboardController clipboardController, @@ -121,16 +114,9 @@ } }, 0, 100); } - if(rfb.filterSingleDisplay) { - singleWidth = rfb.getSingleWidth(); - nextWidth = rfb.getNextWidth(); - isHiDPI = rfb.setHiDPI(singleWidth, singleHeight, nextWidth); - } } } - - @Override public void run() { isRunning = true; @@ -253,17 +239,7 @@ try { decoder.decode(reader, renderer, rect); // TreeVNC processing here if (rfb.getCuiVersion()) continue; - if (rfb.filterSingleDisplay) { - if (!isHiDPI) { - if (rect.x >= rfb.getSingleWidth()) { - continue; - } - } else { - if (rect.x >= rfb.getHiDPIWidth()) { - continue; - } - } - } + if (rfb.filterSingleDisplay && rect.x >= rfb.getSingleWidth()) continue; repaintController.repaintBitmap(rect); } catch (Exception e) { throw e; diff -r 59b1ef1b0a89 -r 62a6c779fd7f src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Tue Mar 03 17:58:41 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Tue Mar 10 12:20:44 2015 +0900 @@ -21,24 +21,20 @@ 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, int nextSingleWidth, int nextSingleHeight) { + public ScreenChangeRequest(String adr, int port, short id, int width, int height) { 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+8); + ByteBuffer out = ByteBuffer.allocate(bytes.length()+25); out.order(ByteOrder.BIG_ENDIAN); out.put(SERVER_CHANGE_REQUEST); out.put((byte)0); // padding @@ -47,8 +43,6 @@ 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(); diff -r 59b1ef1b0a89 -r 62a6c779fd7f src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Mar 03 17:58:41 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Mar 10 12:20:44 2015 +0900 @@ -74,15 +74,10 @@ private int singleWidth = 0; private int singleHeight = 0; - private int hiDPIWidth = 0; - private int hiDPIHeight = 0; - private DatagramSocket socket = null; private byte[] originalInitData = null; private boolean childrenMulticast = true; - private int nextSingleWidth; - private int nextSingleHeight; public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) { rThread = new RequestScreenThread(this); @@ -217,13 +212,9 @@ 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, id); + changeVNCServer(viewer, newHostName, port, frameSizeWidth, frameSizeHeight, id); if (viewer != null) { viewer.setFitScreen(); } @@ -742,22 +733,6 @@ bufs.addFirst(blen); bufs.addFirst(header); addSerialNumber(bufs); - - if (filterSingleDisplay) { - if (setHiDPI(singleWidth, singleHeight, nextSingleWidth)) { - if (rect.x <= hiDPIWidth) { - multicastqueue.put(bufs); - } - } else { - if (rect.x <= getSingleWidth()) { - multicastqueue.put(bufs); - } - } - } else { - multicastqueue.put(bufs); - } - - /* if (filterSingleDisplay) { if (rect.x < singleWidth) { multicastqueue.put(bufs); @@ -765,8 +740,6 @@ } else { multicastqueue.put(bufs); } - */ - } catch (IOException e) { throw new TransportException(e); } catch (DataFormatException e) { @@ -829,15 +802,24 @@ /** * change VNCServer is called when host change. - * + * * @param vncProxyService * @param hostName * HostAddress + * @param width + * FrameWidth + * @param height + * FrameHeight * @param newVNCServerId */ - public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, short newVNCServerId) + public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, int width, int height, 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. @@ -952,29 +934,6 @@ this.singleHeight = singleHeight; } - public void setNextSingleDisplaySize(int singleWidth, int singleHeight) { - this.nextSingleWidth = singleWidth; - this.nextSingleHeight = singleHeight; - } - - public void setHiDPISize(int hiDPIWidth, int hiDPIHeight) { - this.hiDPIWidth = hiDPIWidth; - this.hiDPIHeight = hiDPIHeight; - } - - public int getHiDPIWidth() { - return hiDPIWidth; - } - - public boolean setHiDPI(int singleWidth, int singleHeight, int nextWidth) { - int fbWidth = context.getFbWidth(); - if(fbWidth - nextWidth == singleWidth * 2) { - setHiDPISize(singleWidth * 2, singleHeight * 2); - return true; - } - return false; - } - public int getSingleWidth() { return singleWidth; @@ -984,14 +943,6 @@ return singleHeight; } - public int getNextWidth() { - return nextSingleWidth; - } - - public int getNextHeight() { - return nextSingleHeight; - } - public boolean hasParent() { return id != -1; } diff -r 59b1ef1b0a89 -r 62a6c779fd7f src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java --- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Mar 03 17:58:41 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Mar 10 12:20:44 2015 +0900 @@ -854,22 +854,17 @@ public void actionPerformed(ActionEvent e) { viewer.setVisible(false); - + float scaleFactor = getMyDisplayScaleFactor(); ArrayList rectangles = viewer.getScreenRectangles(); int leftScreenNumber = 0; - 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()); - + int singleWidth = (int) (rectangles.get(leftScreenNumber).getWidth() * scaleFactor); + int singleHeight = (int) (rectangles.get(leftScreenNumber).getHeight() * scaleFactor); + viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); if (viewer.getRfb().hasParent()) { String adr = viewer.getRfb().getMyAddress(); - context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, viewer.getRfb().getId(), singleWidth, singleHeight, nextSingleWidth, nextSingleHeight)); + context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, viewer.getRfb().getId(), singleWidth, singleHeight)); } if (viewer.getRfb().isTreeManager()) { - viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); - viewer.getRfb().setNextSingleDisplaySize(nextSingleWidth, nextSingleHeight); changeVncServer(viewer, singleWidth, singleHeight, viewer.getRfb().getId()); return; } @@ -933,6 +928,13 @@ 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 rectangles = viewer.getScreenRectangles(); int leftScreenNumber = 0; @@ -1019,7 +1021,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, id); + viewer.getRfb().changeVNCServer(viewer, localhost, ConnectionParams.DEFAULT_RFB_PORT, width, height, id); } catch (Exception e1) { System.out.println("can't change server :" + e1.getMessage()); }