Skip to content

Commit

Permalink
Refactor Windows platform implementation (zed-industries#11393)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JunkuiZhang authored May 7, 2024
1 parent b038fb3 commit c260f7d
Show file tree
Hide file tree
Showing 7 changed files with 1,859 additions and 1,488 deletions.
4 changes: 4 additions & 0 deletions crates/gpui/src/platform/windows.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
mod direct_write;
mod dispatcher;
mod display;
mod events;
mod platform;
mod system_settings;
mod util;
mod window;

pub(crate) use direct_write::*;
pub(crate) use dispatcher::*;
pub(crate) use display::*;
pub(crate) use events::*;
pub(crate) use platform::*;
pub(crate) use system_settings::*;
pub(crate) use util::*;
pub(crate) use window::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/gpui/src/platform/windows/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use windows::{

use crate::{Bounds, DevicePixels, DisplayId, PlatformDisplay, Point, Size};

#[derive(Debug)]
#[derive(Debug, Clone, Copy)]
pub(crate) struct WindowsDisplay {
pub handle: HMONITOR,
pub display_id: DisplayId,
Expand Down
Loading

0 comments on commit c260f7d

Please sign in to comment.