Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 444:9a938b714c6b
fix fitScreen (remove all retina scale stuff)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jun 2016 10:39:39 +0900 |
parents | 967aa1f24ba4 |
children | c2323d1012d4 |
files | src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 2 files changed, 28 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Fri Jun 17 09:26:42 2016 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Fri Jun 17 10:39:39 2016 +0900 @@ -197,7 +197,7 @@ '}'; } - public void fitScreen(int thisScreenWidth, int thisScreenHeight, int singleWidth, int singleHeight) { + public double fitScreen(int thisScreenWidth, int thisScreenHeight, int singleWidth, int singleHeight) { double doubleThisWidth = (double) thisScreenWidth; double doubleThisHeight = (double) thisScreenHeight; double widthScale = (doubleThisWidth/singleWidth); @@ -215,5 +215,6 @@ } setScalePercent(scaleFactor); fireListeners(); + return scaleFactor; } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Jun 17 09:26:42 2016 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Jun 17 10:39:39 2016 +0900 @@ -983,41 +983,46 @@ // find which screen we are on Point thisScreenLocation = frame.getLocation(); - int leftScreenNumber = 0; + int thisScreenNumber = 0; for(Rectangle rect : rectangles) { if ( rect.contains(thisScreenLocation) ) break; - leftScreenNumber++; + thisScreenNumber++; } - int thisScreenWidth = (int) rectangles.get(leftScreenNumber).getWidth(); - int thisScreenHeight = (int) rectangles.get(leftScreenNumber).getHeight(); - + int thisScreenWidth = (int) rectangles.get(thisScreenNumber).getWidth(); + int thisScreenHeight = (int) rectangles.get(thisScreenNumber).getHeight(); + int thisRetinaScale = retinaScale(thisScreenNumber); final int thatScreenX = presenter.getX(); final int thatScreenY = presenter.getY(); - final int thatScreenWidth = presenter.getFrameSizeWidth()*presenter.getRetinaScale(); - final int thatScreenHeight = presenter.getFrameSizeHeight()*presenter.getRetinaScale(); - System.out.println("thatScreenX:" + thatScreenX); - System.out.println("thatScreenY:" + thatScreenY); - System.out.println("thisScreenWidth:" + thisScreenWidth); - System.out.println("thisScreenHeight:" + thisScreenHeight); - System.out.println("thatScreenWidth:" + thatScreenWidth); - System.out.println("thatScreenHeight:" + thatScreenHeight); - System.out.println("getMaximum:" + scroller.getHorizontalScrollBar().getMaximum()); - System.out.println("getMinmum:" + scroller.getHorizontalScrollBar().getMinimum()); + int thatRetinaScale = presenter.getRetinaScale(); + final int thatScreenWidth = presenter.getFrameSizeWidth()* thatRetinaScale; + final int thatScreenHeight = presenter.getFrameSizeHeight()* thatRetinaScale; + showScreenInfo("that", 0, thatScreenX, thatScreenY, thatScreenWidth, thatScreenHeight, thatRetinaScale); frame.setSize(thisScreenWidth, thisScreenHeight); - uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, thatScreenWidth, thatScreenHeight); + final double scale = uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, thatScreenWidth, thatScreenHeight); // final Rectangle visible = new Rectangle(thatScreenX,thatScreenY,thatScreenWidth,thatScreenHeight); - final double scale = (double)thisScreenWidth/(double)thatScreenWidth; - SwingUtilities.invokeLater(new Runnable(){ + showScreenInfo("this", thisScreenNumber, 0, 0,thisScreenWidth, thisScreenHeight, thisRetinaScale); + System.out.println("thisScrollScale: " + scale); + SwingUtilities.invokeLater(new Runnable() { public void run() { - scroller.getHorizontalScrollBar().setValue((int)(thatScreenX*scale)); - scroller.getVerticalScrollBar().setValue((int)(thatScreenY*scale)); - // scroller.scrollRectToVisible(visible); this does not work + scroller.getHorizontalScrollBar().setValue((int) (thatScreenX * scale)); + scroller.getVerticalScrollBar().setValue((int) (thatScreenY * scale)); + // scroller.scrollRectToVisible(visible); // this does not work } }); } + private void showScreenInfo(String name, int thisScreenNumber,int thisScreenX, int thisScreenY, int thisScreenWidth, int thisScreenHeight, int retinaScale) { + System.out.println(name + "RetinaScale:" + retinaScale); + System.out.println(name + "Screen:" + thisScreenNumber); + System.out.println(name + "ScreenX:" + thisScreenX); + System.out.println(name + "ScreenY:" + thisScreenY); + System.out.println(name + "ScreenWidth:" + thisScreenWidth); + System.out.println(name + "SreenHeight:" + thisScreenHeight); + System.out.println(); + } + private void sendCtrlAltDel(ProtocolContext context) { context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, true)); context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, true));