From 7ddb85b5ff967721dd3bb6ea9059b675d8c96dc6 Mon Sep 17 00:00:00 2001 From: johnmci Date: Thu, 16 Jan 2020 15:59:32 -0800 Subject: [PATCH] add logic to place screen on window that will fit, don't downsize squeak window --- platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h | 1 + platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m | 10 +++++++++- platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h b/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h index 8c25c4014c..20938c6806 100644 --- a/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h +++ b/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h @@ -51,6 +51,7 @@ such third-party acknowledgments. - (void) makeMainWindowOnMainThread ; - (void) makeMainWindow; +- (void) placeMainWindowOnLargerScreenGivenWidth: (sqInt) width height: (sqInt) height; - (id) createPossibleWindow; - (void) workerThreadStart; - (void) singleThreadStart; diff --git a/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m b/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m index 326e0313f6..90824ba5a4 100644 --- a/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m +++ b/platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m @@ -64,6 +64,12 @@ - (void) makeMainWindow { /* get old window size */ width = ((unsigned) getSavedWindowSize()) >> 16; height = getSavedWindowSize() & 0xFFFF; + + extern sqInt getFullScreenFlag(void); + if (!getFullScreenFlag()) { + [self placeMainWindowOnLargerScreenGivenWidth: width height: height]; + } + windowBlock = AddWindowBlock(); windowBlock->handle = (__bridge void*) createdWindow; windowBlock->context = nil; @@ -72,7 +78,7 @@ - (void) makeMainWindow { setSavedWindowSize( (width << 16) |(height & 0xFFFF)); windowBlock->width = width; windowBlock->height = height; - extern sqInt getFullScreenFlag(void); + ioSetFullScreen(getFullScreenFlag()); } @@ -89,6 +95,8 @@ - (void) makeMainWindowOnMainThread {}; - (id) createPossibleWindow { return NULL;}; +- (void) placeMainWindowOnLargerScreenWidth: (sqInt) width height: (sqInt) height {}; + - (void) workerThreadStart { // Run the squeak process in a worker thread squeakThread = [[NSThread alloc] initWithTarget: self.squeakApplication diff --git a/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m b/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m index 6a192ad9fc..e75345f66b 100644 --- a/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m +++ b/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m @@ -171,6 +171,16 @@ - (id) createPossibleWindow { return [self window]; } +- (void) placeMainWindowOnLargerScreenGivenWidth: (sqInt) width height: (sqInt) height { + for (NSScreen *screen in [NSScreen screens]) { + CGSize screenSize = screen.visibleFrame.size; + if ((height <= screenSize.height) && (width <= screenSize.width)) { + self.window.frameOrigin = screen.visibleFrame.origin; + break; + } + } +} + - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileName { if (self.checkForFileNameOnFirstParm == YES) { self.checkForFileNameOnFirstParm = NO;