Mark extensible enums in winit-core as #[non_exhaustive]

Event, input source, error, data transfer, native key, IME request,
scroll delta and fullscreen enums can now gain variants without a
breaking change. Backends and examples get wildcard arms where they
matched exhaustively; unknown IME requests are reported as
ImeRequestError::NotSupported and unknown fullscreen modes behave
like Fullscreen::Borderless(None).
This commit is contained in:
Olivier Goffart
2026-07-28 14:29:36 +00:00
parent 6a8a334426
commit 37d8a503e4
30 changed files with 57 additions and 21 deletions

View File

@@ -247,6 +247,7 @@ impl TypedData for WinTypedData {
},
// Windows URI drag-and-drop can't be neatly expressed as a binary blob.
SendData::Uris(_) => None,
_ => None,
}
}
@@ -924,6 +925,7 @@ unsafe fn send_data_to_stgmedium(data: SendData, hint: TypeHint) -> Option<STGME
hglobal
},
SendData::Bytes(b) => alloc_hglobal_from(&b)?,
_ => return None,
};
let mut medium = unsafe { std::mem::zeroed::<STGMEDIUM>() };

View File

@@ -431,7 +431,7 @@ impl RootActiveEventLoop for ActiveEventLoop {
) -> Result<CustomCursor, RequestError> {
let cursor = match source {
CustomCursorSource::Image(cursor) => cursor,
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
_ => {
return Err(NotSupportedError::new("unsupported cursor kind").into());
},
};
@@ -1397,6 +1397,7 @@ unsafe fn public_window_callback_inner(
window_pos.cy = old_monitor_rect.bottom - old_monitor_rect.top;
}
},
_ => (),
}
}
}

View File

@@ -967,7 +967,7 @@ impl CoreWindow for Window {
| Fullscreen::Borderless(Some(monitor)) => {
Some(Cow::Borrowed(monitor.cast_ref::<MonitorHandle>().unwrap()))
},
Fullscreen::Borderless(None) => None,
_ => None,
};
let monitor = monitor
@@ -1068,7 +1068,8 @@ impl CoreWindow for Window {
match &request {
ImeRequest::Enable(..) if cap.is_some() => return Err(ImeRequestError::AlreadyEnabled),
ImeRequest::Update(_) if cap.is_none() => return Err(ImeRequestError::NotEnabled),
_ => (),
ImeRequest::Enable(..) | ImeRequest::Update(_) | ImeRequest::Disable => (),
_ => return Err(ImeRequestError::NotSupported),
}
let window = self.window;
@@ -1096,6 +1097,7 @@ impl CoreWindow for Window {
ImeContext::set_ime_allowed(window.hwnd(), false);
return;
},
_ => return,
};
if let Some((spot, size)) = request_data.cursor_area {