Skip to content

Commit 351988b

Browse files
Adding experimental preference to enable update on runtime behavior
In the UI Preferences -> General -> Appearance, there is a new HiDpi setting that could be checked to enable the HiDpi behavior. This check will also enable Edge browser by default instead of Internet explorer. This is an experimental feature to test the HiDpi stuff before it is actually released and set by default. For now, this preference is disabled by default.
1 parent 83c128c commit 351988b

File tree

5 files changed

+81
-7
lines changed

5 files changed

+81
-7
lines changed

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPreferenceConstants.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,4 +705,14 @@ public interface IWorkbenchPreferenceConstants {
705705
* @since 3.130
706706
*/
707707
String LARGE_VIEW_LIMIT = "largeViewLimit"; //$NON-NLS-1$
708+
709+
/**
710+
* <p>
711+
* <strong>EXPERIMENTAL</strong>. Whether the UI adapts to DPI changes at
712+
* runtime. It only effects Windows.
713+
* </p>
714+
*
715+
* @since 3.133
716+
*/
717+
String RESCALING_AT_RUNTIME = "RESCALING_AT_RUNTIME"; //$NON-NLS-1$
708718
}

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ public static int createAndRunWorkbench(final Display display, final WorkbenchAd
584584
int orientation = store.getInt(IPreferenceConstants.LAYOUT_DIRECTION);
585585
Window.setDefaultOrientation(orientation);
586586
}
587-
587+
setRescaleAtRuntimePropertyFromPreference(display);
588588
if (obj instanceof E4Application) {
589589
E4Application e4app = (E4Application) obj;
590590
E4Workbench e4Workbench = e4app.createE4Workbench(getApplicationContext(), display);
@@ -678,6 +678,15 @@ public void update() {
678678
return returnCode[0];
679679
}
680680

681+
private static void setRescaleAtRuntimePropertyFromPreference(final Display display) {
682+
boolean rescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
683+
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
684+
if (rescaleAtRuntime) {
685+
display.setRescalingAtRuntime(rescaleAtRuntime);
686+
System.setProperty("org.eclipse.swt.browser.DefaultType", "edge"); //$NON-NLS-1$ //$NON-NLS-2$
687+
}
688+
}
689+
681690
private static void setSearchContribution(MApplication app, boolean enabled) {
682691
for (MTrimContribution contribution : app.getTrimContributions()) {
683692
if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ public class WorkbenchMessages extends NLS {
3434

3535
public static String ThemingEnabled;
3636

37+
public static String UpdateUIZoomGroupTitle;
38+
39+
public static String UpdateUIZoomTitle;
40+
41+
public static String UpdateUIZoomDesc;
42+
43+
public static String RescaleAtRuntimeSettingChangeWarningTitle;
44+
45+
public static String RescaleAtRuntimeSettingChangeWarningDesc;
46+
3747
public static String ThemeChangeWarningText;
3848

3949
public static String ThemeChangeWarningTitle;

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.eclipse.core.runtime.IExtensionPoint;
3838
import org.eclipse.core.runtime.IExtensionRegistry;
3939
import org.eclipse.core.runtime.Platform;
40+
import org.eclipse.core.runtime.Platform.OS;
4041
import org.eclipse.core.runtime.RegistryFactory;
4142
import org.eclipse.core.runtime.preferences.DefaultScope;
4243
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -53,6 +54,7 @@
5354
import org.eclipse.jface.dialogs.MessageDialog;
5455
import org.eclipse.jface.fieldassist.ControlDecoration;
5556
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
57+
import org.eclipse.jface.layout.GridDataFactory;
5658
import org.eclipse.jface.preference.IPreferenceStore;
5759
import org.eclipse.jface.preference.PreferencePage;
5860
import org.eclipse.jface.util.Util;
@@ -73,6 +75,7 @@
7375
import org.eclipse.swt.widgets.Composite;
7476
import org.eclipse.swt.widgets.Control;
7577
import org.eclipse.swt.widgets.Display;
78+
import org.eclipse.swt.widgets.Group;
7679
import org.eclipse.swt.widgets.Label;
7780
import org.eclipse.ui.IWorkbench;
7881
import org.eclipse.ui.IWorkbenchPreferenceConstants;
@@ -114,6 +117,8 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
114117
private boolean highContrastMode;
115118

116119
private Button themingEnabled;
120+
private Button updateOnRuntime;
121+
private boolean initialStateUpdateOnRuntime;
117122

118123
private Button hideIconsForViewTabs;
119124
private Button showFullTextForViewTabs;
@@ -127,6 +132,8 @@ protected Control createContents(Composite parent) {
127132
Composite comp = new Composite(parent, SWT.NONE);
128133

129134
themingEnabled = createCheckButton(comp, WorkbenchMessages.ThemingEnabled, engine != null);
135+
initialStateUpdateOnRuntime = PrefUtil.getAPIPreferenceStore()
136+
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
130137

131138
// if started with "-cssTheme none", CSS settings should be disabled
132139
// but other appearance settings should be *not* disabled
@@ -135,6 +142,7 @@ protected Control createContents(Composite parent) {
135142
layout.horizontalSpacing = 10;
136143
comp.setLayout(layout);
137144
createThemeIndependentComposits(comp);
145+
createHiDPISettingsGroup(comp);
138146
return comp;
139147
}
140148

@@ -180,6 +188,8 @@ protected Control createContents(Composite parent) {
180188
createHideIconsForViewTabs(comp);
181189
createDependency(showFullTextForViewTabs, hideIconsForViewTabs);
182190

191+
createHiDPISettingsGroup(comp);
192+
183193
if (currentTheme != null) {
184194
String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId(currentTheme.getId());
185195
if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme.getId().equals(colorsAndFontsThemeId)) {
@@ -192,6 +202,28 @@ protected Control createContents(Composite parent) {
192202
return comp;
193203
}
194204

205+
private void createHiDPISettingsGroup(Composite parent) {
206+
if (!OS.isWindows() || true) {
207+
return;
208+
}
209+
createLabel(parent, ""); //$NON-NLS-1$
210+
Group group = new Group(parent, SWT.LEFT);
211+
group.setText(WorkbenchMessages.UpdateUIZoomGroupTitle);
212+
213+
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
214+
gridData.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
215+
group.setLayoutData(gridData);
216+
group.setFont(parent.getFont());
217+
GridLayout layout = new GridLayout(1, false);
218+
group.setLayout(layout);
219+
Label infoLabel = new Label(group, SWT.WRAP);
220+
infoLabel.setText(WorkbenchMessages.UpdateUIZoomDesc);
221+
infoLabel.setLayoutData(GridDataFactory.defaultsFor(infoLabel).create());
222+
createLabel(group, ""); //$NON-NLS-1$
223+
224+
updateOnRuntime = createCheckButton(group, WorkbenchMessages.UpdateUIZoomTitle, initialStateUpdateOnRuntime);
225+
}
226+
195227
private void createThemeIndependentComposits(Composite comp) {
196228
createUseRoundTabs(comp);
197229
createColoredLabelsPref(comp);
@@ -227,7 +259,6 @@ private void createDependency(Button parent, Button dependent) {
227259
GridData gridData = new GridData();
228260
gridData.horizontalIndent = 20;
229261
dependent.setLayoutData(gridData);
230-
231262
boolean parentState = parent.getSelection();
232263
dependent.setEnabled(parentState);
233264

@@ -341,6 +372,12 @@ public boolean performOk() {
341372
.getSelection();
342373
prefs.putBoolean(PartRenderingEngine.ENABLED_THEME_KEY, themingEnabled.getSelection());
343374

375+
boolean isUpdateOnRuntimeChanged = false;
376+
if (updateOnRuntime != null) {
377+
isUpdateOnRuntimeChanged = initialStateUpdateOnRuntime != updateOnRuntime.getSelection();
378+
apiStore.setValue(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, updateOnRuntime.getSelection());
379+
}
380+
344381
prefs.putBoolean(CTabRendering.USE_ROUND_TABS, useRoundTabs.getSelection());
345382
try {
346383
prefs.flush();
@@ -367,19 +404,22 @@ public boolean performOk() {
367404
colorFontsDecorator.hide();
368405

369406
if (themeChanged || colorsAndFontsThemeChanged) {
370-
showRestartDialog();
407+
showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText);
371408
}
372409
}
373410
if (themingEnabledChanged) {
374-
showRestartDialog();
411+
showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText);
412+
}
413+
if (isUpdateOnRuntimeChanged) {
414+
showRestartDialog(WorkbenchMessages.RescaleAtRuntimeSettingChangeWarningTitle,
415+
WorkbenchMessages.RescaleAtRuntimeSettingChangeWarningDesc);
375416
}
376417

377418
return super.performOk();
378419
}
379420

380-
private void showRestartDialog() {
381-
if (new MessageDialog(null, WorkbenchMessages.ThemeChangeWarningTitle, null,
382-
WorkbenchMessages.ThemeChangeWarningText, MessageDialog.NONE, 2,
421+
private void showRestartDialog(String title, String warningText) {
422+
if (new MessageDialog(null, title, null, warningText, MessageDialog.NONE, 2,
383423
WorkbenchMessages.Workbench_RestartButton, WorkbenchMessages.Workbench_DontRestartButton)
384424
.open() == Window.OK) {
385425
Display.getDefault().asyncExec(() -> PlatformUI.getWorkbench().restart());

bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ PreferencePageParameterValues_pageLabelSeparator = \ >\
497497
ThemingEnabled = E&nable theming
498498
ThemeChangeWarningText = Restart for the theme changes to take full effect
499499
ThemeChangeWarningTitle = Theme Changed
500+
RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed
501+
RescaleAtRuntimeSettingChangeWarningDesc = Restart for the effect to take place
502+
UpdateUIZoomGroupTitle = HiDPI settings
503+
UpdateUIZoomTitle = Monitor-specific UI scaling
504+
UpdateUIZoomDesc = EXPERIMENTAL! Activating this option will dynamically scale all windows according to the monitor they are currently in. It will also set the default browser to Edge in order to provide the appropriate scaling of content displayed in a browser. This feature is still in development and therefore considered experimental.
500505
# --- Workbench -----
501506
WorkbenchPreference_openMode=Open mode
502507
WorkbenchPreference_doubleClick=D&ouble click

0 commit comments

Comments
 (0)