Skip to content

Commit

Permalink
Correct activation of monitor-specific rescaling on Windows
Browse files Browse the repository at this point in the history
The activation of monitor-specific rescaling on Windows currently relies
on the method Display#setRescalingAtRuntime(), which was found to not
take the full intended effect.

This change thus replaces the call to that method based on the value of
the according experimental preference by setting the according system
property to activate that behavior in a proper way. It also removes the
obsolete activation of Edge when the experimental preference is set, as
Edge has been enabled by default.
  • Loading branch information
HeikoKlare committed Jan 14, 2025
1 parent 904bdd7 commit 74efba4
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ public final class Workbench extends EventManager implements IWorkbench, org.ecl

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

private static final String SWT_RESCALE_AT_RUNTIME_PROPERTY = "swt.autoScale.updateOnRuntime"; //$NON-NLS-1$

private static final class StartupProgressBundleListener implements ServiceListener {

private final SubMonitor subMonitor;
Expand Down Expand Up @@ -586,7 +588,7 @@ public static int createAndRunWorkbench(final Display display, final WorkbenchAd
int orientation = store.getInt(IPreferenceConstants.LAYOUT_DIRECTION);
Window.setDefaultOrientation(orientation);
}
setRescaleAtRuntimePropertyFromPreference(display);
setRescaleAtRuntimePropertyFromPreference();
if (obj instanceof E4Application) {
E4Application e4app = (E4Application) obj;
E4Workbench e4Workbench = e4app.createE4Workbench(getApplicationContext(), display);
Expand Down Expand Up @@ -680,12 +682,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 setRescaleAtRuntimePropertyFromPreference() {
if (System.getProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY) != null) {
WorkbenchPlugin.log(StatusUtil.newStatus(IStatus.WARNING, SWT_RESCALE_AT_RUNTIME_PROPERTY
+ " is configured (e.g., via the INI), but the according preference should be preferred instead.", //$NON-NLS-1$
new RuntimeException()));
} else {
boolean rescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
}
}

Expand Down

0 comments on commit 74efba4

Please sign in to comment.