Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,14 @@ - (void)cn1ApplicationWillEnterForeground
if (cn1IsHiddenInBackground) {
[[CodenameOne_GLViewController instance] eaglView].hidden = NO;
}
// Clear before updateCanvas: viewWillTransitionToSize: and
// didRotateFromInterfaceOrientation: use this to skip propagation during
// iOS's snapshot-phase orientation flip on iPad between stop and start.
isAppSuspended = NO;
com_codename1_impl_ios_IOSImplementation_applicationWillEnterForeground__(CN1_THREAD_GET_STATE_PASS_SINGLE_ARG);
CodenameOne_GLViewController* vc = [CodenameOne_GLViewController instance];
if (vc != nil) {
// Defer updateCanvas by one run-loop cycle so that UIKit has a chance to
// settle the root view bounds after foreground transition. Calling this
// too early can report the short edge for width/height on iPad, which
// causes a transient wrong screen-size event between stop/start.
dispatch_async(dispatch_get_main_queue(), ^{
CodenameOne_GLViewController* deferredVc = [CodenameOne_GLViewController instance];
if (deferredVc != nil) {
[deferredVc updateCanvas:YES];
}
});
[vc updateCanvas:YES];
}
}

Expand Down
14 changes: 12 additions & 2 deletions Ports/iOSPort/nativeSources/CodenameOne_GLViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ JAVA_INT getSafeTop() {
BOOL firstTime = YES;
BOOL retinaBug;
float scaleValue = 1;
extern BOOL isAppSuspended;

static void updateDisplayMetricsFromView(UIView *view) {
if (view == nil) {
Expand Down Expand Up @@ -2726,7 +2727,13 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
}

-(void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator {

// iOS fires this during its background snapshot pass on iPad with the
// opposite-orientation size. Publishing that would deliver a swapped
// screenSizeChanged to the EDT between stop and start.
if (isAppSuspended) {
return;
}

if(editingComponent != nil) {
// Since willRotateToInterfaceOrientation is deprecated, newer versions (tested 11.3)
// don't call it anymore on rotation.
Expand Down Expand Up @@ -2789,7 +2796,10 @@ - (void)viewSafeAreaInsetsDidChange {
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

if (isAppSuspended) {
return;
}

[[self eaglView] updateFrameBufferSize:(int)self.view.bounds.size.width h:(int)self.view.bounds.size.height];
[[self eaglView] deleteFramebuffer];

Expand Down
Loading