Skip to content

Avoid redraws for event-loop wake notifications - #89

Merged
elcritch merged 8 commits into
mainfrom
refactor/improve-main-event-loop
Sep 15, 2026
Merged

elcritch merged 8 commits into
mainfrom
refactor/improve-main-event-loop

Conversation

@elcritch

Copy link
Copy Markdown
Owner

Problem

Merenda treated every event-loop activity result as a reason to redraw every visible window. Siwin uses the same activity result for native input and event-loop wake notifications, so periodic worker traffic caused unchanged frames to be presented repeatedly.

Change

  • remove the blanket repaint after pollEvents and waitEvents
  • keep view and layout invalidation as the application redraw trigger
  • pin Siwin to the native-damage fix in levovix0/siwin#55
  • add focused coverage for wake-only work, targeted invalidation, clean onRender, and native damage behavior
  • document the render scheduling contract

Siwin now schedules onRender for X11 Expose and damaged WinAPI WM_PAINT events, while wake notifications and unrelated native events leave clean windows untouched.

Validation

  • atlas-run tests tests/integrations/nativewindowrepaint.nim -- --hints:off --warnings:off
  • nim check --os:linux --hints:off --warnings:off --errorMax:3 tests/integrations/nativewindowrepaint.nim
  • nim check --os:windows -d:figdraw.opengl --hints:off --warnings:off --errorMax:3 tests/integrations/nativewindowrepaint.nim
  • Siwin focused event-loop test passed on macOS; Linux and Windows compile checks passed.

The full suites are being run separately as requested.

@elcritch

Copy link
Copy Markdown
Owner Author

@Buegel26 could you checkout this PR and make sure the rendering remains good? This works on the previous fixes but also fixes event efficiency.

@Buegel26

Buegel26 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Local repo: commit 199c4bb (HEAD -> main, origin/main, origin/HEAD)

No issues encountered - works for me, no visible changes in behaviour or new weird things. Rendering is smooth for me.

@elcritch Any further things I should consider when testing this?

@Buegel26

Copy link
Copy Markdown
Contributor

BTW: sorry for the delays in reacting sometimes... you are incredibly fast. And inform me when I starting to annoy you with issues :-)

@elcritch

Copy link
Copy Markdown
Owner Author

Local repo: commit 199c4bb (HEAD -> main, origin/main, origin/HEAD)

No issues encountered - works for me, no visible changes in behaviour or new weird things. Rendering is smooth for me.

Excellent! That means the siwin fix works which simplifies event handling and drawing refreshes.

@elcritch Any further things I should consider when testing this?

Nope just that. Making sure previous rendering glitches didn’t come back.

@elcritch

Copy link
Copy Markdown
Owner Author

BTW: sorry for the delays in reacting sometimes... you are incredibly fast. And inform me when I starting to annoy you with issues :-)

No worries about that! I appreciate the issues.

lol yeah been a bit hyper focused lately on it lately.. Want to get it so I can use it for work.

Thanks for testing, it really helps.

@elcritch
elcritch merged commit 011658b into main Sep 15, 2026
12 checks passed
@elcritch
elcritch deleted the refactor/improve-main-event-loop branch September 15, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants