Mercurial > hg > Applications > TreeVNC
changeset 277:2d39a1f9558d
create adjustHdSizeButton.
author | oc |
---|---|
date | Fri, 09 Jan 2015 16:50:13 +0900 |
parents | 0309ea3a4f4e |
children | 69e821effec6 |
files | src/main/java/com/glavsoft/rfb/client/SetEncodingsMessage.java src/main/java/com/glavsoft/rfb/encoding/EncodingType.java src/main/java/com/glavsoft/rfb/protocol/ProtocolSettings.java src/main/java/jp/ac/u_ryukyu/treevnc/ChengeDesktopSize.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 8 files changed, 62 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/client/SetEncodingsMessage.java Tue Jan 06 19:29:34 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/client/SetEncodingsMessage.java Fri Jan 09 16:50:13 2015 +0900 @@ -39,9 +39,9 @@ @Override public void send(Writer writer) throws TransportException { - writer.writeByte(SET_ENCODINGS); - writer.writeByte(0); // padding byte - writer.writeInt16(encodings.size()); + writer.writeByte(SET_ENCODINGS); + writer.writeByte(0); // padding byte + writer.writeInt16(encodings.size()); for (EncodingType enc : encodings) { writer.writeInt32(enc.getId()); }
--- a/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Tue Jan 06 19:29:34 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Fri Jan 09 16:50:13 2015 +0900 @@ -83,9 +83,9 @@ * Desktop Size Pseudo encoding allows to notificate client about * remote screen resolution changed. */ - DESKTOP_SIZE(0xFFFFFF21, "DesctopSize"), + DESKTOP_SIZE(0xFFFFFF21, "DesktopSize"), /** - * Cusros position encoding allows to transfer remote cursor position to + * Cursor position encoding allows to transfer remote cursor position to * client side. */ CURSOR_POS(0xFFFFFF18, "CursorPos"),
--- a/src/main/java/com/glavsoft/rfb/protocol/ProtocolSettings.java Tue Jan 06 19:29:34 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ProtocolSettings.java Fri Jan 09 16:50:13 2015 +0900 @@ -259,7 +259,7 @@ } else { encodings.add(preferredEncoding); // preferred first encodings.addAll(EncodingType.ordinaryEncodings); - if (compressionLevel > 0 && compressionLevel < 10) { + if (compressionLevel > 0 && compressionLevel < 10) { encodings.add(EncodingType.byId( EncodingType.COMPRESS_LEVEL_0.getId() + compressionLevel)); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ChengeDesktopSize.java Fri Jan 09 16:50:13 2015 +0900 @@ -0,0 +1,35 @@ +package jp.ac.u_ryukyu.treevnc; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import com.glavsoft.rfb.encoding.EncodingType; + +public class ChengeDesktopSize { + + private ByteBuffer msg; + + public ChengeDesktopSize(int width, int height, + 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) width); + msg.putShort((short) height); + msg.putInt(desktopSize.getId()); + msg.putInt(initData.length); + msg.put(initData); + + msg.flip(); + + } + + public ByteBuffer getMessage(){ + return msg; + } + + +}
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Jan 06 19:29:34 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Jan 09 16:50:13 2015 +0900 @@ -450,7 +450,7 @@ LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>(); int width = context.getFbWidth(); int height = context.getFbHeight(); - desktopSize.add(new UpdateRectangleMessage(width, height, EncodingType.INIT_DATA, context.getInitData(),id).getMessage()); + desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(),id).getMessage()); addSerialNumber(desktopSize); multicastqueue.put(desktopSize); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Tue Jan 06 19:29:34 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -package jp.ac.u_ryukyu.treevnc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.glavsoft.rfb.encoding.EncodingType; - -public class UpdateRectangleMessage { - - private ByteBuffer msg; - - public UpdateRectangleMessage(int width, int height, - 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) width); - msg.putShort((short) height); - msg.putInt(desktopSize.getId()); - msg.putInt(initData.length); - msg.put(initData); - - msg.flip(); - - } - - public ByteBuffer getMessage(){ - return msg; - } - - -}
--- a/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Tue Jan 06 19:29:34 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Fri Jan 09 16:50:13 2015 +0900 @@ -108,6 +108,18 @@ fireListeners(); } + public void adjustHdSize() { + // 今の画面サイズを取得 + // uiSettingsData.getScalePercent()を取得 + // 1920x1080にするためにはscaleを何に設定すれば良いのかを計算する + double scaleFactor = (int)(this.uiSettingsData.getScalePercent() / SCALE_PERCENT_ZOOMING_STEP) * SCALE_PERCENT_ZOOMING_STEP + SCALE_PERCENT_ZOOMING_STEP; + if (scaleFactor > MAX_SCALE_PERCENT) { + scaleFactor = MAX_SCALE_PERCENT; + } + setScalePercent(scaleFactor); + fireListeners(); + } + public void zoomAsIs() { setScalePercent(100); fireListeners();
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Jan 06 19:29:34 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Jan 09 16:50:13 2015 +0900 @@ -85,6 +85,7 @@ private Protocol workingProtocol; public int width; public int height; + private JButton adjustHdSizeButton; private boolean isZoomToFitSelected; @@ -363,6 +364,13 @@ uiSettings.zoomIn(); } }); + adjustHdSizeButton = buttonsBar.createButton("adjust-hd-size", "Adjust Hd Size", new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + adjustHdSizeButton.setSelected(false); + uiSettings.adjustHdSize(); + } + }); zoomAsIsButton = buttonsBar.createButton("zoom-100", "Zoom 100%", new ActionListener() { @Override public void actionPerformed(ActionEvent e) {