Update examples to winit 0.29
This commit is contained in:
parent
d6224e1b03
commit
555678e6ed
4 changed files with 56 additions and 50 deletions
|
|
@ -27,7 +27,7 @@ clipboard_wayland = { version = "0.2", path = "./wayland" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
winit = "0.28"
|
winit = { version = "0.29", features = ["rwh_05"] }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
use rand::distributions::{Alphanumeric, Distribution};
|
use rand::distributions::{Alphanumeric, Distribution};
|
||||||
use window_clipboard::Clipboard;
|
use window_clipboard::Clipboard;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
|
keyboard::Key,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -15,7 +16,7 @@ fn main() {
|
||||||
.map(char::from)
|
.map(char::from)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new().unwrap();
|
||||||
|
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_title("Press G to start the test!")
|
.with_title("Press G to start the test!")
|
||||||
|
|
@ -27,28 +28,30 @@ fn main() {
|
||||||
|
|
||||||
clipboard.write(data.clone()).unwrap();
|
clipboard.write(data.clone()).unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| match event {
|
event_loop
|
||||||
Event::WindowEvent {
|
.run(move |event, elwt| match event {
|
||||||
event:
|
Event::WindowEvent {
|
||||||
WindowEvent::KeyboardInput {
|
event:
|
||||||
input:
|
WindowEvent::KeyboardInput {
|
||||||
KeyboardInput {
|
event:
|
||||||
virtual_keycode: Some(VirtualKeyCode::G),
|
KeyEvent {
|
||||||
state: ElementState::Released,
|
logical_key: Key::Character(c),
|
||||||
..
|
state: ElementState::Released,
|
||||||
},
|
..
|
||||||
..
|
},
|
||||||
},
|
..
|
||||||
..
|
},
|
||||||
} => {
|
..
|
||||||
let new_data = clipboard.read().expect("Read data");
|
} if c == "G" => {
|
||||||
assert_eq!(data, new_data, "Data is equal");
|
let new_data = clipboard.read().expect("Read data");
|
||||||
println!("Data copied successfully!");
|
assert_eq!(data, new_data, "Data is equal");
|
||||||
}
|
println!("Data copied successfully!");
|
||||||
Event::WindowEvent {
|
}
|
||||||
event: WindowEvent::CloseRequested,
|
Event::WindowEvent {
|
||||||
window_id,
|
event: WindowEvent::CloseRequested,
|
||||||
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
window_id,
|
||||||
_ => *control_flow = ControlFlow::Wait,
|
} if window_id == window.id() => elwt.exit(),
|
||||||
});
|
_ => {}
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use window_clipboard::Clipboard;
|
use window_clipboard::Clipboard;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new().unwrap();
|
||||||
|
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_title("A fantastic window!")
|
.with_title("A fantastic window!")
|
||||||
|
|
@ -15,14 +15,16 @@ fn main() {
|
||||||
|
|
||||||
let clipboard = Clipboard::connect(&window).expect("Connect to clipboard");
|
let clipboard = Clipboard::connect(&window).expect("Connect to clipboard");
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| match event {
|
event_loop
|
||||||
Event::MainEventsCleared => {
|
.run(move |event, elwt| match event {
|
||||||
println!("{:?}", clipboard.read());
|
Event::AboutToWait => {
|
||||||
}
|
println!("{:?}", clipboard.read());
|
||||||
Event::WindowEvent {
|
}
|
||||||
event: WindowEvent::CloseRequested,
|
Event::WindowEvent {
|
||||||
window_id,
|
event: WindowEvent::CloseRequested,
|
||||||
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
window_id,
|
||||||
_ => *control_flow = ControlFlow::Wait,
|
} if window_id == window.id() => elwt.exit(),
|
||||||
});
|
_ => {}
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use window_clipboard::Clipboard;
|
use window_clipboard::Clipboard;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new().unwrap();
|
||||||
|
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_title("A fantastic window!")
|
.with_title("A fantastic window!")
|
||||||
|
|
@ -20,12 +20,13 @@ fn main() {
|
||||||
.write(String::from("Hello, world!"))
|
.write(String::from("Hello, world!"))
|
||||||
.expect("Write to clipboard");
|
.expect("Write to clipboard");
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| match event {
|
event_loop
|
||||||
Event::MainEventsCleared => {}
|
.run(move |event, elwt| match event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
window_id,
|
window_id,
|
||||||
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
} if window_id == window.id() => elwt.exit(),
|
||||||
_ => *control_flow = ControlFlow::Wait,
|
_ => {}
|
||||||
});
|
})
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue