refactor(gpui): unify per-platform dispatch in window helpers#103
Merged
Conversation
Both hide_window and active_window had two adjacent dispatch blocks: a standalone #[cfg(target_os = "windows")] block followed by a cfg_select! covering macos / linux / _. The split was historical — the Windows branch needed a multi-line unsafe body with a local hwnd binding, while the others were one-liners. cfg_select! arms accept arbitrary statement blocks, so there is no real reason for the asymmetry. Fold the Windows path into each function's existing cfg_select! so every platform goes through the same dispatch site. Behaviour is unchanged on every target — cfg_select! expands to the same compile-time branch selection as #[cfg]. The X11 map/unmap and Win32 SW_HIDE/SW_RESTORE pairings (see issue #101) are preserved verbatim. Refs #102
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
Pure cleanup inside
src/gui/utils.rs. Bothhide_windowandactive_windowhad two adjacent dispatch blocks: a standalone#[cfg(target_os = "windows")]block followed by acfg_select!covering macOS / Linux /_. Fold the Windows path into each function's existingcfg_select!so every platform goes through the same dispatch site.Linked Issue
Closes #102
Changes
hide_window: move the Win32ShowWindow(hwnd, SW_HIDE)block into thecfg_select!as atarget_os = "windows"arm, alongside the existing macOS / Linux /_arms.active_window: same treatment for the Win32ShowWindow(hwnd, SW_RESTORE) + SetForegroundWindow(hwnd)block.map_window↔unmap_windowand Win32SW_RESTORE↔SW_HIDEpairings (see refactor: drop redundant Win32 activate calls in active_window #101) are preserved verbatim — they bridge the project's hide path with GPUI's activation path and must stay.Testing
scripts/precheck.shpasses locally — 424 tests, no clippy warnings, i18n / icons / themes all OKcfg_select!expands to the same compile-time branch selection as#[cfg]Self-Check
refactor(gpui): ...)gpui-component(N/A)thiserror(no manualimpl Display/Error) (N/A)