Fixed context menu popup location for HiDPI displays with display zoom
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / editor / TimeSeriesEditor.java
index cadb5bd4b372e5841479497d672cd1fde938511e..bffd4c8a24952fb60bfae8cd517be91a9d24e36d 100644 (file)
@@ -134,6 +134,7 @@ import org.simantics.utils.threads.ThreadUtils;
 import org.simantics.utils.ui.BundleUtils;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.ExceptionUtils;
+import org.simantics.utils.ui.SWTDPIUtil;
 import org.simantics.utils.ui.SWTUtils;
 import org.simantics.utils.ui.dialogs.ShowMessage;
 import org.simantics.utils.ui.jface.ActiveSelectionProvider;
@@ -567,13 +568,12 @@ public class TimeSeriesEditor extends ResourceEditorPart {
                 if (event.button != MouseEvent.RIGHT_BUTTON)
                     return false;
 
-                final Point p = new Point((int) event.screenPosition.getX(), (int) event.screenPosition.getY());
-                SWTUtils.asyncExec(chassis, new Runnable() {
-                    @Override
-                    public void run() {
-                        if (!canvas.isDisposed())
-                            showPopup(p);
-                    }
+                Point p = new Point(
+                        SWTDPIUtil.downscaleSwt((int) event.screenPosition.getX()),
+                        SWTDPIUtil.downscaleSwt((int) event.screenPosition.getY()));
+                SWTUtils.asyncExec(chassis, () -> {
+                    if (!canvas.isDisposed())
+                        showPopup(p);
                 });
                 return true;
             }