[GTK] Do not pass a negative size to gtk_widget_size_allocate - #3590
Merged
Merged
Conversation
A Shell with a container border (SWT.TOOL | SWT.ON_TOP, as used by the JFace information controls) that is asked for a height of 0 ends up with a client box of -1: setBounds clamps the height to 1 and resizeBounds then subtracts the 2 pixel border. GTK rejects the negative allocation, so the shell keeps its natural size while its content box is never laid out. That shows up as a correctly sized but completely empty popup, together with Gtk-CRITICAL: gtk_widget_get_preferred_width_for_height: assertion 'height >= 0' failed Gtk-WARNING : gtk_widget_size_allocate(): attempt to allocate widget with width 226 and height -1 Clamp the box size to zero so a degenerate request stays degenerate instead of corrupting the layout. Contributes to eclipse-platform#3539
Contributor
akurtakov
reviewed
Sep 14, 2026
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix correctly addresses the invalid allocation and includes targeted regression coverage.
Pull request overview
Clamps GTK shell content dimensions to prevent invalid negative allocations for zero-height bordered popups.
Changes:
- Clamp calculated content dimensions to zero.
- Add a GTK3 regression test for degenerate popup sizing.
File summaries
| File | Description |
|---|---|
Shell.java |
Prevents negative GTK widget allocations. |
Test_org_eclipse_swt_widgets_Shell.java |
Verifies zero-height popups remain degenerate. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
This is clear move in the right direction so I'm merging it. The whole border story is quite problematic and needs bigger overhaul as on Gtk4 max(gtk_widget_get_margin_top|bottom|start|end) is used as border and luckily for us themes are not going wild and using different margins for each side to totally screw SWT. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Shell with a container border (SWT.TOOL | SWT.ON_TOP, as used by the JFace information controls) that is asked for a height of 0 ends up with a client box of -1, because setBounds clamps the height to 1 and resizeBounds then subtracts the 2 pixel border. GTK rejects the negative allocation with a Gtk-CRITICAL, so the shell keeps its natural size while its content is never laid out, which shows up as a correctly sized but empty popup.
The box size is now clamped to zero, so a degenerate request stays degenerate instead of corrupting the layout. The added test fails without the clamp on both X11 and Wayland. Split out of #3541, which contains the actual coordinate fix for #3539.
Contributes to #3539
🤖 Generated with Claude Code
https://claude.ai/code/session_01M2iVTmY8ykUUVtSEJHNJtV