Skip to content

Commit 2d53a65

Browse files
committed
Move experimental monitor-specific scaling preference to IDEApplication
Monitor-specific scaling needs to be activated before the display that is supposed to run in that mode is created. Doing that in the Workbench, like it has been done before, is insufficient, as the display has already been created by then. This change moves the evaluation of the experimental preference to the IDEApplication right before the display creation. This limits the effect to application based on the IDEApplication, which is also added to the disclaimer for the according preference in the UI.
1 parent 9b70eea commit 2d53a65

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.eclipse.swt.widgets.Label;
6363
import org.eclipse.swt.widgets.Shell;
6464
import org.eclipse.ui.IWorkbench;
65+
import org.eclipse.ui.IWorkbenchPreferenceConstants;
6566
import org.eclipse.ui.PlatformUI;
6667
import org.eclipse.ui.internal.Workbench;
6768
import org.eclipse.ui.internal.WorkbenchPlugin;
@@ -105,6 +106,8 @@ public class IDEApplication implements IApplication, IExecutableExtension {
105106

106107
private static final String USER_NAME = "user.name"; //$NON-NLS-1$
107108

109+
private static final String SWT_RESCALE_AT_RUNTIME_PROPERTY = "swt.autoScale.updateOnRuntime"; //$NON-NLS-1$
110+
108111
// Use the branding plug-in of the platform feature since this is most likely
109112
// to change on an update of the IDE.
110113
private static final String WORKSPACE_CHECK_REFERENCE_BUNDLE_NAME = "org.eclipse.platform"; //$NON-NLS-1$
@@ -205,9 +208,22 @@ public Object start(IApplicationContext appContext) throws Exception {
205208
* @return the display used by the application
206209
*/
207210
protected Display createDisplay() {
211+
setRescaleAtRuntimePropertyFromPreference();
208212
return PlatformUI.createDisplay();
209213
}
210214

215+
private static void setRescaleAtRuntimePropertyFromPreference() {
216+
if (System.getProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY) != null) {
217+
WorkbenchPlugin.log(Status.warning(SWT_RESCALE_AT_RUNTIME_PROPERTY
218+
+ " is configured (e.g., via the INI), but the according preference should be preferred instead." //$NON-NLS-1$
219+
));
220+
} else {
221+
boolean rescaleAtRuntime = WorkbenchPlugin.getDefault().getPreferenceStore()
222+
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
223+
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
224+
}
225+
}
226+
211227
@Override
212228
public void setInitializationData(IConfigurationElement config,
213229
String propertyName, Object data) {

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ public final class Workbench extends EventManager implements IWorkbench, org.ecl
298298

299299
private static final String EDGE_USER_DATA_FOLDER = "org.eclipse.swt.internal.win32.Edge.userDataFolder"; //$NON-NLS-1$
300300

301-
private static final String SWT_RESCALE_AT_RUNTIME_PROPERTY = "swt.autoScale.updateOnRuntime"; //$NON-NLS-1$
302-
303301
private static final class StartupProgressBundleListener implements ServiceListener {
304302

305303
private final SubMonitor subMonitor;
@@ -588,7 +586,6 @@ public static int createAndRunWorkbench(final Display display, final WorkbenchAd
588586
int orientation = store.getInt(IPreferenceConstants.LAYOUT_DIRECTION);
589587
Window.setDefaultOrientation(orientation);
590588
}
591-
setRescaleAtRuntimePropertyFromPreference();
592589
if (obj instanceof E4Application) {
593590
E4Application e4app = (E4Application) obj;
594591
E4Workbench e4Workbench = e4app.createE4Workbench(getApplicationContext(), display);
@@ -682,18 +679,6 @@ public void update() {
682679
return returnCode[0];
683680
}
684681

685-
private static void setRescaleAtRuntimePropertyFromPreference() {
686-
if (System.getProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY) != null) {
687-
WorkbenchPlugin.log(StatusUtil.newStatus(IStatus.WARNING, SWT_RESCALE_AT_RUNTIME_PROPERTY
688-
+ " is configured (e.g., via the INI), but the according preference should be preferred instead.", //$NON-NLS-1$
689-
new RuntimeException()));
690-
} else {
691-
boolean rescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
692-
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
693-
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
694-
}
695-
}
696-
697682
private static void setSearchContribution(MApplication app, boolean enabled) {
698683
for (MTrimContribution contribution : app.getTrimContributions()) {
699684
if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private void createHiDPISettingsGroup(Composite parent) {
218218
infoLabel.setLayoutData(GridDataFactory.defaultsFor(infoLabel).create());
219219
createLabel(group, ""); //$NON-NLS-1$
220220

221-
boolean initialStateRescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
221+
boolean initialStateRescaleAtRuntime = WorkbenchPlugin.getDefault().getPreferenceStore()
222222
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
223223
rescaleAtRuntime = createCheckButton(group, WorkbenchMessages.RescaleAtRuntimeEnabled, initialStateRescaleAtRuntime);
224224
}
@@ -373,10 +373,12 @@ public boolean performOk() {
373373

374374
boolean isRescaleAtRuntimeChanged = false;
375375
if (rescaleAtRuntime != null) {
376-
boolean initialStateRescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
376+
IPreferenceStore workbenchStore = WorkbenchPlugin.getDefault().getPreferenceStore();
377+
boolean initialStateRescaleAtRuntime = workbenchStore
377378
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
378379
isRescaleAtRuntimeChanged = initialStateRescaleAtRuntime != rescaleAtRuntime.getSelection();
379-
apiStore.setValue(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, rescaleAtRuntime.getSelection());
380+
workbenchStore.setValue(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME,
381+
rescaleAtRuntime.getSelection());
380382
}
381383

382384
prefs.putBoolean(CTabRendering.USE_ROUND_TABS, useRoundTabs.getSelection());

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed
504504
RescaleAtRuntimeSettingChangeWarningText = Restart for the DPI setting changes to take effect
505505
HiDpiSettingsGroupTitle = HiDPI settings
506506
RescaleAtRuntimeEnabled = Monitor-specific UI &scaling
507-
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.
507+
RescaleAtRuntimeDisclaimer = EXPERIMENTAL! Activating this option will dynamically scale all windows according to the monitor they are currently in. This feature will currently only have an effect when running an IDEApplication. It is still in development and therefore considered experimental.
508508
# --- Workbench -----
509509
WorkbenchPreference_openMode=Open mode
510510
WorkbenchPreference_doubleClick=D&ouble click

0 commit comments

Comments
 (0)