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 24, 2024
1 parent 6fc79c1 commit e30a52d
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -934,27 +934,33 @@ 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.
*/
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);
}
}
});

addZoomChangeListenerToPromptForRestart();
} finally {
HandlerServiceImpl.pop();
}
}

private void addZoomChangeListenerToPromptForRestart() {
getShell().addListener(SWT.ZoomChanged, event -> {
/**
* Prompt for restart when an SWT zoom change for the primary monitor occurs,
* only when rescaling at runtime is not activated.
*/
if (getShell().getDisplay().isRescalingAtRuntime()) {
return;
}
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 e30a52d

Please sign in to comment.