Skip to content

Commit 3ca1192

Browse files
ShahzaibIbrahimHeikoKlare
authored andcommitted
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 343fd57 commit 3ca1192

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,13 @@ private static void setRescaleAtRuntimePropertyFromPreference() {
704704
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
705705
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
706706
}
707+
708+
if (DPIUtil.isMonitorSpecificScalingActive() && !DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
709+
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(false));
710+
MessageDialog.openError(new Shell(Display.getDefault()),
711+
WorkbenchMessages.RescaleAtRuntimeIncompatibilityTitle,
712+
NLS.bind(WorkbenchMessages.RescaleAtRuntimeIncompatibilityDescription));
713+
}
707714
}
708715

709716
private static void setSearchContribution(MApplication app, boolean enabled) {

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
@@ -36,6 +36,12 @@ public class WorkbenchMessages extends NLS {
3636

3737
public static String RescaleAtRuntimeDescription;
3838

39+
public static String RescaleAtRuntimeDisabledDescription;
40+
41+
public static String RescaleAtRuntimeIncompatibilityTitle;
42+
43+
public static String RescaleAtRuntimeIncompatibilityDescription;
44+
3945
public static String RescaleAtRuntimeEnabled;
4046

4147
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
@@ -503,7 +503,10 @@ ThemeChangeWarningTitle = Theme Changed
503503
RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed
504504
RescaleAtRuntimeSettingChangeWarningText = Restart for the DPI setting changes to take effect
505505
RescaleAtRuntimeDescription = Activating this option will dynamically scale all windows according to the monitor they are currently in
506+
RescaleAtRuntimeDisabledDescription = Incompatible value for system property "swt.autoScale" was defined
506507
RescaleAtRuntimeEnabled = Use monitor-specific UI &scaling
508+
RescaleAtRuntimeIncompatibilityTitle = Monitor-Specific Scaling Deactivated
509+
RescaleAtRuntimeIncompatibilityDescription = Monitor-specific scaling is currently active but an incompatible "swt.autoScale" value is defined. For this reason, monitor-specific scaling has been disabled. Please review your auto-scaling configuration.
507510
# --- Workbench -----
508511
WorkbenchPreference_openMode=Open mode
509512
WorkbenchPreference_doubleClick=D&ouble click

0 commit comments

Comments
 (0)