Skip to content

Commit 7ddb85b

Browse files
committed
add logic to place screen on window that will fit, don't downsize squeak window
1 parent 80f639a commit 7ddb85b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ such third-party acknowledgments.
5151

5252
- (void) makeMainWindowOnMainThread ;
5353
- (void) makeMainWindow;
54+
- (void) placeMainWindowOnLargerScreenGivenWidth: (sqInt) width height: (sqInt) height;
5455
- (id) createPossibleWindow;
5556
- (void) workerThreadStart;
5657
- (void) singleThreadStart;

platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ - (void) makeMainWindow {
6464
/* get old window size */
6565
width = ((unsigned) getSavedWindowSize()) >> 16;
6666
height = getSavedWindowSize() & 0xFFFF;
67+
68+
extern sqInt getFullScreenFlag(void);
69+
if (!getFullScreenFlag()) {
70+
[self placeMainWindowOnLargerScreenGivenWidth: width height: height];
71+
}
72+
6773
windowBlock = AddWindowBlock();
6874
windowBlock->handle = (__bridge void*) createdWindow;
6975
windowBlock->context = nil;
@@ -72,7 +78,7 @@ - (void) makeMainWindow {
7278
setSavedWindowSize( (width << 16) |(height & 0xFFFF));
7379
windowBlock->width = width;
7480
windowBlock->height = height;
75-
extern sqInt getFullScreenFlag(void);
81+
7682
ioSetFullScreen(getFullScreenFlag());
7783

7884
}
@@ -89,6 +95,8 @@ - (void) makeMainWindowOnMainThread {};
8995

9096
- (id) createPossibleWindow { return NULL;};
9197

98+
- (void) placeMainWindowOnLargerScreenWidth: (sqInt) width height: (sqInt) height {};
99+
92100
- (void) workerThreadStart {
93101
// Run the squeak process in a worker thread
94102
squeakThread = [[NSThread alloc] initWithTarget: self.squeakApplication

platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ - (id) createPossibleWindow {
171171
return [self window];
172172
}
173173

174+
- (void) placeMainWindowOnLargerScreenGivenWidth: (sqInt) width height: (sqInt) height {
175+
for (NSScreen *screen in [NSScreen screens]) {
176+
CGSize screenSize = screen.visibleFrame.size;
177+
if ((height <= screenSize.height) && (width <= screenSize.width)) {
178+
self.window.frameOrigin = screen.visibleFrame.origin;
179+
break;
180+
}
181+
}
182+
}
183+
174184
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileName {
175185
if (self.checkForFileNameOnFirstParm == YES) {
176186
self.checkForFileNameOnFirstParm = NO;

0 commit comments

Comments
 (0)