Skip to content

Commit

Permalink
Only prompt for restart on zoom change when not rescaling at runtime
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HeikoKlare committed Jul 23, 2024
1 parent 8b4c0b6 commit 7a09bad
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7a09bad

Please sign in to comment.