Mercurial > hg > Members > riono > TreeVNC_ja_comment
comparison src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java @ 451:65ffb64cfb51
try to fix scroll y in fitScreen
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 20 Jun 2016 12:04:13 +0900 |
parents | aa3822daf75a |
children | e94489c9a0bb |
comparison
equal
deleted
inserted
replaced
450:aa3822daf75a | 451:65ffb64cfb51 |
---|---|
914 | 914 |
915 setButtonsBarVisible(true, container); | 915 setButtonsBarVisible(true, container); |
916 } | 916 } |
917 | 917 |
918 public void screenChangeRequest(ProtocolContext context, int shareScreenNumber) { | 918 public void screenChangeRequest(ProtocolContext context, int shareScreenNumber) { |
919 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); | 919 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); |
920 Point offset = viewer.getScreenOffset(rectangles); | 920 Point offset = viewer.getScreenOffset(rectangles); |
921 Rectangle rectangle1 = rectangles.get(shareScreenNumber); | 921 Rectangle rectangle1 = rectangles.get(shareScreenNumber); |
922 int singleWidth = (int) (rectangle1.getWidth()); | 922 int singleWidth = (int) (rectangle1.getWidth()); |
923 int singleHeight = (int) (rectangle1.getHeight()); | 923 int singleHeight = (int) (rectangle1.getHeight()); |
924 int x = (int) (rectangle1.getX())+offset.x; // convert double to int | 924 int x = (int) (rectangle1.getX()) + offset.x; // convert double to int |
925 int y = (int) (rectangle1.getY())+offset.y; | 925 int y = (int) (rectangle1.getY()) + offset.y; |
926 int scale = retinaScale(shareScreenNumber); | 926 int scale = retinaScale(shareScreenNumber); |
927 viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); | 927 viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); |
928 showScreenInfo("request screen change",0, x,y,singleWidth,singleHeight,scale); | 928 showScreenInfo("request screen change", 0, x, y, singleWidth, singleHeight, scale); |
929 | 929 |
930 if (viewer.getRfb().isTreeManager()) { | 930 if (viewer.getRfb().isTreeManager()) { |
931 changeVncServer(viewer, x, y, singleWidth*scale, singleHeight*scale, scale, viewer.getRfb().getId()); | 931 changeVncServer(viewer, x, y, singleWidth * scale, singleHeight * scale, scale, viewer.getRfb().getId()); |
932 } else if (viewer.getRfb().hasParent()) { | 932 } |
933 if (viewer.getRfb().hasParent()) { | |
933 String adr = viewer.getRfb().getMyAddress(); | 934 String adr = viewer.getRfb().getMyAddress(); |
934 if (scanPort(adr, ConnectionParams.DEFAULT_RFB_PORT)) { | 935 if (scanPort(adr, ConnectionParams.DEFAULT_RFB_PORT)) { |
935 // -1 means request to reverse direct connection socket | 936 // -1 means request to reverse direct connection socket |
936 short id = viewer.getRfb().isTreeManager()? (short)-1 : viewer.getRfb().getId(); | 937 short id = viewer.getRfb().isTreeManager() ? (short) -1 : viewer.getRfb().getId(); |
937 context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, id, x, y, singleWidth*scale, singleHeight*scale, scale)); | 938 context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, id, x, y, singleWidth * scale, singleHeight * scale, scale)); |
938 } | 939 } |
939 } | 940 } |
940 } | 941 } |
941 | 942 |
942 private int retinaScale(int shareScreenNumber) { | 943 private int retinaScale(int shareScreenNumber) { |
943 int scale = 1; | 944 int scale = 1; |
973 return false; | 974 return false; |
974 } | 975 } |
975 } | 976 } |
976 | 977 |
977 /** | 978 /** |
978 * change screen viewer scale to fit the server screen size | 979 * change screen viewer scale to fit the selected server screen size in multi screens |
979 */ | 980 */ |
980 public void fitScreen() { | 981 public void fitScreen() { |
981 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); | 982 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); |
982 if (rectangles.size()<=0) return; // no screens, nothing to do | 983 if (rectangles.size()<=0) return; // no screens, nothing to do |
983 | 984 |
1003 frame.setSize(thisScreenWidth, thisScreenHeight); | 1004 frame.setSize(thisScreenWidth, thisScreenHeight); |
1004 double scale = uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, thatScreenWidth, thatScreenHeight); | 1005 double scale = uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, thatScreenWidth, thatScreenHeight); |
1005 // final Rectangle visible = new Rectangle((int)(thatScreenX*scale),(int)(thatScreenY*scale),(int)(thatScreenWidth*scale)-1,(int)(thatScreenHeight*scale)-1); | 1006 // final Rectangle visible = new Rectangle((int)(thatScreenX*scale),(int)(thatScreenY*scale),(int)(thatScreenWidth*scale)-1,(int)(thatScreenHeight*scale)-1); |
1006 showScreenInfo("this", thisScreenNumber, 0, 0,thisScreenWidth, thisScreenHeight, thisRetinaScale); | 1007 showScreenInfo("this", thisScreenNumber, 0, 0,thisScreenWidth, thisScreenHeight, thisRetinaScale); |
1007 System.out.println("this FB x:" + viewer.getConnectionPresenter().getFrameSizeWidth() + " y:" + viewer.getConnectionPresenter().getFrameSizeHeight()); | 1008 System.out.println("this FB x:" + viewer.getConnectionPresenter().getFrameSizeWidth() + " y:" + viewer.getConnectionPresenter().getFrameSizeHeight()); |
1008 System.out.println("thisScrollScale: " + scale); | 1009 System.out.println("thisScrollScale: " + scale + " ymax:"+scroller.getVerticalScrollBar().getMaximum()); |
1009 final int scrollx = (int)(thatScreenX * scale); | 1010 final int scrollx = (int)(thatScreenX * scale); |
1010 final int scrolly = (thatScreenY!=0) ? (int)((thatScreenHeight - thatScreenY) * scale) : 0; | 1011 final int scrolly = (int)((presenter.getFrameSizeHeight()-thatScreenY) * scale) ; |
1011 SwingUtilities.invokeLater(new Runnable() { | 1012 SwingUtilities.invokeLater(new Runnable() { |
1012 public void run() { | 1013 public void run() { |
1013 scroller.getHorizontalScrollBar().setValue(scrollx); | 1014 scroller.getHorizontalScrollBar().setValue(scrollx); |
1014 scroller.getVerticalScrollBar().setValue(scrolly); | 1015 scroller.getVerticalScrollBar().setValue(scrolly); |
1015 // scroller.scrollRectToVisible(visible); // this does not work | 1016 // scroller.scrollRectToVisible(visible); // this does not work |