diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPreferenceConstants.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPreferenceConstants.java index 2df7267e907..9d182e6443e 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPreferenceConstants.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPreferenceConstants.java @@ -705,4 +705,14 @@ public interface IWorkbenchPreferenceConstants { * @since 3.130 */ String LARGE_VIEW_LIMIT = "largeViewLimit"; //$NON-NLS-1$ + + /** + *
+ * EXPERIMENTAL. Whether the UI adapts to DPI changes at + * runtime. It only effects Windows. + *
+ * + * @since 3.133 + */ + String RESCALING_AT_RUNTIME = "RESCALING_AT_RUNTIME"; //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java index 667f5c3ce79..5cb4c5cac77 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java @@ -584,7 +584,7 @@ public static int createAndRunWorkbench(final Display display, final WorkbenchAd int orientation = store.getInt(IPreferenceConstants.LAYOUT_DIRECTION); Window.setDefaultOrientation(orientation); } - + setRescaleAtRuntimePropertyFromPreference(display); if (obj instanceof E4Application) { E4Application e4app = (E4Application) obj; E4Workbench e4Workbench = e4app.createE4Workbench(getApplicationContext(), display); @@ -678,6 +678,15 @@ public void update() { return returnCode[0]; } + private static void setRescaleAtRuntimePropertyFromPreference(final Display display) { + boolean rescaleAtRuntime = PrefUtil.getAPIPreferenceStore() + .getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME); + if (rescaleAtRuntime) { + display.setRescalingAtRuntime(rescaleAtRuntime); + System.setProperty("org.eclipse.swt.browser.DefaultType", "edge"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + private static void setSearchContribution(MApplication app, boolean enabled) { for (MTrimContribution contribution : app.getTrimContributions()) { if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java index f6acb4d73df..bebd0cb973d 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java @@ -34,6 +34,16 @@ public class WorkbenchMessages extends NLS { public static String ThemingEnabled; + public static String HiDpiSettingsGroupTitle; + + public static String RescaleAtRuntimeEnabled; + + public static String RescaleAtRuntimeDisclaimer; + + public static String RescaleAtRuntimeSettingChangeWarningTitle; + + public static String RescaleAtRuntimeSettingChangeWarningText; + public static String ThemeChangeWarningText; public static String ThemeChangeWarningTitle; diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java index 5defbcaa271..cc76a5897fe 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java @@ -37,6 +37,7 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.runtime.RegistryFactory; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -53,6 +54,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.util.Util; @@ -73,6 +75,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferenceConstants; @@ -114,6 +117,7 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre private boolean highContrastMode; private Button themingEnabled; + private Button rescaleAtRuntime; private Button hideIconsForViewTabs; private Button showFullTextForViewTabs; @@ -135,6 +139,7 @@ protected Control createContents(Composite parent) { layout.horizontalSpacing = 10; comp.setLayout(layout); createThemeIndependentComposits(comp); + createHiDPISettingsGroup(comp); return comp; } @@ -180,6 +185,8 @@ protected Control createContents(Composite parent) { createHideIconsForViewTabs(comp); createDependency(showFullTextForViewTabs, hideIconsForViewTabs); + createHiDPISettingsGroup(comp); + if (currentTheme != null) { String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId(currentTheme.getId()); if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme.getId().equals(colorsAndFontsThemeId)) { @@ -192,6 +199,30 @@ protected Control createContents(Composite parent) { return comp; } + private void createHiDPISettingsGroup(Composite parent) { + if (!OS.isWindows()) { + return; + } + createLabel(parent, ""); //$NON-NLS-1$ + Group group = new Group(parent, SWT.LEFT); + group.setText(WorkbenchMessages.HiDpiSettingsGroupTitle); + + GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + gridData.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns; + group.setLayoutData(gridData); + group.setFont(parent.getFont()); + GridLayout layout = new GridLayout(1, false); + group.setLayout(layout); + Label infoLabel = new Label(group, SWT.WRAP); + infoLabel.setText(WorkbenchMessages.RescaleAtRuntimeDisclaimer); + infoLabel.setLayoutData(GridDataFactory.defaultsFor(infoLabel).create()); + createLabel(group, ""); //$NON-NLS-1$ + + boolean initialStateRescaleAtRuntime = PrefUtil.getAPIPreferenceStore() + .getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME); + rescaleAtRuntime = createCheckButton(group, WorkbenchMessages.RescaleAtRuntimeEnabled, initialStateRescaleAtRuntime); + } + private void createThemeIndependentComposits(Composite comp) { createUseRoundTabs(comp); createColoredLabelsPref(comp); @@ -227,7 +258,6 @@ private void createDependency(Button parent, Button dependent) { GridData gridData = new GridData(); gridData.horizontalIndent = 20; dependent.setLayoutData(gridData); - boolean parentState = parent.getSelection(); dependent.setEnabled(parentState); @@ -341,6 +371,14 @@ public boolean performOk() { .getSelection(); prefs.putBoolean(PartRenderingEngine.ENABLED_THEME_KEY, themingEnabled.getSelection()); + boolean isRescaleAtRuntimeChanged = false; + if (rescaleAtRuntime != null) { + boolean initialStateRescaleAtRuntime = PrefUtil.getAPIPreferenceStore() + .getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME); + isRescaleAtRuntimeChanged = initialStateRescaleAtRuntime != rescaleAtRuntime.getSelection(); + apiStore.setValue(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, rescaleAtRuntime.getSelection()); + } + prefs.putBoolean(CTabRendering.USE_ROUND_TABS, useRoundTabs.getSelection()); try { prefs.flush(); @@ -367,19 +405,22 @@ public boolean performOk() { colorFontsDecorator.hide(); if (themeChanged || colorsAndFontsThemeChanged) { - showRestartDialog(); + showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText); } } if (themingEnabledChanged) { - showRestartDialog(); + showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText); + } + if (isRescaleAtRuntimeChanged) { + showRestartDialog(WorkbenchMessages.RescaleAtRuntimeSettingChangeWarningTitle, + WorkbenchMessages.RescaleAtRuntimeSettingChangeWarningText); } return super.performOk(); } - private void showRestartDialog() { - if (new MessageDialog(null, WorkbenchMessages.ThemeChangeWarningTitle, null, - WorkbenchMessages.ThemeChangeWarningText, MessageDialog.NONE, 2, + private void showRestartDialog(String title, String warningText) { + if (new MessageDialog(null, title, null, warningText, MessageDialog.NONE, 2, WorkbenchMessages.Workbench_RestartButton, WorkbenchMessages.Workbench_DontRestartButton) .open() == Window.OK) { Display.getDefault().asyncExec(() -> PlatformUI.getWorkbench().restart()); diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties index 5b4f163b81c..fb2ad133e2e 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties @@ -497,6 +497,11 @@ PreferencePageParameterValues_pageLabelSeparator = \ >\ ThemingEnabled = E&nable theming ThemeChangeWarningText = Restart for the theme changes to take full effect ThemeChangeWarningTitle = Theme Changed +RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed +RescaleAtRuntimeSettingChangeWarningText = Restart for the DPI setting changes to take effect +HiDpiSettingsGroupTitle = HiDPI settings +RescaleAtRuntimeEnabled = Monitor-specific UI &scaling +RescaleAtRuntimeDisclaimer = 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. # --- Workbench ----- WorkbenchPreference_openMode=Open mode WorkbenchPreference_doubleClick=D&ouble click