Skip to content

Commit 6fc0800

Browse files
committed
Move EventLoopExtPumpEvents and PumpStatus to winit-core
1 parent ed4ebd4 commit 6fc0800

File tree

14 files changed

+37
-41
lines changed

14 files changed

+37
-41
lines changed

examples/pump_events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ fn main() -> std::process::ExitCode {
99

1010
use winit::application::ApplicationHandler;
1111
use winit::event::WindowEvent;
12+
use winit::event_loop::pump_events::{EventLoopExtPumpEvents, PumpStatus};
1213
use winit::event_loop::{ActiveEventLoop, EventLoop};
13-
use winit::platform::pump_events::{EventLoopExtPumpEvents, PumpStatus};
1414
use winit::window::{Window, WindowAttributes, WindowId};
1515

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

src/changelog/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ changelog entry.
199199
- Renamed "super" key to "meta", to match the naming in the W3C specification.
200200
`NamedKey::Super` still exists, but it's non-functional and deprecated, `NamedKey::Meta` should be used instead.
201201
- Move `IconExtWindows` into `WinIcon`.
202+
- Move `EventLoopExtPumpEvents` and `PumpStatus` from platform module to `winit::event_loop::pump_events`.
202203

203204
### Removed
204205

src/event_loop.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl AsFd for EventLoop {
275275
///
276276
/// [`calloop`]: https://crates.io/crates/calloop
277277
/// [`mio`]: https://crates.io/crates/mio
278-
/// [`pump_app_events`]: crate::platform::pump_events::EventLoopExtPumpEvents::pump_app_events
278+
/// [`pump_app_events`]: crate::event_loop::pump_events::EventLoopExtPumpEvents::pump_app_events
279279
fn as_fd(&self) -> BorrowedFd<'_> {
280280
self.event_loop.as_fd()
281281
}
@@ -289,8 +289,26 @@ impl AsRawFd for EventLoop {
289289
///
290290
/// [`calloop`]: https://crates.io/crates/calloop
291291
/// [`mio`]: https://crates.io/crates/mio
292-
/// [`pump_app_events`]: crate::platform::pump_events::EventLoopExtPumpEvents::pump_app_events
292+
/// [`pump_app_events`]: crate::event_loop::pump_events::EventLoopExtPumpEvents::pump_app_events
293293
fn as_raw_fd(&self) -> RawFd {
294294
self.event_loop.as_raw_fd()
295295
}
296296
}
297+
298+
#[cfg(any(
299+
windows_platform,
300+
macos_platform,
301+
android_platform,
302+
x11_platform,
303+
wayland_platform,
304+
docsrs,
305+
))]
306+
impl winit_core::event_loop::pump_events::EventLoopExtPumpEvents for EventLoop {
307+
fn pump_app_events<A: ApplicationHandler>(
308+
&mut self,
309+
timeout: Option<std::time::Duration>,
310+
app: A,
311+
) -> winit_core::event_loop::pump_events::PumpStatus {
312+
self.event_loop.pump_app_events(timeout, app)
313+
}
314+
}

src/lib.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,8 @@
3232
//! Winit no longer uses a `EventLoop::poll_events() -> impl Iterator<Event>`-based event loop
3333
//! model, since that can't be implemented properly on some platforms (e.g Web, iOS) and works
3434
//! poorly on most other platforms. However, this model can be re-implemented to an extent with
35-
#![cfg_attr(
36-
any(windows_platform, macos_platform, android_platform, x11_platform, wayland_platform),
37-
doc = "[`EventLoopExtPumpEvents::pump_app_events()`][platform::pump_events::EventLoopExtPumpEvents::pump_app_events()]"
38-
)]
39-
#![cfg_attr(
40-
not(any(windows_platform, macos_platform, android_platform, x11_platform, wayland_platform)),
41-
doc = "`EventLoopExtPumpEvents::pump_app_events()`"
42-
)]
43-
//! [^1]. See that method's documentation for more reasons about why
44-
//! it's discouraged beyond compatibility reasons.
35+
//! [`EventLoopExtPumpEvents::pump_app_events()`] [^1]. See that method's documentation for more
36+
//! reasons about why it's discouraged beyond compatibility reasons.
4537
//!
4638
//!
4739
//! ```no_run
@@ -276,6 +268,7 @@
276268
//! [`DeviceEvent`]: event::DeviceEvent
277269
//! [`raw_window_handle`]: ./window/struct.Window.html#method.raw_window_handle
278270
//! [`raw_display_handle`]: ./window/struct.Window.html#method.raw_display_handle
271+
//! [`EventLoopExtPumpEvents::pump_app_events()`]: crate::event_loop::pump_events::EventLoopExtPumpEvents::pump_app_events()
279272
//! [^1]: `EventLoopExtPumpEvents::pump_app_events()` is only available on Windows, macOS, Android, X11 and Wayland.
280273
281274
#![deny(rust_2018_idioms)]

src/platform/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,5 @@ pub mod x11;
3232
))]
3333
pub mod run_on_demand;
3434

35-
#[cfg(any(
36-
windows_platform,
37-
macos_platform,
38-
android_platform,
39-
x11_platform,
40-
wayland_platform,
41-
docsrs,
42-
))]
43-
pub mod pump_events;
44-
4535
#[cfg(any(windows_platform, macos_platform, x11_platform, wayland_platform, docsrs))]
4636
pub mod scancode;

src/platform/run_on_demand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::error::EventLoopError;
33
use crate::event_loop::EventLoop;
44
#[cfg(doc)]
55
use crate::{
6-
event_loop::ActiveEventLoop, platform::pump_events::EventLoopExtPumpEvents, window::Window,
6+
event_loop::{pump_events::EventLoopExtPumpEvents, ActiveEventLoop},
7+
window::Window,
78
};
89

910
/// Additional methods on [`EventLoop`] to return control flow to the caller.

src/platform_impl/android/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use android_activity::{
99
AndroidApp, AndroidAppWaker, ConfigurationRef, InputStatus, MainEvent, Rect,
1010
};
1111
use tracing::{debug, trace, warn};
12+
use winit_core::event_loop::pump_events::PumpStatus;
1213

1314
use crate::application::ApplicationHandler;
1415
use crate::cursor::{Cursor, CustomCursor, CustomCursorSource};
@@ -21,7 +22,6 @@ use crate::event_loop::{
2122
OwnedDisplayHandle as CoreOwnedDisplayHandle,
2223
};
2324
use crate::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle};
24-
use crate::platform::pump_events::PumpStatus;
2525
use crate::window::{
2626
self, CursorGrabMode, ImePurpose, ResizeDirection, Theme, Window as CoreWindow,
2727
WindowAttributes, WindowButtons, WindowId, WindowLevel,

src/platform_impl/apple/appkit/event_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use objc2_app_kit::{
1515
};
1616
use objc2_foundation::{NSNotificationCenter, NSObjectProtocol};
1717
use rwh_06::HasDisplayHandle;
18+
use winit_core::event_loop::pump_events::PumpStatus;
1819

1920
use super::super::notification_center::create_observer;
2021
use super::app::override_send_event;
@@ -32,7 +33,6 @@ use crate::event_loop::{
3233
};
3334
use crate::monitor::MonitorHandle as CoreMonitorHandle;
3435
use crate::platform::macos::ActivationPolicy;
35-
use crate::platform::pump_events::PumpStatus;
3636
use crate::platform_impl::Window;
3737
use crate::window::Theme;
3838

src/platform_impl/linux/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ use std::env;
77
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
88
use std::time::Duration;
99

10+
use winit_core::event_loop::pump_events::PumpStatus;
11+
1012
pub(crate) use self::common::xkb::{physicalkey_to_scancode, scancode_to_physicalkey};
1113
use crate::application::ApplicationHandler;
1214
#[cfg(x11_platform)]
1315
use crate::dpi::Size;
1416
use crate::error::{EventLoopError, NotSupportedError};
1517
use crate::event_loop::ActiveEventLoop;
16-
use crate::platform::pump_events::PumpStatus;
1718
#[cfg(x11_platform)]
1819
use crate::platform::x11::WindowType as XWindowType;
1920
use crate::window::ActivationToken;

src/platform_impl/linux/wayland/event_loop/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustix::pipe::{self, PipeFlags};
1616
use sctk::reexports::calloop_wayland_source::WaylandSource;
1717
use sctk::reexports::client::{globals, Connection, QueueHandle};
1818
use tracing::warn;
19+
use winit_core::event_loop::pump_events::PumpStatus;
1920

2021
use crate::application::ApplicationHandler;
2122
use crate::cursor::{CustomCursor as CoreCustomCursor, CustomCursorSource};
@@ -27,7 +28,6 @@ use crate::event_loop::{
2728
OwnedDisplayHandle as CoreOwnedDisplayHandle,
2829
};
2930
use crate::monitor::MonitorHandle as CoreMonitorHandle;
30-
use crate::platform::pump_events::PumpStatus;
3131
use crate::platform_impl::platform::min_timeout;
3232
use crate::platform_impl::wayland::types::cursor::WaylandCustomCursor;
3333
use crate::window::Theme;

0 commit comments

Comments
 (0)