Skip to content

Commit 88e83a8

Browse files
akoch-yattaHeikoKlare
authored andcommitted
Proper rescaling for win32 splash screen image
This commit adds an ImageDataProvider to properly scale the splash image, if it is shown in Windows. If the monitor specific scaling is active, the autoScale mode used when the native launcher calculated the initial size was calculated, might be different than when the splash image is refreshed via the Workbench. The ImageDataProvider ensures, that either the explicitly defined mode or the default mode is used.
1 parent 7559164 commit 88e83a8

File tree

1 file changed

+33
-7
lines changed
  • bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal

1 file changed

+33
-7
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/Workbench.java

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.util.Objects;
5252
import java.util.Set;
5353
import java.util.UUID;
54+
import java.util.concurrent.atomic.AtomicReference;
5455
import org.eclipse.core.commands.Command;
5556
import org.eclipse.core.commands.CommandManager;
5657
import org.eclipse.core.commands.ExecutionException;
@@ -157,6 +158,7 @@
157158
import org.eclipse.swt.graphics.Point;
158159
import org.eclipse.swt.graphics.Rectangle;
159160
import org.eclipse.swt.graphics.Transform;
161+
import org.eclipse.swt.internal.DPIUtil;
160162
import org.eclipse.swt.widgets.Display;
161163
import org.eclipse.swt.widgets.Listener;
162164
import org.eclipse.swt.widgets.Monitor;
@@ -315,7 +317,8 @@ private static final class StartupProgressBundleListener implements ServiceListe
315317
@Override
316318
public void serviceChanged(ServiceEvent event) {
317319
subMonitor.setWorkRemaining(5).worked(1);
318-
spinEventQueueToUpdateSplash(displayForStartupListener);
320+
AUTOSCALE_ADAPTATION
321+
.runWithInitialAutoScaleValue(() -> spinEventQueueToUpdateSplash(displayForStartupListener));
319322
}
320323
}
321324

@@ -351,6 +354,11 @@ public void serviceChanged(ServiceEvent event) {
351354
*/
352355
private static AbstractSplashHandler splash;
353356

357+
/**
358+
* Helper to adapt auto-scaling for the splash screen
359+
*/
360+
private static final AutoscaleAdaptation AUTOSCALE_ADAPTATION = new AutoscaleAdaptation();
361+
354362
/**
355363
* The display used for all UI interactions with this workbench.
356364
*
@@ -627,9 +635,9 @@ public void update() {
627635
properties);
628636

629637
// listener for updating the splash screen
630-
ServiceListener serviceListener = null;
638+
AtomicReference<ServiceListener> serviceListener = new AtomicReference<>();
631639
createSplash = WorkbenchPlugin.isSplashHandleSpecified();
632-
if (createSplash) {
640+
Runnable splashCreation = () -> {
633641

634642
// prime the splash nice and early
635643
workbench.createSplashWrapper();
@@ -649,10 +657,13 @@ public void update() {
649657

650658
if (handler != null && showProgress) {
651659
IProgressMonitor progressMonitor = SubMonitor.convert(handler.getBundleProgressMonitor());
652-
serviceListener = new Workbench.StartupProgressBundleListener(progressMonitor, display);
653-
WorkbenchPlugin.getDefault().getBundleContext().addServiceListener(serviceListener);
660+
serviceListener.set(new Workbench.StartupProgressBundleListener(progressMonitor, display));
661+
WorkbenchPlugin.getDefault().getBundleContext().addServiceListener(serviceListener.get());
654662
}
663+
};
655664

665+
if (createSplash) {
666+
AUTOSCALE_ADAPTATION.runWithInitialAutoScaleValue(splashCreation);
656667
}
657668

658669
setSearchContribution(appModel, true);
@@ -661,8 +672,8 @@ public void update() {
661672

662673
if (returnCode[0] == PlatformUI.RETURN_OK) {
663674
// run the e4 event loop and instantiate ... well, stuff
664-
if (serviceListener != null) {
665-
WorkbenchPlugin.getDefault().getBundleContext().removeServiceListener(serviceListener);
675+
if (serviceListener.get() != null) {
676+
WorkbenchPlugin.getDefault().getBundleContext().removeServiceListener(serviceListener.get());
666677
}
667678
e4Workbench.createAndRunUI(e4Workbench.getApplication());
668679
}
@@ -3649,4 +3660,19 @@ public String getId() {
36493660
protected String createId() {
36503661
return UUID.randomUUID().toString();
36513662
}
3663+
3664+
private static class AutoscaleAdaptation {
3665+
private static final String SWT_AUTOSCALE = "swt.autoScale"; //$NON-NLS-1$
3666+
3667+
private final String initialAutoScaleValue;
3668+
3669+
public AutoscaleAdaptation() {
3670+
initialAutoScaleValue = System.getProperty(SWT_AUTOSCALE);
3671+
}
3672+
3673+
public void runWithInitialAutoScaleValue(Runnable runnable) {
3674+
DPIUtil.runWithAutoScaleValue(initialAutoScaleValue, runnable);
3675+
}
3676+
3677+
}
36523678
}

0 commit comments

Comments
 (0)