Skip to content

Commit c30c366

Browse files
committed
Workaround for unexpected scrollbars
This commit adds two additional points to the width and height when calculating the size of the composite containing the Hyperlinks in the MultipleHyperlinkPresenter. Additionally this refreshes the size of the parent shell to prevent additional scrollbars in some zoom levels. This serves as a workaround for a current limitation in the SWT implementation on Windows. With certain zoom settings (e.g., 125%, 175% or 225%), the calculated size may be too small, causing the Composite to show Scrollbars, although it calculated to not need scrollbars. This additional width/height is only added for windows and when no scrollbars should be thrown.
1 parent c741652 commit c30c366

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/MultipleHyperlinkPresenter.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ public LinkListInformationControl(Shell parentShell, MultipleHyperlinkHoverManag
152152
fForegroundColor= foregroundColor;
153153
fBackgroundColor= backgroundColor;
154154
create();
155+
getShell().addListener(SWT.ZoomChanged, event -> {
156+
final Shell shell= getShell();
157+
final Display display= shell.getDisplay();
158+
display.asyncExec(() -> {
159+
if (!display.isDisposed()) {
160+
shell.setSize(computeSizeHint());
161+
}
162+
});
163+
});
155164
}
156165

157166
@Override
@@ -217,6 +226,13 @@ public Point computeSizeHint() {
217226
int width;
218227
if (preferedSize.y - scrollBarHeight <= constraints.y) {
219228
width= preferedSize.x - scrollBarWidth;
229+
if (Util.isWin32()) {
230+
/*
231+
* compensate rounding issue in windows
232+
* +1 for preferedSize and +1 for scrollBarWidth
233+
*/
234+
width+= 2;
235+
}
220236
fTable.getVerticalBar().setVisible(false);
221237
} else {
222238
width= Math.min(preferedSize.x, constraints.x);
@@ -225,6 +241,13 @@ public Point computeSizeHint() {
225241
int height;
226242
if (preferedSize.x - scrollBarWidth <= constraints.x) {
227243
height= preferedSize.y - scrollBarHeight;
244+
if (Util.isWin32()) {
245+
/*
246+
* compensate rounding issue in windows
247+
* +1 for preferedSize and +1 for scrollBarHeight
248+
*/
249+
height+= 2;
250+
}
228251
fTable.getHorizontalBar().setVisible(false);
229252
} else {
230253
height= Math.min(preferedSize.y, constraints.y);

0 commit comments

Comments
 (0)