Skip to content

Commit e833ea5

Browse files
committed
Open dialog at proper point in time
1 parent 06b0ed0 commit e833ea5

File tree

1 file changed

+31
-26
lines changed
  • bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal

1 file changed

+31
-26
lines changed

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

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,13 @@ public void update() {
669669
// run the legacy workbench once
670670
returnCode[0] = workbench.runUI();
671671

672+
if (AUTOSCALE_ADAPTATION.isMonitorSpecificScalingDisabledForIncompatibility()) {
673+
display.asyncExec(() -> {
674+
MessageDialog.openError(null, WorkbenchMessages.RescaleAtRuntimeIncompatibilityTitle,
675+
NLS.bind(WorkbenchMessages.RescaleAtRuntimeIncompatibilityDescription));
676+
});
677+
}
678+
672679
if (returnCode[0] == PlatformUI.RETURN_OK) {
673680
// run the e4 event loop and instantiate ... well, stuff
674681
if (serviceListener.get() != null) {
@@ -694,24 +701,6 @@ public void update() {
694701
return returnCode[0];
695702
}
696703

697-
private static boolean setRescaleAtRuntimePropertyFromPreference() {
698-
if (System.getProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY) != null) {
699-
WorkbenchPlugin.log(Status.warning(SWT_RESCALE_AT_RUNTIME_PROPERTY
700-
+ " is configured (e.g., via the INI), but the according preference should be preferred instead." //$NON-NLS-1$
701-
));
702-
} else {
703-
boolean rescaleAtRuntime = ConfigurationScope.INSTANCE.getNode(WorkbenchPlugin.PI_WORKBENCH)
704-
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
705-
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
706-
}
707-
708-
if (DPIUtil.isMonitorSpecificScalingActive() && !DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
709-
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(false));
710-
return true;
711-
}
712-
return false;
713-
}
714-
715704
private static void setSearchContribution(MApplication app, boolean enabled) {
716705
for (MTrimContribution contribution : app.getTrimContributions()) {
717706
if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$
@@ -777,7 +766,7 @@ public static Display createDisplay() {
777766
Display.setAppName(applicationName);
778767
}
779768

780-
boolean isIncompatibleAutoScaleValue = setRescaleAtRuntimePropertyFromPreference();
769+
AUTOSCALE_ADAPTATION.setRescaleAtRuntimePropertyFromPreference();
781770

782771
// create the display
783772
Display newDisplay = Display.getCurrent();
@@ -796,13 +785,6 @@ public static Display createDisplay() {
796785
}
797786
}
798787

799-
if (isIncompatibleAutoScaleValue) {
800-
newDisplay.asyncExec(() -> {
801-
MessageDialog.openError(null,
802-
WorkbenchMessages.RescaleAtRuntimeIncompatibilityTitle,
803-
NLS.bind(WorkbenchMessages.RescaleAtRuntimeIncompatibilityDescription));
804-
});
805-
}
806788
// workaround for 1GEZ9UR and 1GF07HN
807789
newDisplay.setWarnings(false);
808790

@@ -3686,6 +3668,8 @@ protected String createId() {
36863668
private static class AutoscaleAdaptation {
36873669
private static final String SWT_AUTOSCALE = "swt.autoScale"; //$NON-NLS-1$
36883670

3671+
private boolean incompatibleMonitorSpecificScalingDisabled;
3672+
36893673
private final String initialAutoScaleValue;
36903674

36913675
public AutoscaleAdaptation() {
@@ -3696,5 +3680,26 @@ public void runWithInitialAutoScaleValue(Runnable runnable) {
36963680
DPIUtil.runWithAutoScaleValue(initialAutoScaleValue, runnable);
36973681
}
36983682

3683+
public void setRescaleAtRuntimePropertyFromPreference() {
3684+
if (System.getProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY) != null) {
3685+
WorkbenchPlugin.log(Status.warning(SWT_RESCALE_AT_RUNTIME_PROPERTY
3686+
+ " is configured (e.g., via the INI), but the according preference should be preferred instead." //$NON-NLS-1$
3687+
));
3688+
} else {
3689+
boolean rescaleAtRuntime = ConfigurationScope.INSTANCE.getNode(WorkbenchPlugin.PI_WORKBENCH)
3690+
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
3691+
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
3692+
}
3693+
3694+
if (DPIUtil.isMonitorSpecificScalingActive() && !DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
3695+
incompatibleMonitorSpecificScalingDisabled = true;
3696+
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(false));
3697+
}
3698+
}
3699+
3700+
public boolean isMonitorSpecificScalingDisabledForIncompatibility() {
3701+
return incompatibleMonitorSpecificScalingDisabled;
3702+
}
3703+
36993704
}
37003705
}

0 commit comments

Comments
 (0)