-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some minor doc typo and diagnostic fixes.
- Loading branch information
1 parent
1592b60
commit e7e66c5
Showing
12 changed files
with
398 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/common/application_lifecycle.h" | ||
|
||
#include <cassert> | ||
|
||
namespace flutter { | ||
|
||
const char* AppLifecycleStateToString(AppLifecycleState state) { | ||
switch (state) { | ||
case kAppLifecycleStateDetached: | ||
return "AppLifecycleState.detached"; | ||
case kAppLifecycleStateResumed: | ||
return "AppLifecycleState.resumed"; | ||
case kAppLifecycleStateInactive: | ||
return "AppLifecycleState.inactive"; | ||
case kAppLifecycleStateHidden: | ||
return "AppLifecycleState.hidden"; | ||
case kAppLifecycleStatePaused: | ||
return "AppLifecycleState.paused"; | ||
default: | ||
assert(false && "Lifecycle state not recognized"); | ||
break; | ||
} | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_APPLICATION_LIFECYCLE_H_ | ||
#define FLUTTER_SHELL_PLATFORM_COMMON_APPLICATION_LIFECYCLE_H_ | ||
|
||
namespace flutter { | ||
|
||
/// This enum describes the possible lifecycle states of the application. It | ||
/// must be kept up to date with changes in the framework's AppLifecycleState | ||
/// enum. It is passed to the embedder's |SetLifecycleState| function. | ||
/// | ||
/// |SetLifecycleState| will validate that the state transition is a valid state | ||
/// transition, and will assert if it is not. States not supported on a platform | ||
/// will be emitted when transitioning between states which are supported, so | ||
/// that all implementations share the same allowed state machine. Here is the | ||
/// allowed state machine: | ||
/// | ||
/// +-----------+ +-----------+ | ||
/// | detached |------------------------------>| resumed | | ||
/// +-----------+ +-----------+ | ||
/// ^ ^ | ||
/// | | | ||
/// | v | ||
/// +-----------+ +--------------+ +-----------+ | ||
/// | paused |<------>| hidden |<----->| inactive | | ||
/// +-----------+ +--------------+ +-----------+ | ||
/// | ||
/// The states and their meanings are as follows: | ||
/// | ||
/// detached: The initial state of the state machine. On Android and iOS, | ||
/// also the final state of the state machine when all views are | ||
/// detached. Other platforms do not enter this state again after | ||
/// initially leaving it. | ||
/// | ||
/// resumed: The nominal "running" state of the application. The | ||
/// application is visible, has input focus, and is running. | ||
/// | ||
/// inactive: At least one view of the application is visible, but none | ||
/// have input focus. The application is otherwise running | ||
/// normally. | ||
/// | ||
/// hidden: All views of an application are hidden, either because the | ||
/// application is being stopped (on iOS and Android), or because | ||
/// it is being minimized or on a desktop that is no longer visible | ||
/// (on desktop), or on a tab that is no longer visible (on web). | ||
/// | ||
/// paused: The application is not running, and can be detached or started | ||
/// again at any time. This state is typically only entered into on | ||
/// iOS and Android. | ||
typedef enum { | ||
kAppLifecycleStateDetached = 0x0, | ||
kAppLifecycleStateResumed = 0x1, | ||
kAppLifecycleStateInactive = 0x2, | ||
kAppLifecycleStateHidden = 0x3, | ||
kAppLifecycleStatePaused = 0x4, | ||
} AppLifecycleState; | ||
|
||
const char* AppLifecycleStateToString(AppLifecycleState state); | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_COMMON_APPLICATION_LIFECYCLE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
shell/platform/darwin/macos/framework/Headers/FlutterAppLifecycleDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_FLUTTERAPPLIFECYCLEDELEGATE_H_ | ||
#define FLUTTER_FLUTTERAPPLIFECYCLEDELEGATE_H_ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#include <Foundation/Foundation.h> | ||
|
||
#import "FlutterMacros.h" | ||
#import "FlutterPluginMacOS.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
#pragma mark - | ||
/** | ||
* Protocol for listener of events from the NSApplication, typically a | ||
* FlutterPlugin. | ||
*/ | ||
@protocol FlutterAppLifecycleDelegate <NSObject> | ||
|
||
@optional | ||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillFinishLaunching | ||
* notification. | ||
*/ | ||
- (void)handleWillFinishLaunching:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationDidFinishLaunching | ||
* notification. | ||
*/ | ||
- (void)handleDidFinishLaunching:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillBecomeActive | ||
* notification. | ||
*/ | ||
- (void)handleWillBecomeActive:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationDidBecomeActive | ||
* notification. | ||
*/ | ||
- (void)handleDidBecomeActive:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillResignActive | ||
* notification. | ||
*/ | ||
- (void)handleWillResignActive:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillResignActive | ||
* notification. | ||
*/ | ||
- (void)handleDidResignActive:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillHide | ||
* notification. | ||
*/ | ||
- (void)handleWillHide:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationDidHide | ||
* notification. | ||
*/ | ||
- (void)handleDidHide:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillUnhide | ||
* notification. | ||
*/ | ||
- (void)handleWillUnhide:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationDidUnhide | ||
* notification. | ||
*/ | ||
- (void)handleDidUnhide:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationDidUnhide | ||
* notification. | ||
*/ | ||
- (void)handleDidChangeScreenParameters:(NSNotification*)notification; | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationDidUnhide | ||
* notification. | ||
*/ | ||
- (void)handleDidChangeOcclusionState:(NSNotification*)notification API_AVAILABLE(macos(10.9)); | ||
|
||
/** | ||
* Called when the |FlutterAppDelegate| gets the applicationWillTerminate | ||
* notification. | ||
*/ | ||
- (void)handleWillTerminate:(NSNotification*)notification; | ||
@end | ||
|
||
#pragma mark - | ||
|
||
/** | ||
* Propagates `NSAppDelegate` callbacks to registered plugins. | ||
*/ | ||
FLUTTER_DARWIN_EXPORT | ||
@interface FlutterAppLifecycleRegistrar : NSObject <FlutterAppLifecycleDelegate> | ||
|
||
/** | ||
* Registers `delegate` to receive life cycle callbacks via this FlutterAppLifecycleDelegate | ||
* as long as it is alive. | ||
* | ||
* `delegate` will only be referenced weakly. | ||
*/ | ||
- (void)addDelegate:(NSObject<FlutterAppLifecycleDelegate>*)delegate; | ||
|
||
/** | ||
* Unregisters `delegate` so that it will no longer receive life cycle callbacks | ||
* via this FlutterAppLifecycleDelegate. | ||
*/ | ||
- (void)removeDelegate:(NSObject<FlutterAppLifecycleDelegate>*)delegate; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif // FLUTTER_FLUTTERAPPLIFECYCLEDELEGATE_H_ |
Oops, something went wrong.