Skip to content

[Gtk4] Fix layout problems#3331

Open
akurtakov wants to merge 2 commits into
eclipse-platform:masterfrom
akurtakov:3330
Open

[Gtk4] Fix layout problems#3331
akurtakov wants to merge 2 commits into
eclipse-platform:masterfrom
akurtakov:3330

Conversation

@akurtakov
Copy link
Copy Markdown
Member

@akurtakov akurtakov commented May 27, 2026

On Gtk 4 gtk_widget_hide() resets the widget's allocation to 0x0. If the SWT widget is no longer in the HIDDEN state but visibility hasn't propagated in GTK 4, leave it visible on the GTK side so its allocation (and the propagated allocations of its children) survive. Otherwise children of a Composite that was made visible right before this setBounds call would be left at size 0x0 and miss Resize events.

Skip the trailing gtk_widget_hide() on GTK4 when the SWT widget is not in the HIDDEN state, so the allocation survives. GTK3 behaviour is unchanged.

In GTK4, hiding a wigdet resets its allocation to 0x0.
When a previously hidden Control is made visible and GTK runs a layout pass, GTK assigns a fresh allocation via natural-size propagation.
SWT is not notified of this GTK-driven allocation, so any children that lost their allocation while the control was hidden stay at size 0x0 and never fire SWT.Resize.

Override gtk_map in Control so that when GTK maps a widget (after the frame-clock has assigned its new allocation), a deferred parent layout is triggered. This causes SWT to recompute child bounds at the right moment
without needing to know the allocation synchronously inside setVisible().

Fixes #3330

On Gtk 4 gtk_widget_hide() resets the widget's allocation to 0x0. If the
SWT widget is no longer in the HIDDEN state but visibility hasn't
propagated in GTK 4, leave it visible on the GTK side so its allocation
(and the propagated allocations of its children) survive. Otherwise
children of a Composite that was made visible right before this
setBounds call would be left at size 0x0 and miss Resize events.

Skip the trailing gtk_widget_hide() on GTK4 when the SWT widget is not
in the HIDDEN state, so the allocation survives. GTK3 behaviour is
unchanged.

Fixes eclipse-platform#3330
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Test Results (linux)

   94 files  ±0     94 suites  ±0   14m 18s ⏱️ -7s
4 597 tests ±0  4 373 ✅ ±0  224 💤 ±0  0 ❌ ±0 
3 383 runs  ±0  3 308 ✅ ±0   75 💤 ±0  0 ❌ ±0 

Results for commit ef7cfc5. ± Comparison against base commit 823aeba.

♻️ This comment has been updated with latest results.

@akurtakov akurtakov changed the title [Gtk4] Keep allocation after show-allocate hack in Control.setBounds [Gtk4] Fix layout problems May 27, 2026
In GTK4, hiding a wigdet resets its allocation to 0x0.
When
a previously hidden Control is made visible and GTK runs a
layout pass, GTK assigns a fresh allocation via natural-size
propagation.
SWT is not notified of this GTK-driven allocation, so any children that
lost their allocation while the control was hidden stay at size 0x0 and
never fire SWT.Resize.

Override gtk_map in Control so that when GTK maps a widget (after the
frame-clock has assigned its new allocation), a deferred parent layout
is
triggered. This causes SWT to recompute child bounds at the right moment
without needing to know the allocation synchronously inside
setVisible().

Fixes eclipse-platform#3330
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[GTK4] Layout not propagated correctly

1 participant