From 7a09bad418e5f1c9c51592021dc3fd7149d27e36 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Tue, 23 Jul 2024 16:30:45 +0200 Subject: [PATCH] Only prompt for restart on zoom change when not rescaling at runtime When the zoom of the primary monitor changes, the workbench asks for a restart to adapt the workbench windows to the changed zoom. With the runtime rescaling functionality recently introduced to SWT, this behavior is only desired if that rescaling functionality is not activated. This change adapts the functionality for showing the restart prompt to only come up if the rescaling functionality is deactivated. --- .../eclipse/ui/internal/WorkbenchWindow.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java index 523ea9f08ee..fd6afee8b6f 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java @@ -934,27 +934,34 @@ public void run() throws Exception { getShell().setData(this); trackShellActivation(); + /** - * When SWT zoom changes for primary monitor, prompt user to restart Eclipse to - * apply the changes. + * When rescaling at runtime is not activated, prompt for restart when an SWT + * zoom change for the primary monitor occurs. */ - getShell().addListener(SWT.ZoomChanged, event -> { - if (getShell().getDisplay().getPrimaryMonitor().equals(getShell().getMonitor())) { - int dialogResponse = MessageDialog.open(MessageDialog.QUESTION, getShell(), - WorkbenchMessages.Workbench_zoomChangedTitle, - WorkbenchMessages.Workbench_zoomChangedMessage, SWT.NONE, - WorkbenchMessages.Workbench_RestartButton, WorkbenchMessages.Workbench_DontRestartButton); - if (event.doit && dialogResponse == 0) { - getWorkbenchImpl().restart(true); - } - } - }); + if (!getShell().getDisplay().isRescalingAtRuntime()) { + addZoomChangeListenerToPromptForRestart(); + } } finally { HandlerServiceImpl.pop(); } } + private void addZoomChangeListenerToPromptForRestart() { + getShell().addListener(SWT.ZoomChanged, event -> { + if (getShell().getDisplay().getPrimaryMonitor().equals(getShell().getMonitor())) { + int dialogResponse = MessageDialog.open(MessageDialog.QUESTION, getShell(), + WorkbenchMessages.Workbench_zoomChangedTitle, WorkbenchMessages.Workbench_zoomChangedMessage, + SWT.NONE, WorkbenchMessages.Workbench_RestartButton, + WorkbenchMessages.Workbench_DontRestartButton); + if (event.doit && dialogResponse == 0) { + getWorkbenchImpl().restart(true); + } + } + }); + } + @PreDestroy void preDestroy() { if (mainMenu != null) {