@@ -5512,7 +5512,7 @@ public Rectangle map (Control from, Control to, Rectangle rectangle) {
55125512 public Point map (Control from , Control to , int x , int y ) {
55135513 Point mappedPointInPoints ;
55145514 if (from == null ) {
5515- Point mappedPointInpixels = mapInPixels (from , to , getPixelsFromPoint (to .getShell ().getMonitor (), x , y ));
5515+ Point mappedPointInpixels = mapInPixels (from , to , getPixelsFromPoint (to .getShell ().getMonitor (), x , y , 0 ));
55165516 mappedPointInPoints = DPIUtil .scaleDown (mappedPointInpixels , to .getZoom ());
55175517 } else if (to == null ) {
55185518 Point mappedPointInpixels = mapInPixels (from , to , DPIUtil .scaleUp (new Point (x , y ), from .getZoom ()));
@@ -5555,17 +5555,17 @@ public Point translateFromDisplayCoordinates(Point point, int zoom) {
55555555
55565556 @ Override
55575557 public Point translateToDisplayCoordinates (Point point , int zoom ) {
5558- return translateLocationInPointsToDisplayCoordinateSystem (point .x , point .y );
5558+ return translateLocationInPointsToDisplayCoordinateSystem (point .x , point .y , point . zoom );
55595559 }
55605560
55615561 @ Override
55625562 public Rectangle translateFromDisplayCoordinates (Rectangle rect , int zoom ) {
5563- return translateRectangleInPixelsFromDisplayCoordinateSystemByContainment (rect .x , rect .y , rect .width , rect .height );
5563+ return translateRectangleInPixelsFromDisplayCoordinateSystemByContainment (rect .x , rect .y , rect .width , rect .height , rect . zoom );
55645564 }
55655565
55665566 @ Override
55675567 public Rectangle translateToDisplayCoordinates (Rectangle rect , int zoom ) {
5568- return translateRectangleInPointsToDisplayCoordinateSystemByContainment (rect .x , rect .y , rect .width , rect .height );
5568+ return translateRectangleInPointsToDisplayCoordinateSystemByContainment (rect .x , rect .y , rect .width , rect .height , rect . zoom );
55695569 }
55705570
55715571 @ Override
@@ -5576,39 +5576,40 @@ public Point getCursorLocation () {
55765576
55775577 @ Override
55785578 public void setCursorLocation (int x , int y ) {
5579- Point cursorLocationInPixels = translateLocationInPointsToDisplayCoordinateSystem (x , y );
5579+ Point cursorLocationInPixels = translateLocationInPointsToDisplayCoordinateSystem (x , y , 0 );
55805580 setCursorLocationInPixels (cursorLocationInPixels .x , cursorLocationInPixels .y );
55815581 }
55825582
5583- private Point translateLocationInPointsToDisplayCoordinateSystem (int x , int y ) {
5583+ private Point translateLocationInPointsToDisplayCoordinateSystem (int x , int y , int zoom ) {
55845584 Monitor monitor = getContainingMonitor (x , y );
5585- return getPixelsFromPoint (monitor , x , y );
5585+ return getPixelsFromPoint (monitor , x , y , zoom );
55865586 }
55875587
55885588 private Point translateLocationInPixelsFromDisplayCoordinateSystem (int x , int y ) {
55895589 Monitor monitor = getContainingMonitorInPixelsCoordinate (x , y );
55905590 return getPointFromPixels (monitor , x , y );
55915591 }
55925592
5593- private Rectangle translateRectangleInPointsToDisplayCoordinateSystemByContainment (int x , int y , int width , int height ) {
5593+ private Rectangle translateRectangleInPointsToDisplayCoordinateSystemByContainment (int x , int y , int width , int height , int zoom ) {
55945594 Monitor monitorByLocation = getContainingMonitor (x , y );
55955595 Monitor monitorByContainment = getContainingMonitor (x , y , width , height );
5596- return translateRectangleInPixelsInDisplayCoordinateSystem (x , y , width , height , monitorByLocation , monitorByContainment );
5596+ return translateRectangleInPixelsInDisplayCoordinateSystem (x , y , width , height , zoom , monitorByLocation , monitorByContainment );
55975597 }
55985598
55995599 private Rectangle translateRectangleInPixelsInDisplayCoordinateSystem (int x , int y , int width , int height , Monitor monitor ) {
5600- return translateRectangleInPixelsInDisplayCoordinateSystem (x , y , width , height , monitor , monitor );
5600+ return translateRectangleInPixelsInDisplayCoordinateSystem (x , y , width , height , 0 , monitor , monitor );
56015601 }
56025602
5603- private Rectangle translateRectangleInPixelsInDisplayCoordinateSystem (int x , int y , int width , int height , Monitor monitorOfLocation , Monitor monitorOfArea ) {
5604- Point topLeft = getPixelsFromPoint (monitorOfLocation , x , y );
5605- int zoom = getApplicableMonitorZoom (monitorOfArea );
5603+ private Rectangle translateRectangleInPixelsInDisplayCoordinateSystem (int x , int y , int width , int height , int zoom , Monitor monitorOfLocation , Monitor monitorOfArea ) {
5604+ Point topLeft = getPixelsFromPoint (monitorOfLocation , x , y , zoom );
5605+ if (zoom == 0 )
5606+ zoom = getApplicableMonitorZoom (monitorOfArea );
56065607 int widthInPixels = DPIUtil .scaleUp (width , zoom );
56075608 int heightInPixels = DPIUtil .scaleUp (height , zoom );
56085609 return new Rectangle (topLeft .x , topLeft .y , widthInPixels , heightInPixels );
56095610 }
56105611
5611- private Rectangle translateRectangleInPixelsFromDisplayCoordinateSystemByContainment (int x , int y , int widthInPixels , int heightInPixels ) {
5612+ private Rectangle translateRectangleInPixelsFromDisplayCoordinateSystemByContainment (int x , int y , int widthInPixels , int heightInPixels , int zoom ) {
56125613 Monitor monitorByLocation = getContainingMonitor (x , y );
56135614 Monitor monitorByContainment = getContainingMonitor (x , y , widthInPixels , heightInPixels );
56145615 return translateRectangleInPointsInDisplayCoordinateSystem (x , y , widthInPixels , heightInPixels , monitorByLocation , monitorByContainment );
@@ -5620,11 +5621,14 @@ private Rectangle translateRectangleInPointsInDisplayCoordinateSystem(int x, int
56205621
56215622
56225623 private Rectangle translateRectangleInPointsInDisplayCoordinateSystem (int x , int y , int widthInPixels , int heightInPixels , Monitor monitorOfLocation , Monitor monitorOfArea ) {
5623- Point topLeft = getPointFromPixels (monitorOfLocation , x , y );
5624+ // Point topLeft = getPointFromPixels(monitorOfLocation, x, y);
56245625 int zoom = getApplicableMonitorZoom (monitorOfArea );
5626+ Point topLeft = getPointFromPixels (monitorOfArea , x , y );
56255627 int width = DPIUtil .scaleDown (widthInPixels , zoom );
56265628 int height = DPIUtil .scaleDown (heightInPixels , zoom );
5627- return new Rectangle (topLeft .x , topLeft .y , width , height );
5629+ Rectangle rect = new Rectangle (topLeft .x , topLeft .y , width , height );
5630+ rect .zoom = zoom ;
5631+ return rect ;
56285632 }
56295633
56305634 private Monitor getContainingMonitor (int x , int y ) {
@@ -5673,8 +5677,9 @@ private Rectangle getMonitorClientAreaInPixels(Monitor monitor) {
56735677 return new Rectangle (monitor .clientX , monitor .clientY , widthInPixels , heightInPixels );
56745678 }
56755679
5676- private Point getPixelsFromPoint (Monitor monitor , int x , int y ) {
5677- int zoom = getApplicableMonitorZoom (monitor );
5680+ private Point getPixelsFromPoint (Monitor monitor , int x , int y , int zoom ) {
5681+ if (zoom == 0 )
5682+ zoom = getApplicableMonitorZoom (monitor );
56785683 int mappedX = DPIUtil .scaleUp (x - monitor .clientX , zoom ) + monitor .clientX ;
56795684 int mappedY = DPIUtil .scaleUp (y - monitor .clientY , zoom ) + monitor .clientY ;
56805685 return new Point (mappedX , mappedY );
@@ -5684,7 +5689,9 @@ private Point getPointFromPixels(Monitor monitor, int x, int y) {
56845689 int zoom = getApplicableMonitorZoom (monitor );
56855690 int mappedX = DPIUtil .scaleDown (x - monitor .clientX , zoom ) + monitor .clientX ;
56865691 int mappedY = DPIUtil .scaleDown (y - monitor .clientY , zoom ) + monitor .clientY ;
5687- return new Point (mappedX , mappedY );
5692+ Point pt = new Point (mappedX , mappedY );
5693+ pt .zoom = zoom ;
5694+ return pt ;
56885695 }
56895696
56905697 private int getApplicableMonitorZoom (Monitor monitor ) {
0 commit comments