Skip to content

Remove system-wide EVENT_OBJECT_LOCATIONCHANGE occlusion hook and install occlusion hooks lazily - #97

Merged
lijy91 merged 1 commit into
mainfrom
fix/windows-occlusion-hook-issue-40
Nov 19, 2026
Merged

lijy91 merged 1 commit into
mainfrom
fix/windows-occlusion-hook-issue-40

Conversation

@lijy91

@lijy91 lijy91 commented Nov 19, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the Windows drag-resize cursor lag reported in libnativeapi/nativeapi#40:

  1. Remove the system-wide EVENT_OBJECT_LOCATIONCHANGE WinEvent hook (src/platform/windows/window_manager_windows.cpp):
    • Windows fires EVENT_OBJECT_LOCATIONCHANGE on every cursor move (OBJID_CURSOR) and every window move across all processes, flooding Flutter's platform/UI thread during the modal resize loop.
    • Replace it with EVENT_SYSTEM_MOVESIZEEND (fires once when another process's window finishes an interactive move/resize, never on cursor moves) plus ScheduleOcclusionRefresh() from OnWindowChanged when our own process's windows move or resize programmatically.
  2. Install occlusion hooks lazily instead of unconditionally in WindowManager():
    • Add WindowManager::Impl::SetOcclusionTrackingEnabled(bool) called from StartEventListening() (0→1 listener transition) and StopEventListening() (1→0 listener transition), marshaled to the observation thread.
    • Apps that only use WindowManager::GetCurrent() / command-channel setters without listeners no longer install any system-wide occlusion WinEvent hooks; Window::GetOcclusionState() computes occlusion on demand and is unaffected.

Related to libnativeapi/nativeapi#40.

Verification

  • window_occlusion_test: 10/10 PASS (showing, covering, moving cover away/back, hiding cover, minimizing, restoring, hiding).
  • Windows CTest: 5/5 passed (window_cross_thread_dialog_windows_test, window_startup_maximize_windows_test, window_property_changed_test, window_close_windows_test, window_manager_ui_thread_windows_test).

@lijy91
lijy91 merged commit de5a276 into main Nov 19, 2026
8 of 10 checks passed
@lijy91
lijy91 deleted the fix/windows-occlusion-hook-issue-40 branch November 19, 2026 12:15
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.

1 participant