mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Fix web
errors (#1040)
* Fix old `use` declarations * Fix hidden lifetime parameter * Fix missing methods in `web::Monitor`. Originally fixed by @ryanisaacg in 94387c4bf5bca35f4e24562ce89a4f4badd53aa8. * Disable some tests and examples on `wasm32`
This commit is contained in:
parent
53e646dabc
commit
7b23d190b1
|
@ -1,16 +1,18 @@
|
||||||
extern crate env_logger;
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use std::{collections::HashMap, sync::mpsc, thread, time::Duration};
|
fn main() {
|
||||||
|
extern crate env_logger;
|
||||||
|
|
||||||
use winit::{
|
use std::{collections::HashMap, sync::mpsc, thread, time::Duration};
|
||||||
|
|
||||||
|
use winit::{
|
||||||
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
|
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
window::{CursorIcon, WindowBuilder},
|
window::{CursorIcon, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
||||||
const WINDOW_COUNT: usize = 3;
|
const WINDOW_COUNT: usize = 3;
|
||||||
const WINDOW_SIZE: (u32, u32) = (600, 400);
|
const WINDOW_SIZE: (u32, u32) = (600, 400);
|
||||||
|
|
||||||
fn main() {
|
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let mut window_senders = HashMap::with_capacity(WINDOW_COUNT);
|
let mut window_senders = HashMap::with_capacity(WINDOW_COUNT);
|
||||||
|
@ -36,7 +38,7 @@ fn main() {
|
||||||
} => {
|
} => {
|
||||||
window.set_title(&format!("{:?}", key));
|
window.set_title(&format!("{:?}", key));
|
||||||
let state = !modifiers.shift;
|
let state = !modifiers.shift;
|
||||||
use self::VirtualKeyCode::*;
|
use VirtualKeyCode::*;
|
||||||
match key {
|
match key {
|
||||||
A => window.set_always_on_top(state),
|
A => window.set_always_on_top(state),
|
||||||
C => window.set_cursor_icon(match state {
|
C => window.set_cursor_icon(match state {
|
||||||
|
@ -125,3 +127,8 @@ fn main() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
fn main() {
|
||||||
|
panic!("Example not supported on Wasm");
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use winit::{
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
fn main() {
|
||||||
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let event_loop: EventLoop<i32> = EventLoop::new_user_event();
|
let event_loop: EventLoop<i32> = EventLoop::new_user_event();
|
||||||
|
|
||||||
let _window = WindowBuilder::new()
|
let _window = WindowBuilder::new()
|
||||||
|
@ -35,3 +36,8 @@ fn main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
fn main() {
|
||||||
|
panic!("Example not supported on Wasm");
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::time::{Duration, Instant};
|
use instant::Instant;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::time::{Duration, Instant};
|
use instant::Instant;
|
||||||
|
use std::time::Duration;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, StartCause, WindowEvent},
|
event::{Event, StartCause, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use winit::{
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
fn main() {
|
||||||
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
platform::desktop::EventLoopExtDesktop,
|
platform::desktop::EventLoopExtDesktop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut event_loop = EventLoop::new();
|
let mut event_loop = EventLoop::new();
|
||||||
|
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
|
@ -39,3 +39,8 @@ fn main() {
|
||||||
|
|
||||||
println!("Okay we're done now for real.");
|
println!("Okay we're done now for real.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
fn main() {
|
||||||
|
panic!("Example not supported on Wasm");
|
||||||
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ use instant::Instant;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::{error, fmt};
|
use std::{error, fmt};
|
||||||
|
|
||||||
use event::Event;
|
use crate::event::Event;
|
||||||
use monitor::{AvailableMonitorsIter, MonitorHandle};
|
use crate::monitor::{AvailableMonitorsIter, MonitorHandle};
|
||||||
use platform_impl;
|
use crate::platform_impl;
|
||||||
|
|
||||||
/// Provides a way to retrieve events from the system and from the windows that were registered to
|
/// Provides a way to retrieve events from the system and from the windows that were registered to
|
||||||
/// the events loop.
|
/// the events loop.
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::fmt;
|
||||||
pub struct OsError(pub String);
|
pub struct OsError(pub String);
|
||||||
|
|
||||||
impl fmt::Display for OsError {
|
impl fmt::Display for OsError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
|
use crate::monitor::VideoMode;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Handle;
|
pub struct Handle;
|
||||||
|
@ -12,11 +13,16 @@ impl Handle {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dimensions(&self) -> PhysicalSize {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(&self) -> Option<String> {
|
pub fn name(&self) -> Option<String> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn size(&self) -> PhysicalSize {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
|
||||||
|
// TODO: is this possible ?
|
||||||
|
std::iter::empty()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn needs_send<T: Send>() {}
|
fn needs_send<T: Send>() {}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn event_loop_proxy_send() {
|
fn event_loop_proxy_send() {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -10,6 +11,7 @@ fn event_loop_proxy_send() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn window_send() {
|
fn window_send() {
|
||||||
// ensures that `winit::Window` implements `Send`
|
// ensures that `winit::Window` implements `Send`
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn needs_sync<T: Sync>() {}
|
fn needs_sync<T: Sync>() {}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn window_sync() {
|
fn window_sync() {
|
||||||
// ensures that `winit::Window` implements `Sync`
|
// ensures that `winit::Window` implements `Sync`
|
||||||
|
|
Loading…
Reference in a new issue