@@ -187,6 +187,7 @@ pub enum Action {
187187 NextFrame ,
188188 PreviousFrame ,
189189 AbRepeat ,
190+ AudioToggle ,
190191 WindowClose ,
191192}
192193
@@ -212,6 +213,7 @@ impl MenuAction for Action {
212213 Self :: NextFrame => Message :: NextFrame ,
213214 Self :: PreviousFrame => Message :: PreviousFrame ,
214215 Self :: AbRepeat => Message :: AbRepeat ,
216+ Self :: AudioToggle => Message :: AudioToggle ,
215217 Self :: WindowClose => Message :: WindowClose ,
216218 }
217219 }
@@ -321,6 +323,7 @@ pub enum Message {
321323 ShowControls ,
322324 SystemThemeModeChange ( cosmic_theme:: ThemeMode ) ,
323325 WindowClose ,
326+ Escape ,
324327}
325328
326329/// The [`App`] stores application-specific state.
@@ -964,11 +967,7 @@ impl Application for App {
964967 }
965968
966969 fn on_escape ( & mut self ) -> Task < Self :: Message > {
967- if self . fullscreen {
968- self . update ( Message :: Fullscreen )
969- } else {
970- Task :: none ( )
971- }
970+ self . update ( Message :: Escape )
972971 }
973972
974973 fn on_nav_select ( & mut self , id : nav_bar:: Id ) -> Task < Message > {
@@ -1216,6 +1215,20 @@ impl Application for App {
12161215 ) ;
12171216 }
12181217 }
1218+ Message :: Escape => {
1219+ if let Some ( window_id) = self . core . main_window_id ( ) {
1220+ if self . fullscreen {
1221+ return self . update ( Message :: Fullscreen ) ;
1222+ } else {
1223+
1224+ if let Some ( video) = & mut self . video_opt {
1225+ video. set_paused ( true ) ;
1226+ }
1227+
1228+ return window:: minimize ( window_id, true ) ;
1229+ }
1230+ }
1231+ }
12191232 Message :: Key ( modifiers, physical, key) => {
12201233 for ( key_bind, action) in self . key_binds . iter ( ) {
12211234 if key_bind. matches ( modifiers, & key, Some ( & physical) ) {
0 commit comments