Skip to content

Commit b908e03

Browse files
committed
set Location of menu wrt Display coordinate system
This commit contributes to scaling of the point used to set location of a menu bar in a display coordinate space hence the scaling methods used for such Points must be the ones used for Display coordinate system. contributes to #62 and #127
1 parent 5dd0c28 commit b908e03

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,9 +1188,7 @@ public void setEnabled (boolean enabled) {
11881188
* </ul>
11891189
*/
11901190
public void setLocation (int x, int y) {
1191-
checkWidget ();
1192-
int zoom = getZoom();
1193-
setLocationInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom));
1191+
setLocation(new Point(x, y));
11941192
}
11951193

11961194
void setLocationInPixels (int x, int y) {
@@ -1227,7 +1225,7 @@ void setLocationInPixels (int x, int y) {
12271225
public void setLocation (Point location) {
12281226
checkWidget ();
12291227
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
1230-
location = DPIUtil.scaleUp(location, getZoom());
1228+
location = getDisplay().translateLocationInPixelsInDisplayCoordinateSystem(location.x, location.y);
12311229
setLocationInPixels(location.x, location.y);
12321230
}
12331231

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,8 +1651,8 @@ boolean showMenu (int x, int y) {
16511651

16521652
boolean showMenu (int x, int y, int detail) {
16531653
Event event = new Event ();
1654-
int zoom = getZoom();
1655-
event.setLocation(DPIUtil.scaleDown(x, zoom), DPIUtil.scaleDown(y, zoom));
1654+
Point mappedLocation = getDisplay().translateLocationInPointInDisplayCoordinateSystem(x, y);
1655+
event.setLocation(mappedLocation.x, mappedLocation.y);
16561656
event.detail = detail;
16571657
if (event.detail == SWT.MENU_KEYBOARD) {
16581658
updateMenuLocation (event);
@@ -1663,7 +1663,7 @@ boolean showMenu (int x, int y, int detail) {
16631663
if (!event.doit) return true;
16641664
Menu menu = getMenu ();
16651665
if (menu != null && !menu.isDisposed ()) {
1666-
Point locInPixels = DPIUtil.scaleUp(event.getLocation(), zoom); // In Pixels
1666+
Point locInPixels = DPIUtil.scaleUp(event.getLocation(), getZoom()); // In Pixels
16671667
if (x != locInPixels.x || y != locInPixels.y) {
16681668
menu.setLocation (event.getLocation());
16691669
}

0 commit comments

Comments
 (0)