Skip to content

refactor(gpui): unify per-platform dispatch in window helpers#103

Merged
StudentWeis merged 1 commit into
mainfrom
refactor/unify-cfg-select-in-window-helpers
May 8, 2026
Merged

refactor(gpui): unify per-platform dispatch in window helpers#103
StudentWeis merged 1 commit into
mainfrom
refactor/unify-cfg-select-in-window-helpers

Conversation

@StudentWeis
Copy link
Copy Markdown
Owner

Summary

Pure cleanup inside src/gui/utils.rs. 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 / _. Fold the Windows path into each function's existing cfg_select! so every platform goes through the same dispatch site.

Linked Issue

Closes #102

Changes

  • hide_window: move the Win32 ShowWindow(hwnd, SW_HIDE) block into the cfg_select! as a target_os = "windows" arm, alongside the existing macOS / Linux / _ arms.
  • active_window: same treatment for the Win32 ShowWindow(hwnd, SW_RESTORE) + SetForegroundWindow(hwnd) block.
  • No platform logic added or removed. The X11 map_windowunmap_window and Win32 SW_RESTORESW_HIDE pairings (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.sh passes locally — 424 tests, no clippy warnings, i18n / icons / themes all OK
  • New / updated tests cover the change — N/A, pure mechanical refactor; runtime semantics are unchanged because cfg_select! expands to the same compile-time branch selection as #[cfg]

Self-Check

  • PR title follows Conventional Commits (refactor(gpui): ...)
  • No hardcoded user-facing strings — i18n keys added to all locale files (N/A)
  • New UI components use gpui-component (N/A)
  • Errors defined with thiserror (no manual impl Display/Error) (N/A)
  • No unrelated changes mixed in

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
@StudentWeis StudentWeis merged commit 8e9e336 into main May 8, 2026
8 checks passed
@StudentWeis StudentWeis deleted the refactor/unify-cfg-select-in-window-helpers branch May 8, 2026 11:33
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.

refactor: unify per-platform dispatch in window helpers via cfg_select!

1 participant