Mac: Change the startup windows display the window normally and start a mini runloop instead of calling using runModalForWindow.

This way, the Quit function works.

git-svn-id: https://svn.eduke32.com/eduke32@5965 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-12-26 06:02:27 +00:00
parent dc1bbcd419
commit 25f2a5f457
2 changed files with 32 additions and 58 deletions

View file

@ -79,6 +79,8 @@ static NSPopUpButton * makeComboBox(void)
static id nsapp; static id nsapp;
static int retval = -1;
static struct { static struct {
int fullscreen; int fullscreen;
int xdim2d, ydim2d; int xdim2d, ydim2d;
@ -134,21 +136,6 @@ static struct {
// window properties // window properties
[self setDelegate:self]; [self setDelegate:self];
[self setReleasedWhenClosed:NO]; [self setReleasedWhenClosed:NO];
#if defined MAC_OS_X_VERSION_10_6 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
[self setPreventsApplicationTerminationWhenModal:NO];
#else
SEL selector = @selector(setPreventsApplicationTerminationWhenModal:);
if ([self respondsToSelector:selector])
{
BOOL argument = NO;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:self];
[invocation setArgument:&argument atIndex:2];
[invocation invoke];
[invocation release];
}
#endif
#if defined MAC_OS_X_VERSION_10_3 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 #if defined MAC_OS_X_VERSION_10_3 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
[self setContentMinSize:[[self contentView] frame].size]; [self setContentMinSize:[[self contentView] frame].size];
#else #else
@ -314,7 +301,7 @@ static struct {
{ {
UNREFERENCED_PARAMETER(sender); UNREFERENCED_PARAMETER(sender);
[nsapp abortModal]; retval = 0;
return YES; return YES;
} }
@ -414,7 +401,7 @@ static struct {
{ {
UNREFERENCED_PARAMETER(sender); UNREFERENCED_PARAMETER(sender);
[nsapp abortModal]; retval = 0;
} }
- (void)start:(id)sender - (void)start:(id)sender
@ -438,7 +425,7 @@ static struct {
settings.forcesetup = [alwaysShowButton state] == NSOnState; settings.forcesetup = [alwaysShowButton state] == NSOnState;
[nsapp stopModal]; retval = 1;
} }
- (void)setupRunMode - (void)setupRunMode
@ -575,8 +562,6 @@ int startwin_idle(void *v)
int startwin_run(void) int startwin_run(void)
{ {
int retval;
if (startwin == nil) return 0; if (startwin == nil) return 0;
settings.fullscreen = fullscreen; settings.fullscreen = fullscreen;
@ -589,16 +574,18 @@ int startwin_run(void)
[startwin setupRunMode]; [startwin setupRunMode];
switch ([nsapp runModalForWindow:startwin]) { [nsapp finishLaunching];
#ifdef MAC_OS_X_VERSION_10_9
case NSModalResponseStop: retval = 1; break; [startwin center];
case NSModalResponseAbort: retval = 0; break; [startwin makeKeyAndOrderFront:nil];
#else
case NSRunStoppedResponse: retval = 1; break; do
case NSRunAbortedResponse: retval = 0; break; {
#endif NSEvent *event = [nsapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
default: retval = -1; [nsapp sendEvent:event];
[nsapp updateWindows];
} }
while (retval == -1);
[startwin setupMessagesMode]; [startwin setupMessagesMode];

View file

@ -86,6 +86,8 @@ static NSPopUpButton * makeComboBox(void)
static id nsapp; static id nsapp;
static int retval = -1;
static struct { static struct {
grpfile_t const * grp; grpfile_t const * grp;
int fullscreen; int fullscreen;
@ -141,21 +143,6 @@ static struct {
// window properties // window properties
[self setDelegate:self]; [self setDelegate:self];
[self setReleasedWhenClosed:NO]; [self setReleasedWhenClosed:NO];
#if defined MAC_OS_X_VERSION_10_6 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
[self setPreventsApplicationTerminationWhenModal:NO];
#else
SEL selector = @selector(setPreventsApplicationTerminationWhenModal:);
if ([self respondsToSelector:selector])
{
BOOL argument = NO;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:self];
[invocation setArgument:&argument atIndex:2];
[invocation invoke];
[invocation release];
}
#endif
#if defined MAC_OS_X_VERSION_10_3 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 #if defined MAC_OS_X_VERSION_10_3 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
[self setContentMinSize:[[self contentView] frame].size]; [self setContentMinSize:[[self contentView] frame].size];
#else #else
@ -339,7 +326,7 @@ static struct {
{ {
UNREFERENCED_PARAMETER(sender); UNREFERENCED_PARAMETER(sender);
[nsapp abortModal]; retval = 0;
return YES; return YES;
} }
@ -409,7 +396,7 @@ static struct {
{ {
UNREFERENCED_PARAMETER(sender); UNREFERENCED_PARAMETER(sender);
[nsapp abortModal]; retval = 0;
} }
- (void)start:(id)sender - (void)start:(id)sender
@ -431,7 +418,7 @@ static struct {
settings.forcesetup = [alwaysShowButton state] == NSOnState; settings.forcesetup = [alwaysShowButton state] == NSOnState;
[nsapp stopModal]; retval = 1;
} }
- (void)setupRunMode - (void)setupRunMode
@ -582,8 +569,6 @@ int startwin_idle(void *v)
int startwin_run(void) int startwin_run(void)
{ {
int retval;
if (startwin == nil) return 0; if (startwin == nil) return 0;
settings.fullscreen = ud.config.ScreenMode; settings.fullscreen = ud.config.ScreenMode;
@ -595,16 +580,18 @@ int startwin_run(void)
[startwin setupRunMode]; [startwin setupRunMode];
switch ([nsapp runModalForWindow:startwin]) { [nsapp finishLaunching];
#ifdef MAC_OS_X_VERSION_10_9
case NSModalResponseStop: retval = 1; break; [startwin center];
case NSModalResponseAbort: retval = 0; break; [startwin makeKeyAndOrderFront:nil];
#else
case NSRunStoppedResponse: retval = 1; break; do
case NSRunAbortedResponse: retval = 0; break; {
#endif NSEvent *event = [nsapp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
default: retval = -1; [nsapp sendEvent:event];
[nsapp updateWindows];
} }
while (retval == -1);
[startwin setupMessagesMode]; [startwin setupMessagesMode];