@@ -4,7 +4,8 @@ use std::num::NonZeroU32;
4
4
use std:: ops:: Deref ;
5
5
6
6
use raw_window_handle:: HasRawWindowHandle ;
7
- use winit:: event:: { Event , WindowEvent } ;
7
+ use winit:: event:: { Event , KeyEvent , WindowEvent } ;
8
+ use winit:: keyboard:: { Key , NamedKey } ;
8
9
use winit:: window:: WindowBuilder ;
9
10
10
11
use glutin:: config:: ConfigTemplateBuilder ;
@@ -28,8 +29,11 @@ pub fn main(event_loop: winit::event_loop::EventLoop<()>) -> Result<(), Box<dyn
28
29
//
29
30
// XXX if you don't care about running on Android or so you can safely remove
30
31
// this condition and always pass the window builder.
31
- let window_builder =
32
- if cfg ! ( wgl_backend) { Some ( WindowBuilder :: new ( ) . with_transparent ( true ) ) } else { None } ;
32
+ let window_builder = cfg ! ( wgl_backend) . then ( || {
33
+ WindowBuilder :: new ( )
34
+ . with_transparent ( true )
35
+ . with_title ( "Glutin triangle gradient example (press Escape to exit)" )
36
+ } ) ;
33
37
34
38
// The template will match only the configurations supporting rendering
35
39
// to windows.
@@ -107,7 +111,9 @@ pub fn main(event_loop: winit::event_loop::EventLoop<()>) -> Result<(), Box<dyn
107
111
println ! ( "Android window available" ) ;
108
112
109
113
let window = window. take ( ) . unwrap_or_else ( || {
110
- let window_builder = WindowBuilder :: new ( ) . with_transparent ( true ) ;
114
+ let window_builder = WindowBuilder :: new ( )
115
+ . with_transparent ( true )
116
+ . with_title ( "Glutin triangle gradient example (press Escape to exit)" ) ;
111
117
glutin_winit:: finalize_window ( window_target, window_builder, & gl_config)
112
118
. unwrap ( )
113
119
} ) ;
@@ -165,7 +171,11 @@ pub fn main(event_loop: winit::event_loop::EventLoop<()>) -> Result<(), Box<dyn
165
171
}
166
172
}
167
173
} ,
168
- WindowEvent :: CloseRequested => window_target. exit ( ) ,
174
+ WindowEvent :: CloseRequested
175
+ | WindowEvent :: KeyboardInput {
176
+ event : KeyEvent { logical_key : Key :: Named ( NamedKey :: Escape ) , .. } ,
177
+ ..
178
+ } => window_target. exit ( ) ,
169
179
_ => ( ) ,
170
180
} ,
171
181
Event :: AboutToWait => {
0 commit comments