Repository navigation
Resolve Windows GetCurrent across threads and hidden startup windows - #95
Merged
Merged
Conversation
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
EnumWindowsCallback(WindowManager::GetAll()) withIsOwnProcessWindow(hwnd)soGetAll()only enumerates top-level windows owned by the current process instead of foreign processes' windows.WindowManager::GetCurrent()on Windows so whenGetActiveWindow()is null or not owned by this process (for example when called from Flutter's separate Dart UI isolate thread, or while the main window is still hidden before the first frame duringwaitUntilReadyToShow), it falls back to:GetForegroundWindow()(GA_ROOT),g_focused_hwnd,EnumWindowsselecting the current process's first visible top-level window or first hidden normal top-level window.tests/window_manager_ui_thread_windows_test.cppcovering cross-threadGetCurrent(), hidden startupGetCurrent()with ID stability acrossShowWindow, and own-process filtering inGetAll().Related to libnativeapi/nativeapi#39.
Verification
window_cross_thread_dialog_windows_test,window_property_changed_test,window_manager_ui_thread_windows_test,window_controls_test,window_startup_maximize_windows_test,window_close_windows_test, andrun_on_main_thread_windows_teston Windows.window_manageron Windows: cross-thread ownedIFileOpenDialogopens in ~0.36s (vs ~20.32s innativeapi 0.6.1) and cross-threadgetCurrent()resolves the app window instead ofnull.