Skip to content

Commit d41719a

Browse files
Limit monitor-specific scaling to supported autoscale modes
These changes have following affects: - Upon starting eclipse product when monitor-specific scaling is set with unsupported autoscale mode, it will show a error dialog and application won't start. - User won't be able to enable monitor-specific scaling from appearance page if unsupported autoscale mode is set from property or ini file. - User can then either force the unsupported autoscale mode with monitor specific-scaling by setting swt.autoScale.force to true or switch to supported autoscale mode.
1 parent 3a441d9 commit d41719a

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
import org.eclipse.osgi.service.runnable.StartupMonitor;
149149
import org.eclipse.osgi.util.NLS;
150150
import org.eclipse.swt.SWT;
151+
import org.eclipse.swt.SWTError;
151152
import org.eclipse.swt.SWTException;
152153
import org.eclipse.swt.browser.Browser;
153154
import org.eclipse.swt.custom.BusyIndicator;
@@ -773,6 +774,11 @@ public static Display createDisplay() {
773774

774775
setRescaleAtRuntimePropertyFromPreference();
775776

777+
if (DPIUtil.isMonitorSpecificScalingActive() && !DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
778+
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(false));
779+
showMonitorSpecificIncompambatibilityDialog();
780+
}
781+
776782
// create the display
777783
Display newDisplay = Display.getCurrent();
778784
if (newDisplay == null) {
@@ -802,6 +808,12 @@ public static Display createDisplay() {
802808
return newDisplay;
803809
}
804810

811+
private static void showMonitorSpecificIncompambatibilityDialog() throws SWTError {
812+
MessageDialog.openError(new Shell(Display.getDefault()), WorkbenchMessages.RescaleAtRuntimeIncompatibilityTitle,
813+
NLS.bind(WorkbenchMessages.RescaleAtRuntimeIncompatibilityDescription,
814+
DPIUtil.getAutoScaleValue()));
815+
}
816+
805817
/**
806818
* Create the splash wrapper and set it to work.
807819
*

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public class WorkbenchMessages extends NLS {
3838

3939
public static String RescaleAtRuntimeDescription;
4040

41+
public static String RescaleAtRuntimeDisabledDescription;
42+
43+
public static String RescaleAtRuntimeIncompatibilityTitle;
44+
45+
public static String RescaleAtRuntimeIncompatibilityDescription;
46+
4147
public static String RescaleAtRuntimeEnabled;
4248

4349
public static String RescaleAtRuntimeSettingChangeWarningTitle;

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.eclipse.jface.dialogs.MessageDialog;
5454
import org.eclipse.jface.fieldassist.ControlDecoration;
5555
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
56+
import org.eclipse.jface.layout.GridDataFactory;
5657
import org.eclipse.jface.preference.IPreferenceStore;
5758
import org.eclipse.jface.preference.PreferencePage;
5859
import org.eclipse.jface.viewers.ArrayContentProvider;
@@ -65,7 +66,9 @@
6566
import org.eclipse.swt.SWT;
6667
import org.eclipse.swt.events.SelectionEvent;
6768
import org.eclipse.swt.events.SelectionListener;
69+
import org.eclipse.swt.graphics.Font;
6870
import org.eclipse.swt.graphics.Image;
71+
import org.eclipse.swt.internal.DPIUtil;
6972
import org.eclipse.swt.layout.GridData;
7073
import org.eclipse.swt.layout.GridLayout;
7174
import org.eclipse.swt.widgets.Button;
@@ -222,7 +225,16 @@ private void createRescaleAtRuntimeCheckButton(Composite parent) {
222225
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
223226
rescaleAtRuntime = createCheckButton(parent, WorkbenchMessages.RescaleAtRuntimeEnabled,
224227
initialStateRescaleAtRuntime);
225-
rescaleAtRuntime.setToolTipText(WorkbenchMessages.RescaleAtRuntimeDescription);
228+
if (!DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
229+
rescaleAtRuntime.setEnabled(false);
230+
Font font = parent.getFont();
231+
Composite note = createNoteComposite(font, parent, WorkbenchMessages.Preference_note,
232+
WorkbenchMessages.RescaleAtRuntimeDisabledDescription);
233+
note.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
234+
} else {
235+
rescaleAtRuntime.setEnabled(true);
236+
rescaleAtRuntime.setToolTipText(WorkbenchMessages.RescaleAtRuntimeDescription);
237+
}
226238
}
227239

228240
private void createThemeIndependentComposits(Composite comp) {

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,10 @@ RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed
504504
RescaleAtRuntimeSettingChangeWarningText = Restart for the DPI setting changes to take effect
505505
HiDpiSettingsGroupTitle = HiDPI settings
506506
RescaleAtRuntimeDescription = Activating this option will dynamically scale all windows according to the monitor they are currently in
507+
RescaleAtRuntimeDisabledDescription = Incompatible autoscale value was defined via system property or ini
507508
RescaleAtRuntimeEnabled = Use monitor-specific UI &scaling
509+
RescaleAtRuntimeIncompatibilityTitle = Scaling Configuration Error
510+
RescaleAtRuntimeIncompatibilityDescription = Monitor-specific scaling is currently active with the wrong autoscale value (''{0}''). This combination may lead to unexpected UI scaling behavior, For this reason the monitor-specific scaling has been disabled. Please review your auto-scaling configuration.
508511
# --- Workbench -----
509512
WorkbenchPreference_openMode=Open mode
510513
WorkbenchPreference_doubleClick=D&ouble click

0 commit comments

Comments
 (0)