Repository navigation
glue: store windows in std::vector to preserve creation order - #34
Merged
Merged
Conversation
Replace std::map (and std::set on macos) used to store application windows in the glue adaptations with std::vector<std::pair<window_id, shared_ref<app_window>>> (std::vector<shared_ref<app_window>> on macos, where no window id lookup exists). This way application::get_windows() returns the windows in the order they were opened, which is stable even when new windows are inserted and old ones deleted. The number of windows is expected to be small (2-3), so linear lookup by window_id via find_window() is still fast. Fixes #27.
igagis
reviewed
Nov 24, 2026
igagis
reviewed
Nov 24, 2026
igagis
reviewed
Nov 24, 2026
igagis
reviewed
Nov 24, 2026
igagis
reviewed
Nov 24, 2026
igagis
approved these changes
Nov 25, 2026
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
Fixes #27.
Replaces the per-window storage in the glue adaptations:
linux/xorg,linux/wayland,windows,sdl:std::map<window_id, shared_ref<app_window>>→std::vector<std::pair<window_id, shared_ref<app_window>>>macos:std::set<shared_ref<app_window>>→std::vector<shared_ref<app_window>>(no window id lookup exists on macos, andstd::setalso did not preserve creation order)application::get_windows()now returns the windows in the order they were opened, stable even when new windows are inserted and old ones deleted. The number of windows is expected to be small (2-3), so linear lookup bywindow_idvia the newfind_window()helper is still fast.The
operator</operator==members on macosapp_windowthat existed only forstd::setare removed; macos lookups now compare raw pointers explicitly.Verification
check-format-ruisapp-*targets pass