@@ -21,7 +21,7 @@ use winit::{
21
21
dpi:: PhysicalSize ,
22
22
event:: { DeviceEvent , Event , WindowEvent } ,
23
23
event_loop:: { ControlFlow , EventLoop } ,
24
- window:: WindowBuilder
24
+ window:: WindowBuilder ,
25
25
} ;
26
26
27
27
#[ cfg( feature = "sm-raw-window-handle-05" ) ]
@@ -91,24 +91,27 @@ static BACKGROUND_COLOR: [f32; 4] = [
91
91
] ;
92
92
93
93
#[ cfg( feature = "sm-raw-window-handle-05" ) ]
94
- fn make_connection ( window : & winit:: window:: Window ) -> surfman:: Connection
95
- {
94
+ fn make_connection ( window : & winit:: window:: Window ) -> surfman:: Connection {
96
95
let raw_display_handle = window. raw_display_handle ( ) ;
97
96
let connection = Connection :: from_raw_display_handle ( raw_display_handle) . unwrap ( ) ;
98
97
connection
99
98
}
100
99
101
100
#[ cfg( not( feature = "sm-raw-window-handle-05" ) ) ]
102
- fn make_connection ( window : & winit:: window:: Window ) -> surfman:: Connection
103
- {
104
- let display_handle = window. display_handle ( ) . expect ( "failed to get display handle from window" ) ;
101
+ fn make_connection ( window : & winit:: window:: Window ) -> surfman:: Connection {
102
+ let display_handle = window
103
+ . display_handle ( )
104
+ . expect ( "failed to get display handle from window" ) ;
105
105
let connection = Connection :: from_display_handle ( display_handle) . unwrap ( ) ;
106
106
connection
107
107
}
108
108
109
109
#[ cfg( feature = "sm-raw-window-handle-05" ) ]
110
- fn make_native_widget ( window : & winit:: window:: Window , connection : & surfman:: Connection , window_size : Size2D < i32 > ) -> surfman:: NativeWidget
111
- {
110
+ fn make_native_widget (
111
+ window : & winit:: window:: Window ,
112
+ connection : & surfman:: Connection ,
113
+ window_size : Size2D < i32 > ,
114
+ ) -> surfman:: NativeWidget {
112
115
let raw_window_handle = window. raw_window_handle ( ) ;
113
116
let native_widget = connection
114
117
. create_native_widget_from_raw_window_handle ( raw_window_handle, window_size)
@@ -117,9 +120,14 @@ fn make_native_widget(window: &winit::window::Window, connection: &surfman::Conn
117
120
}
118
121
119
122
#[ cfg( not( feature = "sm-raw-window-handle-05" ) ) ]
120
- fn make_native_widget ( window : & winit:: window:: Window , connection : & surfman:: Connection , window_size : Size2D < i32 > ) -> surfman:: NativeWidget
121
- {
122
- let raw_window_handle = window. window_handle ( ) . expect ( "couldn't get window handle from window" ) ;
123
+ fn make_native_widget (
124
+ window : & winit:: window:: Window ,
125
+ connection : & surfman:: Connection ,
126
+ window_size : Size2D < i32 > ,
127
+ ) -> surfman:: NativeWidget {
128
+ let raw_window_handle = window
129
+ . window_handle ( )
130
+ . expect ( "couldn't get window handle from window" ) ;
123
131
let native_widget = connection
124
132
. create_native_widget_from_window_handle ( raw_window_handle, window_size)
125
133
. unwrap ( ) ;
@@ -128,7 +136,10 @@ fn make_native_widget(window: &winit::window::Window, connection: &surfman::Conn
128
136
129
137
#[ cfg( not( target_os = "android" ) ) ]
130
138
fn main ( ) {
131
- use winit:: { event:: RawKeyEvent , keyboard:: { KeyCode , PhysicalKey } } ;
139
+ use winit:: {
140
+ event:: RawKeyEvent ,
141
+ keyboard:: { KeyCode , PhysicalKey } ,
142
+ } ;
132
143
133
144
let event_loop = EventLoop :: new ( ) . expect ( "couldn't create eventloop" ) ;
134
145
let window_size = Size2D :: new ( WINDOW_WIDTH , WINDOW_HEIGHT ) ;
@@ -177,22 +188,26 @@ fn main() {
177
188
window_size,
178
189
) ;
179
190
180
- event_loop. run ( move |event, target| match event {
181
- Event :: WindowEvent {
182
- event : WindowEvent :: CloseRequested ,
183
- ..
184
- }
185
- | Event :: DeviceEvent {
186
- event :
187
- DeviceEvent :: Key ( RawKeyEvent {
188
- physical_key : PhysicalKey :: Code ( KeyCode :: Escape ) ,
189
- ..
190
- } ) ,
191
- ..
192
- } => target. exit ( ) ,
193
- _ => { app. tick ( true ) ; target. set_control_flow ( ControlFlow :: Poll ) }
194
- } ) . expect ( "failed to run event loop" ) ;
195
-
191
+ event_loop
192
+ . run ( move |event, target| match event {
193
+ Event :: WindowEvent {
194
+ event : WindowEvent :: CloseRequested ,
195
+ ..
196
+ }
197
+ | Event :: DeviceEvent {
198
+ event :
199
+ DeviceEvent :: Key ( RawKeyEvent {
200
+ physical_key : PhysicalKey :: Code ( KeyCode :: Escape ) ,
201
+ ..
202
+ } ) ,
203
+ ..
204
+ } => target. exit ( ) ,
205
+ _ => {
206
+ app. tick ( true ) ;
207
+ target. set_control_flow ( ControlFlow :: Poll )
208
+ }
209
+ } )
210
+ . expect ( "failed to run event loop" ) ;
196
211
}
197
212
pub struct App {
198
213
main_from_worker_receiver : Receiver < Frame > ,
@@ -213,7 +228,6 @@ impl Drop for App {
213
228
}
214
229
215
230
impl App {
216
-
217
231
pub fn new (
218
232
connection : Connection ,
219
233
adapter : Adapter ,
0 commit comments