Skip to content

Commit 5d899d6

Browse files
committed
Move EventLoopExtRunOnDemand to winit-core
1 parent c606833 commit 5d899d6

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

examples/run_on_demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
77

88
use winit::application::ApplicationHandler;
99
use winit::event::WindowEvent;
10+
use winit::event_loop::run_on_demand::EventLoopExtRunOnDemand;
1011
use winit::event_loop::{ActiveEventLoop, EventLoop};
11-
use winit::platform::run_on_demand::EventLoopExtRunOnDemand;
1212
use winit::window::{Window, WindowAttributes, WindowId};
1313

1414
#[path = "util/fill.rs"]

src/changelog/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ changelog entry.
200200
`NamedKey::Super` still exists, but it's non-functional and deprecated, `NamedKey::Meta` should be used instead.
201201
- Move `IconExtWindows` into `WinIcon`.
202202
- Move `EventLoopExtPumpEvents` and `PumpStatus` from platform module to `winit::event_loop::pump_events`.
203+
- Move `EventLoopExtRunOnDemand` from platform module to `winit::event_loop::run_on_demand`.
203204

204205
### Removed
205206

src/event_loop.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,31 @@ impl winit_core::event_loop::pump_events::EventLoopExtPumpEvents for EventLoop {
312312
self.event_loop.pump_app_events(timeout, app)
313313
}
314314
}
315+
316+
#[allow(unused_imports)]
317+
#[cfg(any(
318+
windows_platform,
319+
macos_platform,
320+
android_platform,
321+
x11_platform,
322+
wayland_platform,
323+
docsrs,
324+
))]
325+
impl winit_core::event_loop::run_on_demand::EventLoopExtRunOnDemand for EventLoop {
326+
fn run_app_on_demand<A: ApplicationHandler>(&mut self, app: A) -> Result<(), EventLoopError> {
327+
self.event_loop.run_app_on_demand(app)
328+
}
329+
}
330+
331+
/// ```
332+
/// use winit::event_loop::EventLoop;
333+
/// use winit::platform::run_on_demand::EventLoopExtRunOnDemand;
334+
///
335+
/// let mut event_loop = EventLoop::new().unwrap();
336+
/// event_loop.run_on_demand(|_, _| {
337+
/// // Attempt to run the event loop re-entrantly; this must fail.
338+
/// event_loop.run_on_demand(|_, _| {});
339+
/// });
340+
/// ```
341+
#[allow(dead_code)]
342+
fn test_run_on_demand_cannot_access_event_loop() {}

src/platform/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,5 @@ pub mod windows;
2121
#[cfg(x11_platform)]
2222
pub mod x11;
2323

24-
#[allow(unused_imports)]
25-
#[cfg(any(
26-
windows_platform,
27-
macos_platform,
28-
android_platform,
29-
x11_platform,
30-
wayland_platform,
31-
docsrs,
32-
))]
33-
pub mod run_on_demand;
34-
3524
#[cfg(any(windows_platform, macos_platform, x11_platform, wayland_platform, docsrs))]
3625
pub mod scancode;

winit-core/src/event_loop/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod pump_events;
2+
pub mod run_on_demand;
23

34
use std::fmt::{self, Debug};
45
use std::sync::atomic::{AtomicUsize, Ordering};

src/platform/run_on_demand.rs renamed to winit-core/src/event_loop/run_on_demand.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::application::ApplicationHandler;
22
use crate::error::EventLoopError;
3-
use crate::event_loop::EventLoop;
43
#[cfg(doc)]
54
use crate::{
65
event_loop::{pump_events::EventLoopExtPumpEvents, ActiveEventLoop},
76
window::Window,
87
};
98

9+
#[allow(rustdoc::broken_intra_doc_links)] // FIXME(madsmtm): Fix these.
1010
/// Additional methods on [`EventLoop`] to return control flow to the caller.
1111
pub trait EventLoopExtRunOnDemand {
1212
/// Run the application with the event loop on the calling thread.
@@ -63,22 +63,3 @@ pub trait EventLoopExtRunOnDemand {
6363
/// [`set_control_flow()`]: ActiveEventLoop::set_control_flow()
6464
fn run_app_on_demand<A: ApplicationHandler>(&mut self, app: A) -> Result<(), EventLoopError>;
6565
}
66-
67-
impl EventLoopExtRunOnDemand for EventLoop {
68-
fn run_app_on_demand<A: ApplicationHandler>(&mut self, app: A) -> Result<(), EventLoopError> {
69-
self.event_loop.run_app_on_demand(app)
70-
}
71-
}
72-
73-
/// ```compile_fail
74-
/// use winit::event_loop::EventLoop;
75-
/// use winit::platform::run_on_demand::EventLoopExtRunOnDemand;
76-
///
77-
/// let mut event_loop = EventLoop::new().unwrap();
78-
/// event_loop.run_on_demand(|_, _| {
79-
/// // Attempt to run the event loop re-entrantly; this must fail.
80-
/// event_loop.run_on_demand(|_, _| {});
81-
/// });
82-
/// ```
83-
#[allow(dead_code)]
84-
fn test_run_on_demand_cannot_access_event_loop() {}

0 commit comments

Comments
 (0)