51
51
import java .util .Objects ;
52
52
import java .util .Set ;
53
53
import java .util .UUID ;
54
+ import java .util .concurrent .atomic .AtomicReference ;
54
55
import org .eclipse .core .commands .Command ;
55
56
import org .eclipse .core .commands .CommandManager ;
56
57
import org .eclipse .core .commands .ExecutionException ;
157
158
import org .eclipse .swt .graphics .Point ;
158
159
import org .eclipse .swt .graphics .Rectangle ;
159
160
import org .eclipse .swt .graphics .Transform ;
161
+ import org .eclipse .swt .internal .DPIUtil ;
160
162
import org .eclipse .swt .widgets .Display ;
161
163
import org .eclipse .swt .widgets .Listener ;
162
164
import org .eclipse .swt .widgets .Monitor ;
@@ -315,7 +317,8 @@ private static final class StartupProgressBundleListener implements ServiceListe
315
317
@ Override
316
318
public void serviceChanged (ServiceEvent event ) {
317
319
subMonitor .setWorkRemaining (5 ).worked (1 );
318
- spinEventQueueToUpdateSplash (displayForStartupListener );
320
+ AUTOSCALE_ADAPTATION
321
+ .runWithInitialAutoScaleValue (() -> spinEventQueueToUpdateSplash (displayForStartupListener ));
319
322
}
320
323
}
321
324
@@ -351,6 +354,11 @@ public void serviceChanged(ServiceEvent event) {
351
354
*/
352
355
private static AbstractSplashHandler splash ;
353
356
357
+ /**
358
+ * Helper to adapt auto-scaling for the splash screen
359
+ */
360
+ private static final AutoscaleAdaptation AUTOSCALE_ADAPTATION = new AutoscaleAdaptation ();
361
+
354
362
/**
355
363
* The display used for all UI interactions with this workbench.
356
364
*
@@ -627,9 +635,9 @@ public void update() {
627
635
properties );
628
636
629
637
// listener for updating the splash screen
630
- ServiceListener serviceListener = null ;
638
+ AtomicReference < ServiceListener > serviceListener = new AtomicReference <>() ;
631
639
createSplash = WorkbenchPlugin .isSplashHandleSpecified ();
632
- if ( createSplash ) {
640
+ Runnable splashCreation = () -> {
633
641
634
642
// prime the splash nice and early
635
643
workbench .createSplashWrapper ();
@@ -649,10 +657,13 @@ public void update() {
649
657
650
658
if (handler != null && showProgress ) {
651
659
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 () );
654
662
}
663
+ };
655
664
665
+ if (createSplash ) {
666
+ AUTOSCALE_ADAPTATION .runWithInitialAutoScaleValue (splashCreation );
656
667
}
657
668
658
669
setSearchContribution (appModel , true );
@@ -661,8 +672,8 @@ public void update() {
661
672
662
673
if (returnCode [0 ] == PlatformUI .RETURN_OK ) {
663
674
// 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 () );
666
677
}
667
678
e4Workbench .createAndRunUI (e4Workbench .getApplication ());
668
679
}
@@ -3649,4 +3660,19 @@ public String getId() {
3649
3660
protected String createId () {
3650
3661
return UUID .randomUUID ().toString ();
3651
3662
}
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
+ }
3652
3678
}
0 commit comments