src/video/cocoa/SDL_cocoaevents.m
changeset 5266 e107518710f6
parent 5262 b530ef003506
child 5377 6125f6da3dae
equal deleted inserted replaced
5265:48724afcdc6e 5266:e107518710f6
    38 /* setAppleMenu disappeared from the headers in 10.4 */
    38 /* setAppleMenu disappeared from the headers in 10.4 */
    39 @interface NSApplication(NSAppleMenu)
    39 @interface NSApplication(NSAppleMenu)
    40 - (void)setAppleMenu:(NSMenu *)menu;
    40 - (void)setAppleMenu:(NSMenu *)menu;
    41 @end
    41 @end
    42 
    42 
    43 @implementation NSApplication(SDL)
       
    44 - (void)setRunning
       
    45 {
       
    46     _running = 1;
       
    47 }
       
    48 @end
       
    49 
       
    50 @interface SDLAppDelegate : NSObject
    43 @interface SDLAppDelegate : NSObject
    51 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
    44 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
    52 @end
    45 @end
    53 
    46 
    54 @implementation SDLAppDelegate : NSObject
    47 @implementation SDLAppDelegate : NSObject
   162         [NSApp finishLaunching];
   155         [NSApp finishLaunching];
   163     }
   156     }
   164     if ([NSApp delegate] == nil) {
   157     if ([NSApp delegate] == nil) {
   165         [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
   158         [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
   166     }
   159     }
   167     [NSApp setRunning];
       
   168     [pool release];
   160     [pool release];
   169 }
   161 }
   170 
   162 
   171 void
   163 void
   172 Cocoa_PumpEvents(_THIS)
   164 Cocoa_PumpEvents(_THIS)
   183             data->screensaver_activity = now;
   175             data->screensaver_activity = now;
   184         }
   176         }
   185     }
   177     }
   186 
   178 
   187     pool = [[NSAutoreleasePool alloc] init];
   179     pool = [[NSAutoreleasePool alloc] init];
   188     while ([NSApp isRunning]) {
   180     for ( ; ; ) {
   189         NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
   181         NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
   190         if ( event == nil ) {
   182         if ( event == nil ) {
   191             break;
   183             break;
   192         }
   184         }
   193 		
   185