Skip to content

Commit 2e6e2da

Browse files
committed
Remove lifetime from the Event
Lifetimes don't work nicely when dealing with multithreaded environments in the current design of the existing winit's event handling model, so remove it in favor of `InnerSizeWriter` fences passed to client, so they could try to update the size. Fixes rust-windowing#1387.
1 parent ae7497e commit 2e6e2da

31 files changed

+252
-429
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ And please only add new entries to the top of this list, right below the `# Unre
88

99
# Unreleased
1010

11+
- **Breaking:** Remove lifetime parameter from `Event` and `WindowEvent`.
12+
- **Breaking:** `ScaleFactorChanged` now contains a writer instead of a reference to update inner size.
1113
- On iOS, always wake the event loop when transitioning from `ControlFlow::Poll` to `ControlFlow::Poll`.
1214
- **Breaking:** `ActivationTokenDone` event which could be requested with the new `startup_notify` module, see its docs for more.
1315
- On Wayland, make double clicking and moving the CSD frame more reliable.

examples/child_window.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() -> Result<(), impl std::error::Error> {
4646

4747
println!("parent window: {parent_window:?})");
4848

49-
event_loop.run(move |event: Event<'_, ()>, event_loop, control_flow| {
49+
event_loop.run(move |event: Event<()>, event_loop, control_flow| {
5050
*control_flow = ControlFlow::Wait;
5151

5252
if let Event::WindowEvent { event, window_id } = event {

examples/multithreaded.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ fn main() -> Result<(), impl std::error::Error> {
195195
}
196196
_ => {
197197
if let Some(tx) = window_senders.get(&window_id) {
198-
if let Some(event) = event.to_static() {
199-
tx.send(event).unwrap();
200-
}
198+
tx.send(event).unwrap();
201199
}
202200
}
203201
},

src/error.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use crate::platform_impl;
88
pub enum ExternalError {
99
/// The operation is not supported by the backend.
1010
NotSupported(NotSupportedError),
11+
/// The operation was ignored.
12+
Ignored,
1113
/// The OS cannot perform the operation.
1214
Os(OsError),
1315
}
@@ -74,6 +76,7 @@ impl fmt::Display for ExternalError {
7476
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
7577
match self {
7678
ExternalError::NotSupported(e) => e.fmt(f),
79+
ExternalError::Ignored => write!(f, "Operation was ignored"),
7780
ExternalError::Os(e) => e.fmt(f),
7881
}
7982
}

0 commit comments

Comments
 (0)