[PR #1494] refactor (window): replace raw isize window handles with self-documenting Window and custom ID types #1429

Open
opened 2026-01-05 14:55:15 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/LGUG2Z/komorebi/pull/1494
Author: @JustForFun88
Created: 6/28/2025
Status: 🔄 Open

Base: masterHead: private_window_internals


📝 Commits (5)

  • f9ea220 Stop exposing Ring internals
  • 862a55f Use Arc<str> and WsElementId instead of String
  • 3020684 make serialize and deserialize compact
  • 8cbf024 Make Window internals private.
  • 86b297f Make clippy happy

📊 Changes

41 files changed (+1651 additions, -1663 deletions)

View changed files

📝 komorebi-bar/src/bar.rs (+18 -22)
📝 komorebi-bar/src/main.rs (+13 -23)
📝 komorebi-bar/src/widgets/battery.rs (+1 -1)
📝 komorebi-bar/src/widgets/cpu.rs (+3 -3)
📝 komorebi-bar/src/widgets/date.rs (+1 -1)
📝 komorebi-bar/src/widgets/komorebi.rs (+10 -11)
📝 komorebi-bar/src/widgets/komorebi_layout.rs (+2 -3)
📝 komorebi-bar/src/widgets/memory.rs (+3 -3)
📝 komorebi-bar/src/widgets/mod.rs (+5 -4)
📝 komorebi-bar/src/widgets/network.rs (+2 -2)
📝 komorebi-bar/src/widgets/storage.rs (+2 -2)
📝 komorebi-bar/src/widgets/time.rs (+1 -1)
📝 komorebi-bar/src/widgets/update.rs (+1 -1)
📝 komorebi-gui/src/main.rs (+8 -8)
📝 komorebi/src/animation/prefix.rs (+1 -1)
📝 komorebi/src/border_manager/border.rs (+54 -37)
📝 komorebi/src/border_manager/mod.rs (+152 -129)
📝 komorebi/src/container.rs (+49 -67)
📝 komorebi/src/core/mod.rs (+16 -1)
📝 komorebi/src/focus_manager.rs (+5 -5)

...and 21 more files

📄 Description

This pull request makes the hwnd field of the Window struct private and updates the codebase to use the explicit Window type or dedicated ID structs (such as BorderId, StackbarId) instead of raw isize handles. This makes all window management logic self-documenting, safer, and easier to maintain.

Motivation & Benefits:

  • All data structures and APIs now use intention-revealing types instead of ambiguous integers (e.g., ReaperNotification(pub HashMap<Window, (usize, usize)>)).
  • Removes isize identifiers from related structs, introducing clear ID types.
  • Improves type safety and enforces encapsulation, making the API and overall codebase more robust and understandable.
  • The code is now more self-documenting — window-related logic is explicit and easy to follow at a glance.

Key Refactorings:

  • Hidden now holds a private Window field instead of isize.
  • Stackbar now uses a StackbarId struct that wraps a Window.
  • Border now stores a BorderId and tracking_window: Window instead of raw handles.

Other Notes:

  • Serialization logic remains compatible with previous versions for backward compatibility.
  • This PR is based on #1489 and #1491.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/LGUG2Z/komorebi/pull/1494 **Author:** [@JustForFun88](https://github.com/JustForFun88) **Created:** 6/28/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `private_window_internals` --- ### 📝 Commits (5) - [`f9ea220`](https://github.com/LGUG2Z/komorebi/commit/f9ea220ccbeddc515279bcf5e6b8ee25a20ab9f2) Stop exposing Ring internals - [`862a55f`](https://github.com/LGUG2Z/komorebi/commit/862a55f06feca69a1d519b935427837e5f948905) Use `Arc<str>` and `WsElementId` instead of `String` - [`3020684`](https://github.com/LGUG2Z/komorebi/commit/3020684a16a143c18222e5cb39d460a6ab0c5af8) make serialize and deserialize compact - [`8cbf024`](https://github.com/LGUG2Z/komorebi/commit/8cbf0245cabcb1e920a175926959548f2b86c93d) Make `Window` internals private. - [`86b297f`](https://github.com/LGUG2Z/komorebi/commit/86b297f54b39fe80234568fc75d582d421890e0c) Make clippy happy ### 📊 Changes **41 files changed** (+1651 additions, -1663 deletions) <details> <summary>View changed files</summary> 📝 `komorebi-bar/src/bar.rs` (+18 -22) 📝 `komorebi-bar/src/main.rs` (+13 -23) 📝 `komorebi-bar/src/widgets/battery.rs` (+1 -1) 📝 `komorebi-bar/src/widgets/cpu.rs` (+3 -3) 📝 `komorebi-bar/src/widgets/date.rs` (+1 -1) 📝 `komorebi-bar/src/widgets/komorebi.rs` (+10 -11) 📝 `komorebi-bar/src/widgets/komorebi_layout.rs` (+2 -3) 📝 `komorebi-bar/src/widgets/memory.rs` (+3 -3) 📝 `komorebi-bar/src/widgets/mod.rs` (+5 -4) 📝 `komorebi-bar/src/widgets/network.rs` (+2 -2) 📝 `komorebi-bar/src/widgets/storage.rs` (+2 -2) 📝 `komorebi-bar/src/widgets/time.rs` (+1 -1) 📝 `komorebi-bar/src/widgets/update.rs` (+1 -1) 📝 `komorebi-gui/src/main.rs` (+8 -8) 📝 `komorebi/src/animation/prefix.rs` (+1 -1) 📝 `komorebi/src/border_manager/border.rs` (+54 -37) 📝 `komorebi/src/border_manager/mod.rs` (+152 -129) 📝 `komorebi/src/container.rs` (+49 -67) 📝 `komorebi/src/core/mod.rs` (+16 -1) 📝 `komorebi/src/focus_manager.rs` (+5 -5) _...and 21 more files_ </details> ### 📄 Description This pull request makes the `hwnd` field of the `Window` struct private and updates the codebase to use the explicit `Window` type or dedicated ID structs (such as `BorderId`, `StackbarId`) instead of raw `isize` handles. This makes all window management logic **self-documenting**, safer, and easier to maintain. ## Motivation & Benefits: - All data structures and APIs now use intention-revealing types instead of ambiguous integers (e.g., `ReaperNotification(pub HashMap<Window, (usize, usize)>)`). - Removes `isize` identifiers from related structs, introducing clear ID types. - Improves type safety and enforces encapsulation, making the API and overall codebase more robust and understandable. - The code is now more **self-documenting** — window-related logic is explicit and easy to follow at a glance. ## Key Refactorings: - `Hidden` now holds a private `Window` field instead of `isize`. - `Stackbar` now uses a `StackbarId` struct that wraps a `Window`. - `Border` now stores a `BorderId` and `tracking_window: Window` instead of raw handles. ## Other Notes: - Serialization logic remains compatible with previous versions for backward compatibility. - This PR is based on #1489 and #1491. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-01-05 14:55:15 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#1429