Skip to content

Commit a9ec6c9

Browse files
akoch-yattaHeikoKlare
authored andcommitted
Workaround for unexpected scrollbars in MultipleHyperlinkPresenter
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 a9ec6c9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ 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+
shell.getDisplay().asyncExec(() -> {
158+
if (!shell.isDisposed()) {
159+
shell.setSize(computeSizeHint());
160+
}
161+
});
162+
});
155163
}
156164

157165
@Override
@@ -217,6 +225,13 @@ public Point computeSizeHint() {
217225
int width;
218226
if (preferedSize.y - scrollBarHeight <= constraints.y) {
219227
width= preferedSize.x - scrollBarWidth;
228+
if (Util.isWin32()) {
229+
/*
230+
* compensate rounding issue in windows
231+
* +1 for preferedSize and +1 for scrollBarWidth
232+
*/
233+
width+= 2;
234+
}
220235
fTable.getVerticalBar().setVisible(false);
221236
} else {
222237
width= Math.min(preferedSize.x, constraints.x);
@@ -225,6 +240,13 @@ public Point computeSizeHint() {
225240
int height;
226241
if (preferedSize.x - scrollBarWidth <= constraints.x) {
227242
height= preferedSize.y - scrollBarHeight;
243+
if (Util.isWin32()) {
244+
/*
245+
* compensate rounding issue in windows
246+
* +1 for preferedSize and +1 for scrollBarHeight
247+
*/
248+
height+= 2;
249+
}
228250
fTable.getHorizontalBar().setVisible(false);
229251
} else {
230252
height= Math.min(preferedSize.y, constraints.y);

0 commit comments

Comments
 (0)