From 63f2f953315938928e5a232a619fa9bb5d694580 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 9 Aug 2019 17:27:58 +0300 Subject: [PATCH] HiDPI fixes gitlab #22 Change-Id: Ib6589309b5b1d9ce3d9f1f369803b262df04ae76 --- .../rendering/swt/vtkSwtInteractorForwarderDecorator.java | 5 +++-- vtk.rendering/src/vtk/rendering/vtkAbstractComponent.java | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/vtk.rendering/src/vtk/rendering/swt/vtkSwtInteractorForwarderDecorator.java b/vtk.rendering/src/vtk/rendering/swt/vtkSwtInteractorForwarderDecorator.java index 24ccabe1..56259564 100644 --- a/vtk.rendering/src/vtk/rendering/swt/vtkSwtInteractorForwarderDecorator.java +++ b/vtk.rendering/src/vtk/rendering/swt/vtkSwtInteractorForwarderDecorator.java @@ -13,6 +13,7 @@ import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.MouseWheelListener; +import org.eclipse.swt.internal.DPIUtil; /** * Decorator class used to implement all Mouse/Key SWT listener and convert them @@ -55,7 +56,7 @@ implements MouseListener, MouseMoveListener, MouseTrackListener, MouseWheelListe if ((e.button == 1) || (e.stateMask & SWT.BUTTON1) != 0) button = java.awt.event.MouseEvent.BUTTON1; else if ((e.button == 2) || (e.stateMask & SWT.BUTTON2) != 0) button = java.awt.event.MouseEvent.BUTTON2; else if ((e.button == 3) || (e.stateMask & SWT.BUTTON3) != 0) button = java.awt.event.MouseEvent.BUTTON3; - return new java.awt.event.MouseEvent(dummyComponent, 0, (long)e.time, convertModifiers(e.button,e.stateMask), e.x, e.y, e.count, false, button); + return new java.awt.event.MouseEvent(dummyComponent, 0, (long)e.time, convertModifiers(e.button,e.stateMask), DPIUtil.autoScaleUp(e.x), DPIUtil.autoScaleUp(e.y), e.count, false, button); } public int convertKeyCode(int swtKeyCode) { @@ -66,7 +67,7 @@ implements MouseListener, MouseMoveListener, MouseTrackListener, MouseWheelListe } public java.awt.event.MouseWheelEvent convertMouseWheelEvent(org.eclipse.swt.events.MouseEvent e) { - return new java.awt.event.MouseWheelEvent(dummyComponent, 0, e.time, convertModifiers(e.button,e.stateMask), e.x, e.y, 0, false, java.awt.event.MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, e.count); + return new java.awt.event.MouseWheelEvent(dummyComponent, 0, e.time, convertModifiers(e.button,e.stateMask), DPIUtil.autoScaleUp(e.x), DPIUtil.autoScaleUp(e.y), 0, false, java.awt.event.MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, e.count); } public void keyPressed(KeyEvent e) { diff --git a/vtk.rendering/src/vtk/rendering/vtkAbstractComponent.java b/vtk.rendering/src/vtk/rendering/vtkAbstractComponent.java index 84f2fb41..c905a72f 100644 --- a/vtk.rendering/src/vtk/rendering/vtkAbstractComponent.java +++ b/vtk.rendering/src/vtk/rendering/vtkAbstractComponent.java @@ -2,6 +2,8 @@ package vtk.rendering; import java.util.concurrent.locks.ReentrantLock; +import org.eclipse.swt.internal.DPIUtil; + import vtk.vtkAxesActor; import vtk.vtkCamera; import vtk.vtkGenericRenderWindowInteractor; @@ -130,7 +132,8 @@ public abstract class vtkAbstractComponent implements vtkComponent { if (renderWindow == null || windowInteractor == null) { return; // Nothing to do we are deleted... } - + w = DPIUtil.autoScaleUp(w); + h = DPIUtil.autoScaleUp(h); try { lock.lockInterruptibly(); renderWindow.SetSize(w, h); -- 2.47.1