Move from lazy static to OnceLock for global state
Add accessors around the OnceLocks to make them easy to call (e.g. border_window())
Fold related accessors into the OnceLock container, with internal synchronization
e.g. border width becomes a locked property inside Border
Centralize other logical state where appropriate into these new objects where appropriate
e.g. Border hide/show becomes a single property controlled by methods in Border's impl.
Centralize the callbacks as well
e.g. The border paint callback moves from windows_callbacks.rs into border.rs.
In the above example with Border done this way, border becomes almost freestanding, it could move into a module or crate with minimal further dependency flattening.
This leads to the next step though:
Migrate much of the Window code into a Window trait that depends on a hwnd() -> HWND accessor
Hidden and Border can now impl Window, just overriding hwnd() to return their internal field, and have the richness of all the associated functions.
These can be done step-by-step, rather than all at once.
Originally created by @raggi on GitHub (Mar 3, 2024).
I started a demo of the outcome for discussion here: https://github.com/raggi/komorebi/commit/8f6d2bf22c76ec0bc0062d5250ef02bc5ca5899d
The general idea here is a few things:
- Move from lazy static to OnceLock for global state
- Add accessors around the OnceLocks to make them easy to call (e.g. `border_window()`)
- Fold related accessors into the OnceLock container, with internal synchronization
- e.g. border width becomes a locked property inside Border
- Centralize other logical state where appropriate into these new objects where appropriate
- e.g. Border hide/show becomes a single property controlled by methods in Border's impl.
- Centralize the callbacks as well
- e.g. The border paint callback moves from windows_callbacks.rs into border.rs.
In the above example with Border done this way, border becomes almost freestanding, it could move into a module or crate with minimal further dependency flattening.
This leads to the next step though:
- Migrate much of the Window code into a Window trait that depends on a `hwnd() -> HWND` accessor
- Hidden and Border can now impl Window, just overriding hwnd() to return their internal field, and have the richness of all the associated functions.
These can be done step-by-step, rather than all at once.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @raggi on GitHub (Mar 3, 2024).
I started a demo of the outcome for discussion here: https://github.com/raggi/komorebi/commit/8f6d2bf22c76ec0bc0062d5250ef02bc5ca5899d
The general idea here is a few things:
border_window())In the above example with Border done this way, border becomes almost freestanding, it could move into a module or crate with minimal further dependency flattening.
This leads to the next step though:
hwnd() -> HWNDaccessorThese can be done step-by-step, rather than all at once.