@@ -351,46 +351,61 @@ impl AndroidAppInner {
351351 let cmd = match cmd_i as ffi:: NativeAppGlueAppCmd {
352352 //NativeAppGlueAppCmd_UNUSED_APP_CMD_INPUT_CHANGED => AndroidAppMainEvent::InputChanged,
353353 ffi:: NativeAppGlueAppCmd_APP_CMD_INIT_WINDOW => {
354- MainEvent :: InitWindow { }
354+ Some ( MainEvent :: InitWindow { } )
355355 }
356356 ffi:: NativeAppGlueAppCmd_APP_CMD_TERM_WINDOW => {
357- MainEvent :: TerminateWindow { }
357+ Some ( MainEvent :: TerminateWindow { } )
358358 }
359359 ffi:: NativeAppGlueAppCmd_APP_CMD_WINDOW_RESIZED => {
360- MainEvent :: WindowResized { }
360+ Some ( MainEvent :: WindowResized { } )
361361 }
362362 ffi:: NativeAppGlueAppCmd_APP_CMD_WINDOW_REDRAW_NEEDED => {
363- MainEvent :: RedrawNeeded { }
363+ Some ( MainEvent :: RedrawNeeded { } )
364364 }
365365 ffi:: NativeAppGlueAppCmd_APP_CMD_CONTENT_RECT_CHANGED => {
366- MainEvent :: ContentRectChanged { }
366+ Some ( MainEvent :: ContentRectChanged { } )
367367 }
368368 ffi:: NativeAppGlueAppCmd_APP_CMD_GAINED_FOCUS => {
369- MainEvent :: GainedFocus
369+ Some ( MainEvent :: GainedFocus )
370370 }
371371 ffi:: NativeAppGlueAppCmd_APP_CMD_LOST_FOCUS => {
372- MainEvent :: LostFocus
372+ Some ( MainEvent :: LostFocus )
373373 }
374374 ffi:: NativeAppGlueAppCmd_APP_CMD_CONFIG_CHANGED => {
375- MainEvent :: ConfigChanged { }
375+ Some ( MainEvent :: ConfigChanged { } )
376376 }
377377 ffi:: NativeAppGlueAppCmd_APP_CMD_LOW_MEMORY => {
378- MainEvent :: LowMemory
378+ Some ( MainEvent :: LowMemory )
379+ }
380+ ffi:: NativeAppGlueAppCmd_APP_CMD_START => {
381+ Some ( MainEvent :: Start )
382+ }
383+ ffi:: NativeAppGlueAppCmd_APP_CMD_RESUME => {
384+ Some ( MainEvent :: Resume {
385+ loader : StateLoader { app : self } ,
386+ } )
379387 }
380- ffi:: NativeAppGlueAppCmd_APP_CMD_START => MainEvent :: Start ,
381- ffi:: NativeAppGlueAppCmd_APP_CMD_RESUME => MainEvent :: Resume {
382- loader : StateLoader { app : self } ,
383- } ,
384388 ffi:: NativeAppGlueAppCmd_APP_CMD_SAVE_STATE => {
385- MainEvent :: SaveState {
389+ Some ( MainEvent :: SaveState {
386390 saver : StateSaver { app : self } ,
387- }
391+ } )
392+ }
393+ ffi:: NativeAppGlueAppCmd_APP_CMD_PAUSE => {
394+ Some ( MainEvent :: Pause )
395+ }
396+ ffi:: NativeAppGlueAppCmd_APP_CMD_STOP => Some ( MainEvent :: Stop ) ,
397+ ffi:: NativeAppGlueAppCmd_APP_CMD_DESTROY => {
398+ Some ( MainEvent :: Destroy )
388399 }
389- ffi:: NativeAppGlueAppCmd_APP_CMD_PAUSE => MainEvent :: Pause ,
390- ffi:: NativeAppGlueAppCmd_APP_CMD_STOP => MainEvent :: Stop ,
391- ffi:: NativeAppGlueAppCmd_APP_CMD_DESTROY => MainEvent :: Destroy ,
392400 ffi:: NativeAppGlueAppCmd_APP_CMD_WINDOW_INSETS_CHANGED => {
393- MainEvent :: InsetsChanged { }
401+ Some ( MainEvent :: InsetsChanged { } )
402+ }
403+ ffi:: NativeAppGlueAppCmd_APP_CMD_SOFTWARE_KB_VIS_CHANGED => {
404+ // NOOP: we ignore these events because they are driven by a
405+ // potentially-unreliable heuristic (based on watching for
406+ // inset changes) and we don't currently have a public event
407+ // for exposing this state.
408+ None
394409 }
395410 _ => unreachable ! ( ) ,
396411 } ;
@@ -399,30 +414,35 @@ impl AndroidAppInner {
399414
400415 trace ! ( "Calling android_app_pre_exec_cmd({cmd_i})" ) ;
401416 ffi:: android_app_pre_exec_cmd ( native_app. as_ptr ( ) , cmd_i) ;
402- match cmd {
403- MainEvent :: ConfigChanged { .. } => {
404- self . config . replace ( Configuration :: clone_from_ptr (
405- NonNull :: new_unchecked ( ( * native_app. as_ptr ( ) ) . config ) ,
406- ) ) ;
407- }
408- MainEvent :: InitWindow { .. } => {
409- let win_ptr = ( * native_app. as_ptr ( ) ) . window ;
410- // It's important that we use ::clone_from_ptr() here
411- // because NativeWindow has a Drop implementation that
412- // will unconditionally _release() the native window
413- * self . native_window . write ( ) . unwrap ( ) =
414- Some ( NativeWindow :: clone_from_ptr (
415- NonNull :: new ( win_ptr) . unwrap ( ) ,
417+
418+ if let Some ( cmd) = cmd {
419+ match cmd {
420+ MainEvent :: ConfigChanged { .. } => {
421+ self . config . replace ( Configuration :: clone_from_ptr (
422+ NonNull :: new_unchecked (
423+ ( * native_app. as_ptr ( ) ) . config ,
424+ ) ,
416425 ) ) ;
426+ }
427+ MainEvent :: InitWindow { .. } => {
428+ let win_ptr = ( * native_app. as_ptr ( ) ) . window ;
429+ // It's important that we use ::clone_from_ptr() here
430+ // because NativeWindow has a Drop implementation that
431+ // will unconditionally _release() the native window
432+ * self . native_window . write ( ) . unwrap ( ) =
433+ Some ( NativeWindow :: clone_from_ptr (
434+ NonNull :: new ( win_ptr) . unwrap ( ) ,
435+ ) ) ;
436+ }
437+ MainEvent :: TerminateWindow { .. } => {
438+ * self . native_window . write ( ) . unwrap ( ) = None ;
439+ }
440+ _ => { }
417441 }
418- MainEvent :: TerminateWindow { .. } => {
419- * self . native_window . write ( ) . unwrap ( ) = None ;
420- }
421- _ => { }
422- }
423442
424- trace ! ( "Invoking callback for ID_MAIN command = {:?}" , cmd) ;
425- callback ( PollEvent :: Main ( cmd) ) ;
443+ trace ! ( "Invoking callback for ID_MAIN command = {:?}" , cmd) ;
444+ callback ( PollEvent :: Main ( cmd) ) ;
445+ }
426446
427447 trace ! ( "Calling android_app_post_exec_cmd({cmd_i})" ) ;
428448 ffi:: android_app_post_exec_cmd ( native_app. as_ptr ( ) , cmd_i) ;
0 commit comments