@@ -2547,15 +2547,19 @@ public Point map (Control from, Control to, int x, int y) {
2547
2547
checkDevice ();
2548
2548
if (from != null && from .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
2549
2549
if (to != null && to .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
2550
- // Element hwndFrom = from != null ? from.handle : null;
2551
- // Element hwndTo = to != null ? to.handle : null;
2550
+ if (from == to ) return new Point (x , y );
2551
+ Element hwndFrom = from != null ? from .handle : document .body ;
2552
+ Element hwndTo = to != null ? to .handle : document .body ;
2552
2553
2553
2554
// POINT point = new POINT ();
2554
2555
// point.x = x;
2555
2556
// point.y = y;
2556
2557
// OS.MapWindowPoints (hwndFrom, hwndTo, point, 1);
2557
2558
// return new Point (point.x, point.y);
2558
- return new Point (0 , 0 );
2559
+ Point p = OS .calcuateRelativePosition (hwndFrom , hwndTo );
2560
+ p .x += x ;
2561
+ p .y += y ;
2562
+ return p ;
2559
2563
}
2560
2564
2561
2565
/**
@@ -2642,8 +2646,9 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
2642
2646
checkDevice ();
2643
2647
if (from != null && from .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
2644
2648
if (to != null && to .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
2645
- // Element hwndFrom = from != null ? from.handle : null;
2646
- // Element hwndTo = to != null ? to.handle : null;
2649
+ if (from == to ) return new Rectangle (x , y , width , height );
2650
+ Element hwndFrom = from != null ? from .handle : document .body ;
2651
+ Element hwndTo = to != null ? to .handle : document .body ;
2647
2652
2648
2653
// RECT rect = new RECT ();
2649
2654
// rect.left = x;
@@ -2652,7 +2657,10 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
2652
2657
// rect.bottom = y + height;
2653
2658
// OS.MapWindowPoints (hwndFrom, hwndTo, rect, 2);
2654
2659
// return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
2655
- return new Rectangle (0 , 0 , 0 , 0 );
2660
+ Point p = OS .calcuateRelativePosition (hwndFrom , hwndTo );
2661
+ p .x += x ;
2662
+ p .y += y ;
2663
+ return new Rectangle (p .x + x , p .y + y , OS .getContainerWidth (hwndTo ), OS .getContainerHeight (hwndTo ));
2656
2664
}
2657
2665
2658
2666
/*
0 commit comments