changeset 461:b7d43b12651c

fix getFbRectangles x may have minus value now, but xFb is always plus
author kono
date Mon, 04 Jul 2016 18:41:14 +0900
parents c6058c4e2a79
children b5459c7c8e4d
files src/viewer_swing/java/com/glavsoft/viewer/Viewer.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java
diffstat 2 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Mon Jun 27 18:07:29 2016 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Mon Jul 04 18:41:14 2016 +0900
@@ -502,7 +502,10 @@
         ArrayList<FbRectangle> fbRectangles = new ArrayList<FbRectangle>();
         int screenNumber = 0;
         for (Rectangle rect : rectangles) {
-            fbRectangles.add(new FbRectangle(rect.x + offset.x, rect.y + offset.y, rect.width, rect.height, screenNumber, retinaScale(screenNumber)));
+            FbRectangle fbrect = new FbRectangle(rect.x, rect.y, rect.width, rect.height, screenNumber, retinaScale(screenNumber));
+            fbrect.setXfb(rect.x + offset.x);
+            fbrect.setXfb(rect.y + offset.y);
+            fbRectangles.add(fbrect);
             screenNumber++;
         }
 
@@ -525,7 +528,7 @@
                     retinaOffsetX += fbRectanglesPrev.getWidth() * (fbRectanglesPrev.retinaScale - 1);
                 }
             }
-            fbRect.setXfb((int) (fbRect.getX() + retinaOffsetX));
+            fbRect.setXfb((int) (fbRect.getXfb() + retinaOffsetX));
             fbRectanglesPrev = fbRect;
         }
 
@@ -548,7 +551,7 @@
                     retinaOffsetY += fbRectanglesPrev.getHeight() * (fbRectanglesPrev.retinaScale - 1);
                 }
             }
-            fbRect.setYfb((int) (fbRect.getY() + retinaOffsetY));
+            fbRect.setYfb((int) (fbRect.getYfb() + retinaOffsetY));
             fbRectanglesPrev = fbRect;
         }
         return fbRectangles;
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java	Mon Jun 27 18:07:29 2016 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java	Mon Jul 04 18:41:14 2016 +0900
@@ -966,13 +966,13 @@
         int thatRetinaScale = presenter.getRetinaScale();
         final int thatScreenWidth = presenter.getSingleWidth();
         final int thatScreenHeight = presenter.getSingleHeight();
-        // showScreenInfo("that", 0, thatScreenX, thatScreenY, thatScreenWidth, thatScreenHeight, thatRetinaScale);
-        // System.out.println("that FB x:" + viewer.getRfb().getContext().getFbWidth() + " y:" + viewer.getRfb().getContext().getFbHeight());
+        showScreenInfo("that", 0, thatScreenX, thatScreenY, thatScreenWidth, thatScreenHeight, thatRetinaScale);
+        System.out.println("that FB w:" + viewer.getRfb().getContext().getFbWidth() + " h:" + viewer.getRfb().getContext().getFbHeight());
 
         frame.setSize(thisScreenWidth, thisScreenHeight);
         double scale = uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, thatScreenWidth, thatScreenHeight);
         // final Rectangle visible = new Rectangle((int)(thatScreenX*scale),(int)(thatScreenY*scale),(int)(thatScreenWidth*scale)-1,(int)(thatScreenHeight*scale)-1);
-        // showScreenInfo("this", thisScreenNumber, 0, 0,thisScreenWidth, thisScreenHeight, thisRetinaScale);
+        showScreenInfo("this", thisScreenNumber, 0, 0,thisScreenWidth, thisScreenHeight, thisRetinaScale);
         final int scrollx = (int)(thatScreenX * scale);
         final int scrolly = (int)(thatScreenY * scale);
         // System.out.println("thisScrollScale: " + scale + " xmax:"+scroller.getHorizontalScrollBar().getMaximum() + " scrollx:"+scrollx);
@@ -990,23 +990,17 @@
         // find which screen we are on
         Point thisScreenLocation = frame.getLocation();
         Point mouse = frame.getMousePosition();
+        System.out.println("finding this screeen number " + thisScreenLocation + " mouse " + mouse + " on screen 0 " + rectangles.get(0)) ;
         int thisScreenNumber = 0;
         for(Rectangle rect : rectangles) {
-            if ( rect.contains(thisScreenLocation) ) break;
+            if ( rect.contains(thisScreenLocation) ) return thisScreenNumber;
             thisScreenNumber++;
         }
-        if (thisScreenNumber<rectangles.size()) {
-            return thisScreenNumber;
-        }
         // frame may out of screen, try mouse position ...
         thisScreenLocation.translate(mouse.x,mouse.y);
         thisScreenNumber = 0;
         for(Rectangle rect : rectangles) {
-            if ( rect.contains(thisScreenLocation) ) break;
-            thisScreenNumber++;
-        }
-        if (thisScreenNumber<rectangles.size()) {
-            return thisScreenNumber;
+            if ( rect.contains(thisScreenLocation) ) return thisScreenNumber;
         }
         return 0;
     }