Skip to content

Commit a195ce8

Browse files
authored
Re-format on stable rustfmt (rust-windowing#974)
1 parent 9dd15d0 commit a195ce8

39 files changed

+585
-711
lines changed

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ matrix:
4545
install:
4646
- rustup self update
4747
- rustup target add $TARGET; true
48-
- rustup install nightly
49-
- rustup component add rustfmt --toolchain nightly
48+
- rustup component add rustfmt
5049

5150
script:
52-
- cargo +nightly fmt --all -- --check
51+
- cargo fmt --all -- --check
5352
- cargo build --target $TARGET --verbose
5453
- cargo build --target $TARGET --features serde --verbose
5554
# Running iOS apps on OSX requires the simulator so we skip that for now

examples/cursor.rs

+28-30
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,35 @@ fn main() {
1212

1313
let mut cursor_idx = 0;
1414

15-
event_loop.run(move |event, _, control_flow| {
16-
match event {
17-
Event::WindowEvent {
18-
event:
19-
WindowEvent::KeyboardInput {
20-
input:
21-
KeyboardInput {
22-
state: ElementState::Pressed,
23-
..
24-
},
25-
..
26-
},
27-
..
28-
} => {
29-
println!("Setting cursor to \"{:?}\"", CURSORS[cursor_idx]);
30-
window.set_cursor_icon(CURSORS[cursor_idx]);
31-
if cursor_idx < CURSORS.len() - 1 {
32-
cursor_idx += 1;
33-
} else {
34-
cursor_idx = 0;
35-
}
36-
},
37-
Event::WindowEvent {
38-
event: WindowEvent::CloseRequested,
39-
..
40-
} => {
41-
*control_flow = ControlFlow::Exit;
42-
return;
43-
},
44-
_ => (),
15+
event_loop.run(move |event, _, control_flow| match event {
16+
Event::WindowEvent {
17+
event:
18+
WindowEvent::KeyboardInput {
19+
input:
20+
KeyboardInput {
21+
state: ElementState::Pressed,
22+
..
23+
},
24+
..
25+
},
26+
..
27+
} => {
28+
println!("Setting cursor to \"{:?}\"", CURSORS[cursor_idx]);
29+
window.set_cursor_icon(CURSORS[cursor_idx]);
30+
if cursor_idx < CURSORS.len() - 1 {
31+
cursor_idx += 1;
32+
} else {
33+
cursor_idx = 0;
34+
}
4535
}
36+
Event::WindowEvent {
37+
event: WindowEvent::CloseRequested,
38+
..
39+
} => {
40+
*control_flow = ControlFlow::Exit;
41+
return;
42+
}
43+
_ => (),
4644
});
4745
}
4846

examples/cursor_grab.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
H => window.set_cursor_visible(modifiers.shift),
3535
_ => (),
3636
}
37-
},
37+
}
3838
_ => (),
3939
}
4040
}

examples/fullscreen.rs

+52-59
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
let num = num.trim().parse().ok().expect("Please enter a number");
2525
match num {
2626
2 => macos_use_simple_fullscreen = true,
27-
_ => {},
27+
_ => {}
2828
}
2929

3030
// Prompt for monitor when using native fullscreen
@@ -54,69 +54,62 @@ fn main() {
5454
*control_flow = ControlFlow::Wait;
5555

5656
match event {
57-
Event::WindowEvent { event, .. } => {
58-
match event {
59-
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
60-
WindowEvent::KeyboardInput {
61-
input:
62-
KeyboardInput {
63-
virtual_keycode: Some(virtual_code),
64-
state,
65-
..
66-
},
67-
..
68-
} => {
69-
match (virtual_code, state) {
70-
(VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit,
71-
(VirtualKeyCode::F, ElementState::Pressed) => {
72-
#[cfg(target_os = "macos")]
73-
{
74-
if macos_use_simple_fullscreen {
75-
use winit::platform::macos::WindowExtMacOS;
76-
if WindowExtMacOS::set_simple_fullscreen(
77-
&window,
78-
!is_fullscreen,
79-
) {
80-
is_fullscreen = !is_fullscreen;
81-
}
82-
return;
83-
}
57+
Event::WindowEvent { event, .. } => match event {
58+
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
59+
WindowEvent::KeyboardInput {
60+
input:
61+
KeyboardInput {
62+
virtual_keycode: Some(virtual_code),
63+
state,
64+
..
65+
},
66+
..
67+
} => match (virtual_code, state) {
68+
(VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit,
69+
(VirtualKeyCode::F, ElementState::Pressed) => {
70+
#[cfg(target_os = "macos")]
71+
{
72+
if macos_use_simple_fullscreen {
73+
use winit::platform::macos::WindowExtMacOS;
74+
if WindowExtMacOS::set_simple_fullscreen(&window, !is_fullscreen) {
75+
is_fullscreen = !is_fullscreen;
8476
}
77+
return;
78+
}
79+
}
8580

86-
is_fullscreen = !is_fullscreen;
87-
if !is_fullscreen {
88-
window.set_fullscreen(None);
89-
} else {
90-
window.set_fullscreen(Some(window.current_monitor()));
91-
}
92-
},
93-
(VirtualKeyCode::S, ElementState::Pressed) => {
94-
println!("window.fullscreen {:?}", window.fullscreen());
95-
96-
#[cfg(target_os = "macos")]
97-
{
98-
use winit::platform::macos::WindowExtMacOS;
99-
println!(
100-
"window.simple_fullscreen {:?}",
101-
WindowExtMacOS::simple_fullscreen(&window)
102-
);
103-
}
104-
},
105-
(VirtualKeyCode::M, ElementState::Pressed) => {
106-
is_maximized = !is_maximized;
107-
window.set_maximized(is_maximized);
108-
},
109-
(VirtualKeyCode::D, ElementState::Pressed) => {
110-
decorations = !decorations;
111-
window.set_decorations(decorations);
112-
},
113-
_ => (),
81+
is_fullscreen = !is_fullscreen;
82+
if !is_fullscreen {
83+
window.set_fullscreen(None);
84+
} else {
85+
window.set_fullscreen(Some(window.current_monitor()));
86+
}
87+
}
88+
(VirtualKeyCode::S, ElementState::Pressed) => {
89+
println!("window.fullscreen {:?}", window.fullscreen());
90+
91+
#[cfg(target_os = "macos")]
92+
{
93+
use winit::platform::macos::WindowExtMacOS;
94+
println!(
95+
"window.simple_fullscreen {:?}",
96+
WindowExtMacOS::simple_fullscreen(&window)
97+
);
11498
}
115-
},
99+
}
100+
(VirtualKeyCode::M, ElementState::Pressed) => {
101+
is_maximized = !is_maximized;
102+
window.set_maximized(is_maximized);
103+
}
104+
(VirtualKeyCode::D, ElementState::Pressed) => {
105+
decorations = !decorations;
106+
window.set_decorations(decorations);
107+
}
116108
_ => (),
117-
}
109+
},
110+
_ => (),
118111
},
119-
_ => {},
112+
_ => {}
120113
}
121114
});
122115
}

examples/handling_close.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn main() {
4040
// action from the user, this is generally where you'd handle cleanup before
4141
// closing the window. How to close the window is detailed in the handler for
4242
// the Y key.
43-
},
43+
}
4444
WindowEvent::KeyboardInput {
4545
input:
4646
KeyboardInput {
@@ -63,19 +63,19 @@ fn main() {
6363
// sent.
6464
*control_flow = ControlFlow::Exit;
6565
}
66-
},
66+
}
6767
N => {
6868
if close_requested {
6969
println!("Your window will continue to stay by your side.");
7070
close_requested = false;
7171
}
72-
},
72+
}
7373
_ => (),
7474
}
75-
},
75+
}
7676
_ => (),
7777
}
78-
},
78+
}
7979
_ => (),
8080
}
8181
});

examples/multithreaded.rs

+50-64
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,15 @@ fn main() {
3939
use self::VirtualKeyCode::*;
4040
match key {
4141
A => window.set_always_on_top(state),
42-
C => {
43-
window.set_cursor_icon(match state {
44-
true => CursorIcon::Progress,
45-
false => CursorIcon::Default,
46-
})
47-
},
42+
C => window.set_cursor_icon(match state {
43+
true => CursorIcon::Progress,
44+
false => CursorIcon::Default,
45+
}),
4846
D => window.set_decorations(!state),
49-
F => {
50-
window.set_fullscreen(match state {
51-
true => Some(window.current_monitor()),
52-
false => None,
53-
})
54-
},
47+
F => window.set_fullscreen(match state {
48+
true => Some(window.current_monitor()),
49+
false => None,
50+
}),
5551
G => window.set_cursor_grab(state).unwrap(),
5652
H => window.set_cursor_visible(!state),
5753
I => {
@@ -60,49 +56,41 @@ fn main() {
6056
println!("-> inner_position : {:?}", window.inner_position());
6157
println!("-> outer_size : {:?}", window.outer_size());
6258
println!("-> inner_size : {:?}", window.inner_size());
63-
},
64-
L => {
65-
window.set_min_inner_size(match state {
66-
true => Some(WINDOW_SIZE.into()),
67-
false => None,
68-
})
69-
},
59+
}
60+
L => window.set_min_inner_size(match state {
61+
true => Some(WINDOW_SIZE.into()),
62+
false => None,
63+
}),
7064
M => window.set_maximized(state),
71-
P => {
72-
window.set_outer_position({
73-
let mut position = window.outer_position().unwrap();
74-
let sign = if state { 1.0 } else { -1.0 };
75-
position.x += 10.0 * sign;
76-
position.y += 10.0 * sign;
77-
position
78-
})
79-
},
65+
P => window.set_outer_position({
66+
let mut position = window.outer_position().unwrap();
67+
let sign = if state { 1.0 } else { -1.0 };
68+
position.x += 10.0 * sign;
69+
position.y += 10.0 * sign;
70+
position
71+
}),
8072
Q => window.request_redraw(),
8173
R => window.set_resizable(state),
82-
S => {
83-
window.set_inner_size(
84-
match state {
85-
true => (WINDOW_SIZE.0 + 100, WINDOW_SIZE.1 + 100),
86-
false => WINDOW_SIZE,
87-
}
88-
.into(),
74+
S => window.set_inner_size(
75+
match state {
76+
true => (WINDOW_SIZE.0 + 100, WINDOW_SIZE.1 + 100),
77+
false => WINDOW_SIZE,
78+
}
79+
.into(),
80+
),
81+
W => window
82+
.set_cursor_position(
83+
(WINDOW_SIZE.0 as i32 / 2, WINDOW_SIZE.1 as i32 / 2).into(),
8984
)
90-
},
91-
W => {
92-
window
93-
.set_cursor_position(
94-
(WINDOW_SIZE.0 as i32 / 2, WINDOW_SIZE.1 as i32 / 2).into(),
95-
)
96-
.unwrap()
97-
},
85+
.unwrap(),
9886
Z => {
9987
window.set_visible(false);
10088
thread::sleep(Duration::from_secs(1));
10189
window.set_visible(true);
102-
},
90+
}
10391
_ => (),
10492
}
105-
},
93+
}
10694
_ => (),
10795
}
10896
}
@@ -114,25 +102,23 @@ fn main() {
114102
false => ControlFlow::Exit,
115103
};
116104
match event {
117-
Event::WindowEvent { event, window_id } => {
118-
match event {
119-
WindowEvent::CloseRequested
120-
| WindowEvent::Destroyed
121-
| WindowEvent::KeyboardInput {
122-
input:
123-
KeyboardInput {
124-
virtual_keycode: Some(VirtualKeyCode::Escape),
125-
..
126-
},
127-
..
128-
} => {
129-
window_senders.remove(&window_id);
130-
},
131-
_ => {
132-
if let Some(tx) = window_senders.get(&window_id) {
133-
tx.send(event).unwrap();
134-
}
135-
},
105+
Event::WindowEvent { event, window_id } => match event {
106+
WindowEvent::CloseRequested
107+
| WindowEvent::Destroyed
108+
| WindowEvent::KeyboardInput {
109+
input:
110+
KeyboardInput {
111+
virtual_keycode: Some(VirtualKeyCode::Escape),
112+
..
113+
},
114+
..
115+
} => {
116+
window_senders.remove(&window_id);
117+
}
118+
_ => {
119+
if let Some(tx) = window_senders.get(&window_id) {
120+
tx.send(event).unwrap();
121+
}
136122
}
137123
},
138124
_ => (),

0 commit comments

Comments
 (0)