Skip to content

Commit 853812c

Browse files
committed
appkit: patch a unit test issue in monitor.rs regarding display ID.
On macOS, make AppKit monitor handle tests derive their reference display IDs from `CGMainDisplayID`, preventing failures on systems where the primary monitor is not display `1`.
1 parent a9c189a commit 853812c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

winit-appkit/src/monitor.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,10 @@ mod tests {
352352

353353
#[test]
354354
fn uuid_stable() {
355-
let handle_a = MonitorHandle::new(1).unwrap();
356-
let handle_b = MonitorHandle::new(1).unwrap();
355+
let primary_id = CGMainDisplayID();
356+
357+
let handle_a = MonitorHandle::new(primary_id).unwrap();
358+
let handle_b = MonitorHandle::new(primary_id).unwrap();
357359
assert_eq!(handle_a, handle_b);
358360
assert_eq!(handle_a.display_id(), handle_b.display_id());
359361
assert_eq!(handle_a.uuid(), handle_b.uuid());
@@ -368,8 +370,10 @@ mod tests {
368370
/// Test the MonitorHandle::new fallback.
369371
#[test]
370372
fn monitorhandle_from_zero() {
373+
let primary_id = CGMainDisplayID();
374+
371375
let handle0 = MonitorHandle::new(0).unwrap();
372-
let handle1 = MonitorHandle::new(1).unwrap();
376+
let handle1 = MonitorHandle::new(primary_id).unwrap();
373377
assert_eq!(handle0, handle1);
374378
assert_eq!(handle0.display_id(), handle1.display_id());
375379
assert_eq!(handle0.uuid(), handle1.uuid());

winit/src/changelog/unreleased.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ changelog entry.
264264
- On macOS, fixed redundant `SurfaceResized` event at window creation.
265265
- On macOS, don't panic on monitors with unknown bit-depths.
266266
- On macOS, fixed crash when closing the window on macOS 26+.
267+
- On macOS, make AppKit monitor handle tests derive their reference display IDs from
268+
`CGMainDisplayID`, preventing failures on systems where the primary monitor is not display `1`.
267269
- On Windows, account for mouse wheel lines per scroll setting for `WindowEvent::MouseWheel`.
268270
- On Windows, `Window::theme` will return the correct theme after setting it through `Window::set_theme`.
269271
- On Windows, `Window::set_theme` will change the title bar color immediately now.

0 commit comments

Comments
 (0)