Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fix addresses the reported construction-time event ordering and includes appropriate regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Defers GTK DPI-change layouts to prevent SWT.Skin events during widget construction.
Changes:
- Schedules shell relayout asynchronously after scale-factor changes.
- Adds a GTK regression test covering
StyledTextconstruction.
| File | Description |
|---|---|
Display.java |
Defers DPI-triggered shell layouts. |
Test_org_eclipse_swt_custom_StyledText.java |
Verifies skin events occur after construction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
15653c2 to
52ec5b7
Compare
|
Some analysis follow: Suggestion: only the Shell's own window notification should change the global zoom and I don't see a reason why/when non-Shells should send zoom-changed on Gtk. The per-widget hook can stay for refreshing images: // Widget.dpiChanged: return 0; // Shell On both GTK3 and GTK4 that should have the effect of no early Skin event and the zoom doesn't change, while real scale changes still work. That should make the async call not needed and make things even more predictable. Please try it. |
52ec5b7 to
a795fce
Compare
|
Thanks, applied. |
a795fce to
24442c9
Compare
7cb0836 to
d4dba30
Compare
GTK notifies scale-factor on every widget, including a child that is being attached to its parent inside the Control constructor. SWT took this for a DPI change, so the half-built child changed the global zoom, received SWT.ZoomChanged and laid out all shells, which sent SWT.Skin to custom widgets like StyledText before their constructor had initialized them. Only the notification of the Shell window now changes the zoom and sends SWT.ZoomChanged; other widgets still refresh their images. Fixes eclipse-platform#3458 Assisted-by: multiple AI agents and layers of automated tooling 🤖
d4dba30 to
4c1306b
Compare
| @Override | ||
| long dpiChanged (long object, long arg0) { | ||
| // Only the window changes the global zoom, children report their scale while being attached | ||
| if (object == shellHandle) { |
There was a problem hiding this comment.
That is a must have to not regress on Gtk 4.
|
The tests are really complicated and non-generic enough. It would be nice to have them in org.eclipse.swt.tests.gtk and use Gtk specific methods directly so it's easier to understand what it does. |

GTK notifies scale-factor on every widget, including a child that is attached to its parent inside the Control constructor. SWT took this for a DPI change, so the half-built child changed the global zoom, received SWT.ZoomChanged and laid out all shells, which sent SWT.Skin to custom widgets like StyledText before their constructor had finished and caused a NullPointerException. Now only the Shell window's notification changes the zoom and sends SWT.ZoomChanged, while image widgets still refresh their images. Regression tests cover both the early Skin event and the Shell path.
Fixes #3458