Skip to content

Commit

Permalink
Find/replace overlay: asynchronously update on editor movement eclips…
Browse files Browse the repository at this point in the history
…e-platform#2138

The update of the find/replace overlay placement and size while a
repaint for its target editor is being processed (e.g., in order to
handle minimizing/maximizing the target editor) is currently executed
just-in-time. Other updates, reacting to movements and resizes of the
shell, are processed asynchronously. The just-in-time execution leads to
deadlocks on GTK.

With this change, all update operations for the size and position of the
overlay are performed via asynchronous executions scheduled via the
Display. In addition, changing visibility for the overlay is only
performed if the currently visibility state does not fit.

Fixes eclipse-platform#2138
  • Loading branch information
HeikoKlare committed Aug 1, 2024
1 parent 1778483 commit 60c835b
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,24 @@ private void performSelectAll() {
private ControlListener shellMovementListener = new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
if (getShell() != null) {
getShell().getDisplay().asyncExec(() -> updatePlacementAndVisibility());
}
asyncUpdatePlacementAndVisibility();
}

@Override
public void controlResized(ControlEvent e) {
if (getShell() != null) {
getShell().getDisplay().asyncExec(() -> updatePlacementAndVisibility());
}
asyncUpdatePlacementAndVisibility();
}
};

private PaintListener widgetMovementListener = __ -> asyncUpdatePlacementAndVisibility();

private void asyncUpdatePlacementAndVisibility() {
Shell shell = getShell();
if (shell != null) {
shell.getDisplay().asyncExec(this::updatePlacementAndVisibility);
}
}

private ShellAdapter overlayDeactivationListener = new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
Expand All @@ -220,8 +225,6 @@ public void shellDeactivated(ShellEvent e) {
}
};

private PaintListener widgetMovementListener = __ -> updatePlacementAndVisibility();

private static class TargetPartVisibilityHandler implements IPartListener2, IPageChangedListener {
private final IWorkbenchPart targetPart;
private final IWorkbenchPart topLevelPart;
Expand Down Expand Up @@ -926,11 +929,16 @@ private void updatePosition(Rectangle overlayBounds) {
}

private void updateVisibility(Rectangle targetControlBounds, Rectangle overlayBounds) {
boolean shallBeVisible = true;
if (positionAtTop) {
getShell().setVisible(
overlayBounds.y + overlayBounds.height <= targetControlBounds.y + targetControlBounds.height);
shallBeVisible = overlayBounds.y + overlayBounds.height <= targetControlBounds.y
+ targetControlBounds.height;
} else {
getShell().setVisible(overlayBounds.y >= targetControlBounds.y);
shallBeVisible = overlayBounds.y >= targetControlBounds.y;
}
Shell shell = getShell();
if (shallBeVisible != shell.isVisible()) {
shell.setVisible(shallBeVisible);
}
}

Expand Down

0 comments on commit 60c835b

Please sign in to comment.