Skip to content

Commit a05574d

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 2c59dfb commit a05574d

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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,4 +705,13 @@ public interface IWorkbenchPreferenceConstants {
705705
* @since 3.130
706706
*/
707707
String LARGE_VIEW_LIMIT = "largeViewLimit"; //$NON-NLS-1$
708+
709+
/**
710+
* <p>
711+
* Whether the UI updates on runtime during dpi change
712+
* </p>
713+
*
714+
* @since 3.133
715+
*/
716+
String UPDATE_ON_RUNTIME_KEY = "UPDATE_ON_RUNTIME_KEY"; //$NON-NLS-1$
708717
}

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+
setRuntimePropertyFromPreference(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 setRuntimePropertyFromPreference(final Display display) {
682+
boolean updateOnRunTime = PrefUtil.getAPIPreferenceStore()
683+
.getBoolean(IWorkbenchPreferenceConstants.UPDATE_ON_RUNTIME_KEY);
684+
display.setRescalingAtRuntime(updateOnRunTime);
685+
if (updateOnRunTime) {
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public class WorkbenchMessages extends NLS {
3434

3535
public static String ThemingEnabled;
3636

37+
public static String UpdateUIZoomTitle;
38+
39+
public static String UpdateUIZoomDesc;
40+
41+
public static String RuntimeSettingChangeWarningTitle;
42+
43+
public static String RuntimeSettingChangeWarningDesc;
44+
3745
public static String ThemeChangeWarningText;
3846

3947
public static String ThemeChangeWarningTitle;

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

Lines changed: 50 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;
@@ -73,6 +74,7 @@
7374
import org.eclipse.swt.widgets.Composite;
7475
import org.eclipse.swt.widgets.Control;
7576
import org.eclipse.swt.widgets.Display;
77+
import org.eclipse.swt.widgets.Group;
7678
import org.eclipse.swt.widgets.Label;
7779
import org.eclipse.ui.IWorkbench;
7880
import org.eclipse.ui.IWorkbenchPreferenceConstants;
@@ -114,6 +116,9 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
114116
private boolean highContrastMode;
115117

116118
private Button themingEnabled;
119+
private Button updateOnRuntime;
120+
private boolean initialStateUpdateOnRuntime = PrefUtil.getAPIPreferenceStore()
121+
.getBoolean(IWorkbenchPreferenceConstants.UPDATE_ON_RUNTIME_KEY);
117122

118123
private Button hideIconsForViewTabs;
119124
private Button showFullTextForViewTabs;
@@ -135,6 +140,7 @@ protected Control createContents(Composite parent) {
135140
layout.horizontalSpacing = 10;
136141
comp.setLayout(layout);
137142
createThemeIndependentComposits(comp);
143+
createHiDPISettingsGroup(comp);
138144
return comp;
139145
}
140146

@@ -180,6 +186,8 @@ protected Control createContents(Composite parent) {
180186
createHideIconsForViewTabs(comp);
181187
createDependency(showFullTextForViewTabs, hideIconsForViewTabs);
182188

189+
createHiDPISettingsGroup(comp);
190+
183191
if (currentTheme != null) {
184192
String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId(currentTheme.getId());
185193
if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme.getId().equals(colorsAndFontsThemeId)) {
@@ -192,6 +200,31 @@ protected Control createContents(Composite parent) {
192200
return comp;
193201
}
194202

203+
private void createHiDPISettingsGroup(Composite parent) {
204+
if (!OS.isWindows()) {
205+
return;
206+
}
207+
createLabel(parent, ""); //$NON-NLS-1$
208+
Group group = new Group(parent, SWT.LEFT);
209+
group.setText("HiDPI settings"); //$NON-NLS-1$
210+
211+
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
212+
gridData.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
213+
group.setLayoutData(gridData);
214+
group.setFont(parent.getFont());
215+
GridLayout layout = new GridLayout(1, false);
216+
group.setLayout(layout);
217+
Label infoLabel = new Label(group, SWT.WRAP);
218+
infoLabel.setText(WorkbenchMessages.UpdateUIZoomDesc);
219+
GridData labelGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
220+
labelGridData.widthHint = 400; // Adjust this value to control initial wrapping width
221+
infoLabel.setLayoutData(labelGridData);
222+
createLabel(group, ""); //$NON-NLS-1$
223+
224+
updateOnRuntime = createCheckButton(group, WorkbenchMessages.UpdateUIZoomTitle,
225+
initialStateUpdateOnRuntime);
226+
}
227+
195228
private void createThemeIndependentComposits(Composite comp) {
196229
createUseRoundTabs(comp);
197230
createColoredLabelsPref(comp);
@@ -212,6 +245,9 @@ protected void createHideIconsForViewTabs(Composite composite) {
212245
CTabRendering.HIDE_ICONS_FOR_VIEW_TABS_DEFAULT);
213246
hideIconsForViewTabs = createCheckButton(composite, WorkbenchMessages.ViewsPreference_hideIconsForViewTabs,
214247
actualValue);
248+
GridData gridData = new GridData();
249+
gridData.horizontalIndent = 20;
250+
hideIconsForViewTabs.setLayoutData(gridData);
215251
}
216252

217253
private boolean getSwtRendererPreference(String prefName, boolean defaultValue) {
@@ -224,10 +260,6 @@ private boolean getSwtRendererPreference(String prefName, boolean defaultValue)
224260
* @param hideIconsForViewTabs
225261
*/
226262
private void createDependency(Button parent, Button dependent) {
227-
GridData gridData = new GridData();
228-
gridData.horizontalIndent = 20;
229-
dependent.setLayoutData(gridData);
230-
231263
boolean parentState = parent.getSelection();
232264
dependent.setEnabled(parentState);
233265

@@ -341,6 +373,11 @@ public boolean performOk() {
341373
.getSelection();
342374
prefs.putBoolean(PartRenderingEngine.ENABLED_THEME_KEY, themingEnabled.getSelection());
343375

376+
boolean isUpdateOnRuntimeChanged = (updateOnRuntime != null
377+
&& initialStateUpdateOnRuntime != updateOnRuntime.getSelection());
378+
apiStore.setValue(IWorkbenchPreferenceConstants.UPDATE_ON_RUNTIME_KEY,
379+
updateOnRuntime == null ? false : updateOnRuntime.getSelection());
380+
344381
prefs.putBoolean(CTabRendering.USE_ROUND_TABS, useRoundTabs.getSelection());
345382
try {
346383
prefs.flush();
@@ -373,13 +410,20 @@ public boolean performOk() {
373410
if (themingEnabledChanged) {
374411
showRestartDialog();
375412
}
413+
if (isUpdateOnRuntimeChanged) {
414+
showRestartDialog(WorkbenchMessages.RuntimeSettingChangeWarningTitle,
415+
WorkbenchMessages.RuntimeSettingChangeWarningDesc);
416+
}
376417

377418
return super.performOk();
378419
}
379420

380421
private void showRestartDialog() {
381-
if (new MessageDialog(null, WorkbenchMessages.ThemeChangeWarningTitle, null,
382-
WorkbenchMessages.ThemeChangeWarningText, MessageDialog.NONE, 2,
422+
showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText);
423+
}
424+
425+
private void showRestartDialog(String title, String warningText) {
426+
if (new MessageDialog(null, title, null, warningText, MessageDialog.NONE, 2,
383427
WorkbenchMessages.Workbench_RestartButton, WorkbenchMessages.Workbench_DontRestartButton)
384428
.open() == Window.OK) {
385429
Display.getDefault().asyncExec(() -> PlatformUI.getWorkbench().restart());

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ PreferencePageParameterValues_pageLabelSeparator = \ >\
497497
ThemingEnabled = E&nable theming
498498
ThemeChangeWarningText = Restart for the theme changes to take full effect
499499
ThemeChangeWarningTitle = Theme Changed
500+
RuntimeSettingChangeWarningTitle = DPI Setting Changed
501+
RuntimeSettingChangeWarningDesc = Restart for the effect to take place
502+
UpdateUIZoomTitle = Update UI scaling on runtime
503+
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.
500504
# --- Workbench -----
501505
WorkbenchPreference_openMode=Open mode
502506
WorkbenchPreference_doubleClick=D&ouble click

0 commit comments

Comments
 (0)