Skip to content

Commit

Permalink
windows: Update crate Windows from 0.53 to 0.56 (#11662)
Browse files Browse the repository at this point in the history
Version 0.56 has fixed many of the previous bugs, and one of the bugs
prevent me implementing some functions.

Release Notes:

- N/A
  • Loading branch information
JunkuiZhang committed May 14, 2024
1 parent d1ee2d0 commit 5154910
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 87 deletions.
106 changes: 57 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ wit-component = "0.201"
sys-locale = "0.3.1"

[workspace.dependencies.windows]
version = "0.53.0"
version = "0.56.0"
features = [
"implement",
"Foundation_Numerics",
Expand Down
1 change: 1 addition & 0 deletions crates/gpui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ xkbcommon = { version = "0.7", features = ["wayland", "x11"] }

[target.'cfg(windows)'.dependencies]
windows.workspace = true
windows-core = "0.56"

[target.'cfg(windows)'.build-dependencies]
embed-resource = "2.4"
Expand Down
20 changes: 11 additions & 9 deletions crates/gpui/src/platform/windows/direct_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl DirectWriteComponent {
// `DirectWriteTextSystem` to run on `win10 1703`+.
let in_memory_loader = factory.CreateInMemoryFontFileLoader()?;
factory.RegisterFontFileLoader(&in_memory_loader)?;
let builder = factory.CreateFontSetBuilder2()?;
let builder = factory.CreateFontSetBuilder()?;
let mut locale_vec = vec![0u16; LOCALE_NAME_MAX_LENGTH as usize];
GetUserDefaultLocaleName(&mut locale_vec);
let locale = String::from_utf16_lossy(&locale_vec);
Expand All @@ -107,7 +107,7 @@ impl DirectWriteTextSystem {
let mut result = std::mem::zeroed();
components
.factory
.GetSystemFontCollection2(false, &mut result, true)?;
.GetSystemFontCollection(false, &mut result, true)?;
result.unwrap()
};
let custom_font_set = unsafe { components.builder.CreateFontSet()? };
Expand Down Expand Up @@ -303,7 +303,7 @@ impl DirectWriteState {
let mut collection = std::mem::zeroed();
self.components
.factory
.GetSystemFontCollection2(false, &mut collection, true)
.GetSystemFontCollection(false, &mut collection, true)
.unwrap();
self.system_font_collection = collection.unwrap();
}
Expand Down Expand Up @@ -496,7 +496,7 @@ impl DirectWriteState {
unsafe {
let font_info = &self.fonts[font_id.0];
let mut metrics = std::mem::zeroed();
font_info.font_face.GetMetrics2(&mut metrics);
font_info.font_face.GetMetrics(&mut metrics);

FontMetrics {
units_per_em: metrics.Base.designUnitsPerEm as _,
Expand Down Expand Up @@ -549,10 +549,11 @@ impl DirectWriteState {
};
self.components.factory.CreateGlyphRunAnalysis(
&glyph_run as _,
1.0,
Some(&transform as _),
DWRITE_RENDERING_MODE_NATURAL,
DWRITE_RENDERING_MODE1_NATURAL,
DWRITE_MEASURING_MODE_NATURAL,
DWRITE_GRID_FIT_MODE_DEFAULT,
DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE,
0.0,
0.0,
)
Expand Down Expand Up @@ -707,7 +708,7 @@ impl DirectWriteState {
render_target.BeginDraw();
if params.is_emoji {
// WARN: only DWRITE_GLYPH_IMAGE_FORMATS_COLR has been tested
let enumerator = self.components.factory.TranslateColorGlyphRun2(
let enumerator = self.components.factory.TranslateColorGlyphRun(
baseline_origin,
&glyph_run as _,
None,
Expand All @@ -721,7 +722,7 @@ impl DirectWriteState {
0,
)?;
while enumerator.MoveNext().is_ok() {
let Ok(color_glyph) = enumerator.GetCurrentRun2() else {
let Ok(color_glyph) = enumerator.GetCurrentRun() else {
break;
};
let color_glyph = &*color_glyph;
Expand All @@ -746,7 +747,7 @@ impl DirectWriteState {
color_glyph.Base.paletteIndex as u32,
color_glyph.measuringMode,
),
_ => render_target.DrawGlyphRun2(
_ => render_target.DrawGlyphRun(
baseline_origin,
&color_glyph.Base.glyphRun,
Some(color_glyph.Base.glyphRunDescription as *const _),
Expand All @@ -759,6 +760,7 @@ impl DirectWriteState {
render_target.DrawGlyphRun(
baseline_origin,
&glyph_run,
None,
&brush,
DWRITE_MEASURING_MODE_NATURAL,
);
Expand Down
5 changes: 4 additions & 1 deletion crates/gpui/src/platform/windows/display.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use itertools::Itertools;
use smallvec::SmallVec;
use std::rc::Rc;
use util::ResultExt;
use uuid::Uuid;
use windows::{
core::*,
Expand Down Expand Up @@ -158,7 +159,9 @@ fn available_monitors() -> SmallVec<[HMONITOR; 4]> {
None,
Some(monitor_enum_proc),
LPARAM(&mut monitors as *mut _ as _),
);
)
.ok()
.log_err();
}
monitors
}
Expand Down
Loading

0 comments on commit 5154910

Please sign in to comment.