[DEV] correct start and stop application for IOS
This commit is contained in:
parent
a0f6e268af
commit
54cd4828df
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
||||
Subproject commit c6fe3295f449ddb300cb26c51482b89626fbff7c
|
||||
Subproject commit 6a3d2d129e5097a1060b05ec0a266b951c32cecb
|
@ -674,24 +674,67 @@ void ewol::Context::setWindows(ewol::widget::Windows* _windows) {
|
||||
}
|
||||
|
||||
void ewol::Context::forceRedrawAll(void) {
|
||||
if (NULL != m_windowsCurrent) {
|
||||
m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y()));
|
||||
if (m_windowsCurrent == NULL) {
|
||||
return;
|
||||
}
|
||||
m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y()));
|
||||
}
|
||||
|
||||
void ewol::Context::OS_Stop(void) {
|
||||
if (NULL != m_windowsCurrent) {
|
||||
// set the curent interface :
|
||||
lockContext();
|
||||
EWOL_INFO("OS_Stop...");
|
||||
if (m_windowsCurrent != NULL) {
|
||||
m_windowsCurrent->sysOnKill();
|
||||
}
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
}
|
||||
|
||||
void ewol::Context::OS_Suspend(void) {
|
||||
// set the curent interface :
|
||||
lockContext();
|
||||
EWOL_INFO("OS_Suspend...");
|
||||
m_previousDisplayTime = -1;
|
||||
if (m_windowsCurrent != NULL) {
|
||||
m_windowsCurrent->onStateSuspend();
|
||||
}
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
}
|
||||
|
||||
void ewol::Context::OS_Resume(void) {
|
||||
// set the curent interface :
|
||||
lockContext();
|
||||
EWOL_INFO("OS_Resume...");
|
||||
m_previousDisplayTime = ewol::getTime();
|
||||
m_widgetManager.periodicCallResume(m_previousDisplayTime);
|
||||
if (m_windowsCurrent != NULL) {
|
||||
m_windowsCurrent->onStateResume();
|
||||
}
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
}
|
||||
void ewol::Context::OS_Foreground(void) {
|
||||
// set the curent interface :
|
||||
lockContext();
|
||||
EWOL_INFO("OS_Foreground...");
|
||||
if (m_windowsCurrent != NULL) {
|
||||
m_windowsCurrent->onStateForeground();
|
||||
}
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
}
|
||||
|
||||
void ewol::Context::OS_Background(void) {
|
||||
// set the curent interface :
|
||||
lockContext();
|
||||
EWOL_INFO("OS_Background...");
|
||||
if (m_windowsCurrent != NULL) {
|
||||
m_windowsCurrent->onStateBackground();
|
||||
}
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,6 +122,15 @@ namespace ewol {
|
||||
*/
|
||||
virtual void OS_Resume(void);
|
||||
|
||||
/**
|
||||
* @brief The current context is set in foreground (framerate is maximum speed)
|
||||
*/
|
||||
virtual void OS_Foreground(void);
|
||||
/**
|
||||
* @brief The current context is set in background (framerate is slowing down (max fps)/5 # 4fps)
|
||||
*/
|
||||
virtual void OS_Background(void);
|
||||
|
||||
void requestUpdateSize(void);
|
||||
|
||||
// return true if a flush is needed
|
||||
|
@ -37,6 +37,7 @@
|
||||
NSLog(@"CREATE EWOL interface creation\n");
|
||||
IOs::createInterface();
|
||||
IOs::resize(currentSize.width, currentSize.height);
|
||||
IOs::start();
|
||||
}
|
||||
/*
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
@ -50,28 +51,37 @@
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
EWOL_INFO("move windows in applicationWillResignActive");
|
||||
[glView speedSlow];
|
||||
IOs::background();
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
EWOL_INFO("move windows in applicationDidEnterBackground");
|
||||
[glView stopDisplayLink];
|
||||
IOs::suspend();
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
EWOL_INFO("move windows in applicationWillEnterForeground");
|
||||
IOs::resume();
|
||||
[glView startDisplayLink];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
EWOL_INFO("move windows in applicationDidBecomeActive");
|
||||
[glView speedNormal];
|
||||
IOs::foreground();
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
// Create interface of ewol here ....
|
||||
EWOL_INFO("move windows in applicationWillTerminate");
|
||||
IOs::stop();
|
||||
IOs::releaseInterface();
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,47 @@ void IOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::key
|
||||
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown);
|
||||
}
|
||||
|
||||
void IOs::start(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
//interface->OS_Start();
|
||||
}
|
||||
|
||||
void IOs::resume(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->OS_Resume();
|
||||
}
|
||||
|
||||
void IOs::suspend(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->OS_Suspend();
|
||||
}
|
||||
|
||||
void IOs::stop(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->OS_Stop();
|
||||
}
|
||||
void IOs::background(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->OS_Background();
|
||||
}
|
||||
void IOs::foreground(void) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->OS_Foreground();
|
||||
}
|
||||
|
||||
|
||||
static int l_argc = 0;
|
||||
static const char **l_argv = NULL;
|
||||
/**
|
||||
|
@ -28,6 +28,12 @@ namespace IOs {
|
||||
void setInputMotion(int32_t _id, float _x, float _y);
|
||||
void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
|
||||
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown);
|
||||
void start(void);
|
||||
void stop(void);
|
||||
void foreground(void);
|
||||
void background(void);
|
||||
void resume(void);
|
||||
void suspend(void);
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,6 +31,12 @@
|
||||
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
||||
GLuint depthRenderbuffer;
|
||||
CGSize m_currentSize;
|
||||
CADisplayLink* displayLink; //!< link to start and stop display of the view...
|
||||
int deltaDisplay;
|
||||
int displayCounter;
|
||||
}
|
||||
|
||||
- (void)stopDisplayLink;
|
||||
- (void)startDisplayLink;
|
||||
- (void)speedSlow;
|
||||
- (void)speedNormal;
|
||||
@end
|
||||
|
@ -185,16 +185,41 @@
|
||||
}
|
||||
|
||||
- (void)render:(CADisplayLink*)displayLink {
|
||||
displayCounter++;
|
||||
if (displayCounter >= deltaDisplay) {
|
||||
displayCounter = 0;
|
||||
IOs::draw(true);
|
||||
[_context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setupDisplayLink {
|
||||
CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
|
||||
- (void)speedSlow {
|
||||
deltaDisplay = 5;
|
||||
}
|
||||
|
||||
- (void)speedNormal {
|
||||
deltaDisplay = 1;
|
||||
}
|
||||
|
||||
- (void)startDisplayLink {
|
||||
if (displayLink != NULL) {
|
||||
return;
|
||||
}
|
||||
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
|
||||
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)stopDisplayLink {
|
||||
if (displayLink == NULL) {
|
||||
return;
|
||||
}
|
||||
[displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
displayLink = NULL;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame {
|
||||
deltaDisplay = 1;
|
||||
displayCounter = 0;
|
||||
NSLog(@"INIT with size : %fx%f, %fx%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
|
||||
self = [super initWithFrame:frame];
|
||||
self.contentScaleFactor = 1.0f;
|
||||
@ -207,7 +232,7 @@
|
||||
[self setupDepthBuffer];
|
||||
[self setupRenderBuffer];
|
||||
[self setupFrameBuffer];
|
||||
[self setupDisplayLink];
|
||||
[self startDisplayLink];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ namespace ewol {
|
||||
return true;
|
||||
};
|
||||
virtual void onReduce(void) { };
|
||||
virtual void onStateBackground(void) {};
|
||||
virtual void onStateForeground(void) {};
|
||||
virtual void onStateSuspend(void) {};
|
||||
virtual void onStateResume(void) {};
|
||||
virtual void on(void) { };
|
||||
private:
|
||||
bool m_hasDecoration;
|
||||
|
Loading…
x
Reference in New Issue
Block a user