Repository navigation
Coalesce Windows move/resize events and add fast paths for zero listeners and message dispatch - #96
Merged
Merged
Conversation
…ners and message dispatch
lijy91
force-pushed
the
fix/windows-resize-lag-issue-30
branch
from
November 19, 2026 12:25
f75d3f6 to
8bf490c
Compare
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.
Summary
Addresses all four Windows resize/drag performance root causes reported in libnativeapi/nativeapi#30:
src/foundation/event_emitter.h,src/platform/windows/window_manager_windows.cpp):listener_count_and lock-freeHasAnyListeners()toEventEmitter; short-circuitEmit()when zero listeners are registered.g_has_window_listenersinwindow_manager_windows.cpp(refreshing baseline snapshots on 0→1 listener transition and clearing pending timers on 1→0). When zero listeners exist,WindowGeometryProcpasses straight through toDefSubclassProcwithout locking, diffing snapshots, or constructing events.WindowMovedEvent/WindowResizedEventand remove redundant getter round-trips (src/platform/windows/window_manager_windows.cpp):WM_ENTERSIZEMOVE..WM_EXITSIZEMOVE) and rapidSetWindowPosbursts within 50 ms, defer geometry delivery to a low-priority 50 msWM_TIMERinstead of constructing and delivering events synchronously inside everyWM_WINDOWPOSCHANGED; flush the final geometry immediately onWM_EXITSIZEMOVE.WindowSnapshotinstead of re-queryingWindowRegistry+GetSize()/GetPosition()per event.WindowMessageDispatcherfast path withSetWindowSubclass+ lock-free message bitmask (src/platform/windows/window_message_dispatcher.{h,cpp},src/platform/windows/window_windows.cpp):SetWindowLongPtr(GWLP_WNDPROC)toSetWindowSubclasswith per-windowWindowStatepassed viadwRefDataand a lock-free atomic message-interest bitmask (0..1023).RegisterHandler(HWND, std::initializer_list<UINT>, handler)overload and switchminimumSize/maximumSize(WM_GETMINMAXINFO),aspectRatio(WM_SIZING), andalwaysOnBottom(WM_WINDOWPOSCHANGING) to it so unrelated messages bypass mutex locking, hash lookups, vector allocation, and sorting.tests/window_geometry_coalesce_windows_test.cpp):SetWindowPosburst coalescing, andWM_ENTERSIZEMOVE..WM_EXITSIZEMOVEsession-edge flushing.Related to libnativeapi/nativeapi#30.
Verification
window_geometry_coalesce_windows_test,window_manager_ui_thread_windows_test,window_cross_thread_dialog_windows_test,window_property_changed_test,window_startup_maximize_windows_test,window_close_windows_test,view_updates_windows_test,tray_template_windows_test,window_popup_caption_windows_test, andwindow_maximize_button_test.