Refactor Windows platform implementation (#11393)
This aligns the Windows platform implementation with a code style similar to macOS platform, eliminating most of the `Cell`s and `Mutex`es. This adjustment facilitates potential future porting to a multi-threaded implementation if required. Overall, this PR made the following changes: it segregated all member variables in `WindowsPlatform` and `WindowsWindow`, grouping together variables that remain constant throughout the entire app lifecycle, while placing variables that may change during app runtime into `RefCell`. Edit: During the code refactoring process, a bug was also fixed. **Before**: Close window when file has changed, nothing happen: https://github.com/zed-industries/zed/assets/14981363/0bcda7c1-808c-4b36-8953-a3a3365a314e **After**: Now `should_close` callback is properly handled https://github.com/zed-industries/zed/assets/14981363/c8887b72-9a0b-42ad-b9ab-7d0775d843f5 Release Notes: - N/A
This commit is contained in:
parent
b038fb3729
commit
c260f7d5ac
7 changed files with 1862 additions and 1491 deletions
|
@ -74,6 +74,7 @@ pub(crate) unsafe fn set_window_long(
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct OwnedHandle(HANDLE);
|
||||
|
||||
impl OwnedHandle {
|
||||
|
@ -135,3 +136,19 @@ pub(crate) fn load_cursor(style: CursorStyle) -> HCURSOR {
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn logical_size(physical_size: Size<DevicePixels>, scale_factor: f32) -> Size<Pixels> {
|
||||
Size {
|
||||
width: px(physical_size.width.0 as f32 / scale_factor),
|
||||
height: px(physical_size.height.0 as f32 / scale_factor),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn logical_point(x: f32, y: f32, scale_factor: f32) -> Point<Pixels> {
|
||||
Point {
|
||||
x: px(x / scale_factor),
|
||||
y: px(y / scale_factor),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue