Skip to content

Commit b4c60b7

Browse files
daxpeddamadsmtm
andcommitted
Address review
Co-Authored-By: Mads Marquart <mads@marquart.dk>
1 parent e9a4e0b commit b4c60b7

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

src/platform_impl/apple/uikit/monitor.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use objc2_ui_kit::{UIScreen, UIScreenMode};
1212

1313
use super::app_state;
1414
use crate::dpi::{PhysicalPosition, PhysicalSize};
15-
use crate::monitor::VideoModeHandle as RootVideoModeHandle;
1615

1716
// Workaround for `MainThreadBound` implementing almost no traits
1817
#[derive(Debug)]
@@ -175,12 +174,10 @@ impl MonitorHandle {
175174
let modes: Vec<_> = ui_screen
176175
.availableModes()
177176
.into_iter()
178-
.map(|mode| RootVideoModeHandle {
179-
video_mode: VideoModeHandle::new(ui_screen.clone(), mode, mtm),
180-
})
177+
.map(|mode| VideoModeHandle::new(ui_screen.clone(), mode, mtm))
181178
.collect();
182179

183-
modes.into_iter().map(|mode| mode.video_mode)
180+
modes.into_iter()
184181
})
185182
}
186183

src/platform_impl/windows/monitor.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::VecDeque;
1+
use std::collections::{HashSet, VecDeque};
22
use std::hash::Hash;
33
use std::num::{NonZeroU16, NonZeroU32};
44
use std::{io, mem, ptr};
@@ -13,7 +13,6 @@ use windows_sys::Win32::Graphics::Gdi::{
1313

1414
use super::util::decode_wide;
1515
use crate::dpi::{PhysicalPosition, PhysicalSize};
16-
use crate::monitor::VideoModeHandle as RootVideoModeHandle;
1716
use crate::platform_impl::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi};
1817
use crate::platform_impl::platform::util::has_flag;
1918
use crate::platform_impl::platform::window::Window;
@@ -226,14 +225,13 @@ impl MonitorHandle {
226225
// EnumDisplaySettingsExW can return duplicate values (or some of the
227226
// fields are probably changing, but we aren't looking at those fields
228227
// anyway), so we're using a BTreeSet deduplicate
229-
let mut modes = Vec::new();
230-
let mod_map = |mode: RootVideoModeHandle| mode.video_mode;
228+
let mut modes = HashSet::new();
231229

232230
let monitor_info = match get_monitor_info(self.0) {
233231
Ok(monitor_info) => monitor_info,
234232
Err(error) => {
235233
tracing::warn!("Error from get_monitor_info: {error}");
236-
return modes.into_iter().map(mod_map);
234+
return modes.into_iter();
237235
},
238236
};
239237

@@ -247,12 +245,11 @@ impl MonitorHandle {
247245
break;
248246
}
249247

250-
modes
251-
.push(RootVideoModeHandle { video_mode: VideoModeHandle::new(self.clone(), mode) });
248+
modes.insert(VideoModeHandle::new(self.clone(), mode));
252249

253250
i += 1;
254251
}
255252

256-
modes.into_iter().map(mod_map)
253+
modes.into_iter()
257254
}
258255
}

0 commit comments

Comments
 (0)