Skip to content

Commit a47014f

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 a47014f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import org.eclipse.swt.widgets.Table;
4040
import org.eclipse.swt.widgets.TableItem;
4141

42+
import org.eclipse.core.runtime.Platform.OS;
43+
4244
import org.eclipse.jface.preference.IPreferenceStore;
4345
import org.eclipse.jface.resource.JFaceResources;
4446
import org.eclipse.jface.util.Geometry;
@@ -152,6 +154,15 @@ public LinkListInformationControl(Shell parentShell, MultipleHyperlinkHoverManag
152154
fForegroundColor= foregroundColor;
153155
fBackgroundColor= backgroundColor;
154156
create();
157+
getShell().addListener(SWT.ZoomChanged, event -> {
158+
final Shell shell= getShell();
159+
final Display display= shell.getDisplay();
160+
display.asyncExec(() -> {
161+
if (!display.isDisposed()) {
162+
shell.setSize(computeSizeHint());
163+
}
164+
});
165+
});
155166
}
156167

157168
@Override
@@ -217,6 +228,13 @@ public Point computeSizeHint() {
217228
int width;
218229
if (preferedSize.y - scrollBarHeight <= constraints.y) {
219230
width= preferedSize.x - scrollBarWidth;
231+
if (OS.isWindows()) {
232+
/*
233+
* compensate rounding issue in windows
234+
* +1 for preferedSize and +1 for scrollBarWidth
235+
*/
236+
width+= 2;
237+
}
220238
fTable.getVerticalBar().setVisible(false);
221239
} else {
222240
width= Math.min(preferedSize.x, constraints.x);
@@ -225,6 +243,13 @@ public Point computeSizeHint() {
225243
int height;
226244
if (preferedSize.x - scrollBarWidth <= constraints.x) {
227245
height= preferedSize.y - scrollBarHeight;
246+
if (OS.isWindows()) {
247+
/*
248+
* compensate rounding issue in windows
249+
* +1 for preferedSize and +1 for scrollBarHeight
250+
*/
251+
height+= 2;
252+
}
228253
fTable.getHorizontalBar().setVisible(false);
229254
} else {
230255
height= Math.min(preferedSize.y, constraints.y);

0 commit comments

Comments
 (0)