Skip to content

Commit

Permalink
Replace EventLoopWindowTarget with ActiveEventLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 24, 2023
1 parent 3b06f64 commit 273a2e0
Show file tree
Hide file tree
Showing 32 changed files with 447 additions and 341 deletions.
4 changes: 2 additions & 2 deletions examples/child_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ fn main() -> Result<(), impl std::error::Error> {
use winit::{
dpi::{LogicalPosition, LogicalSize, Position},
event::{ElementState, Event, KeyEvent, WindowEvent},
event_loop::{EventLoop, EventLoopWindowTarget},
event_loop::{ActiveEventLoop, EventLoop},
raw_window_handle::HasRawWindowHandle,
window::{Window, WindowBuilder, WindowId},
};

fn spawn_child_window(
parent: &Window,
event_loop: &EventLoopWindowTarget,
event_loop: ActiveEventLoop<'_>,
windows: &mut HashMap<WindowId, Window>,
) {
let parent = parent.raw_window_handle().unwrap();
Expand Down
7 changes: 3 additions & 4 deletions examples/custom_cursors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
use simple_logger::SimpleLogger;
use winit::{
event::{ElementState, Event, KeyEvent, WindowEvent},
event_loop::{EventLoop, EventLoopWindowTarget},
event_loop::EventLoop,
keyboard::Key,
window::{CustomCursor, WindowBuilder},
};

fn decode_cursor(bytes: &[u8], window_target: &EventLoopWindowTarget) -> CustomCursor {
fn decode_cursor(bytes: &[u8], event_loop: &EventLoop<()>) -> CustomCursor {
let img = image::load_from_memory(bytes).unwrap().to_rgba8();
let samples = img.into_flat_samples();
let (_, w, h) = samples.extents();
let (w, h) = (w as u16, h as u16);
let builder = CustomCursor::from_rgba(samples.samples, w, h, w / 2, h / 2).unwrap();

builder.build(window_target)
builder.build(event_loop)
}

#[cfg(not(wasm_platform))]
Expand Down
6 changes: 3 additions & 3 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::hash::Hasher;
use std::sync::Arc;
use std::{error::Error, hash::Hash};

use crate::event_loop::EventLoopWindowTarget;
use crate::event_loop::MaybeActiveEventLoop;
use crate::platform_impl::{self, PlatformCustomCursor, PlatformCustomCursorBuilder};

/// The maximum width and height for a cursor when using [`CustomCursor::from_rgba`].
Expand Down Expand Up @@ -87,9 +87,9 @@ pub struct CustomCursorBuilder {
}

impl CustomCursorBuilder {
pub fn build(self, window_target: &EventLoopWindowTarget) -> CustomCursor {
pub fn build<'a>(self, event_loop: impl MaybeActiveEventLoop<'a>) -> CustomCursor {
CustomCursor {
inner: PlatformCustomCursor::build(self.inner, &window_target.p),
inner: PlatformCustomCursor::build(self.inner, event_loop.__inner()),
}
}
}
Expand Down
Loading

0 comments on commit 273a2e0

Please sign in to comment.