Skip to content

Commit fb6e41b

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 b9ab7dc commit fb6e41b

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

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

Lines changed: 16 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;
@@ -704,6 +705,9 @@ private static void setRescaleAtRuntimePropertyFromPreference() {
704705
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
705706
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
706707
}
708+
if (Boolean.getBoolean(System.getProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY))) {
709+
DPIUtil.setAutoScaleForMonitorSpecificScaling();
710+
}
707711
}
708712

709713
private static void setSearchContribution(MApplication app, boolean enabled) {
@@ -773,6 +777,9 @@ public static Display createDisplay() {
773777

774778
setRescaleAtRuntimePropertyFromPreference();
775779

780+
if (DPIUtil.isMonitorSpecificScalingActive() && !DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
781+
showMonitorSpecificIncompambatibilityDialog();
782+
}
776783
// create the display
777784
Display newDisplay = Display.getCurrent();
778785
if (newDisplay == null) {
@@ -802,6 +809,15 @@ public static Display createDisplay() {
802809
return newDisplay;
803810
}
804811

812+
private static void showMonitorSpecificIncompambatibilityDialog() throws SWTError {
813+
MessageDialog.openError(new Shell(Display.getDefault()), WorkbenchMessages.RescaleAtRuntimeIncompatibilityTitle,
814+
NLS.bind(WorkbenchMessages.RescaleAtRuntimeIncompatibilityDescription,
815+
DPIUtil.getAutoScaleValue()));
816+
throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED,
817+
"monitor-specific scaling is only implemented for auto-scale values \"quarter\" and \"exact\", but \"" //$NON-NLS-1$
818+
+ DPIUtil.getAutoScaleValue() + "\" has been specified"); //$NON-NLS-1$
819+
}
820+
805821
/**
806822
* Create the splash wrapper and set it to work.
807823
*

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. Please review your auto-scaling configuration.
508511
# --- Workbench -----
509512
WorkbenchPreference_openMode=Open mode
510513
WorkbenchPreference_doubleClick=D&ouble click

0 commit comments

Comments
 (0)