Skip to content

Commit 6a12fa1

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

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/platform_impl/apple/uikit/monitor.rs

Lines changed: 2 additions & 6 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)]
@@ -170,17 +169,14 @@ impl MonitorHandle {
170169
pub fn video_modes(&self) -> impl Iterator<Item = VideoModeHandle> {
171170
run_on_main(|mtm| {
172171
let ui_screen = self.ui_screen(mtm);
173-
// Use Ord impl of RootVideoModeHandle
174172

175173
let modes: Vec<_> = ui_screen
176174
.availableModes()
177175
.into_iter()
178-
.map(|mode| RootVideoModeHandle {
179-
video_mode: VideoModeHandle::new(ui_screen.clone(), mode, mtm),
180-
})
176+
.map(|mode| VideoModeHandle::new(ui_screen.clone(), mode, mtm))
181177
.collect();
182178

183-
modes.into_iter().map(|mode| mode.video_mode)
179+
modes.into_iter()
184180
})
185181
}
186182

src/platform_impl/windows/monitor.rs

Lines changed: 6 additions & 9 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;
@@ -225,15 +224,14 @@ impl MonitorHandle {
225224
pub fn video_modes(&self) -> impl Iterator<Item = VideoModeHandle> {
226225
// EnumDisplaySettingsExW can return duplicate values (or some of the
227226
// fields are probably changing, but we aren't looking at those fields
228-
// anyway), so we're using a BTreeSet deduplicate
229-
let mut modes = Vec::new();
230-
let mod_map = |mode: RootVideoModeHandle| mode.video_mode;
227+
// anyway), so we're using a HashSet to deduplicate.
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)