src/video/cocoa/SDL_cocoawindow.m
changeset 1937 05e88d266921
parent 1936 83946ee0ff1f
child 1951 7177581dc9fa
equal deleted inserted replaced
1936:83946ee0ff1f 1937:05e88d266921
   417 }
   417 }
   418 
   418 
   419 void
   419 void
   420 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
   420 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
   421 {
   421 {
       
   422     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   422     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   423     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   423     NSString *string;
   424     NSString *string;
   424 
   425 
   425     string = [[NSString alloc] initWithUTF8String:window->title];
   426     string = [[NSString alloc] initWithUTF8String:window->title];
   426     [nswindow setTitle:string];
   427     [nswindow setTitle:string];
   427     [nswindow setMiniwindowTitle:string];
   428     [nswindow setMiniwindowTitle:string];
   428     [string release];
   429     [string release];
       
   430     [pool release];
   429 }
   431 }
   430 
   432 
   431 void
   433 void
   432 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   434 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   433 {
   435 {
       
   436     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   434     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   437     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   435     NSRect rect;
   438     NSRect rect;
   436 
   439 
   437     rect.origin.x = window->x;
   440     rect.origin.x = window->x;
   438     rect.origin.y = window->y;
   441     rect.origin.y = window->y;
   439     rect.size.width = window->w;
   442     rect.size.width = window->w;
   440     rect.size.height = window->h;
   443     rect.size.height = window->h;
   441     ConvertNSRect(&rect);
   444     ConvertNSRect(&rect);
   442     rect = [nswindow frameRectForContentRect:rect];
   445     rect = [nswindow frameRectForContentRect:rect];
   443     [nswindow setFrameOrigin:rect.origin];
   446     [nswindow setFrameOrigin:rect.origin];
       
   447     [pool release];
   444 }
   448 }
   445 
   449 
   446 void
   450 void
   447 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   451 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   448 {
   452 {
       
   453     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   449     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   454     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   450     NSSize size;
   455     NSSize size;
   451 
   456 
   452     size.width = window->w;
   457     size.width = window->w;
   453     size.height = window->h;
   458     size.height = window->h;
   454     [nswindow setContentSize:size];
   459     [nswindow setContentSize:size];
       
   460     [pool release];
   455 }
   461 }
   456 
   462 
   457 void
   463 void
   458 Cocoa_ShowWindow(_THIS, SDL_Window * window)
   464 Cocoa_ShowWindow(_THIS, SDL_Window * window)
   459 {
   465 {
       
   466     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   460     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   467     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   461 
   468 
   462     [nswindow makeKeyAndOrderFront:nil];
   469     [nswindow makeKeyAndOrderFront:nil];
       
   470     [pool release];
   463 }
   471 }
   464 
   472 
   465 void
   473 void
   466 Cocoa_HideWindow(_THIS, SDL_Window * window)
   474 Cocoa_HideWindow(_THIS, SDL_Window * window)
   467 {
   475 {
   471 }
   479 }
   472 
   480 
   473 void
   481 void
   474 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
   482 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
   475 {
   483 {
       
   484     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   476     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   485     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   477 
   486 
   478     [nswindow makeKeyAndOrderFront:nil];
   487     [nswindow makeKeyAndOrderFront:nil];
       
   488     [pool release];
   479 }
   489 }
   480 
   490 
   481 void
   491 void
   482 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
   492 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
   483 {
   493 {
       
   494     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   484     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   495     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   485 
   496 
   486     [nswindow performZoom:nil];
   497     [nswindow performZoom:nil];
       
   498     [pool release];
   487 }
   499 }
   488 
   500 
   489 void
   501 void
   490 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
   502 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
   491 {
   503 {
       
   504     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   492     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   505     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   493 
   506 
   494     [nswindow performMiniaturize:nil];
   507     [nswindow performMiniaturize:nil];
       
   508     [pool release];
   495 }
   509 }
   496 
   510 
   497 void
   511 void
   498 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   512 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   499 {
   513 {
   514 }
   528 }
   515 
   529 
   516 void
   530 void
   517 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
   531 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
   518 {
   532 {
       
   533     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   519     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   534     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   520 
   535 
   521     if (data) {
   536     if (data) {
   522         NSAutoreleasePool *pool;
       
   523 #ifdef SDL_VIDEO_OPENGL
   537 #ifdef SDL_VIDEO_OPENGL
   524         if (window->flags & SDL_WINDOW_OPENGL) {
   538         if (window->flags & SDL_WINDOW_OPENGL) {
   525             Cocoa_GL_CleanupWindow(_this, window);
   539             Cocoa_GL_CleanupWindow(_this, window);
   526         }
   540         }
   527 #endif
   541 #endif
   528         pool = [[NSAutoreleasePool alloc] init];
       
   529         [data->listener close];
   542         [data->listener close];
   530         [data->listener release];
   543         [data->listener release];
   531         if (data->created) {
   544         if (data->created) {
   532             [data->window close];
   545             [data->window close];
   533         }
   546         }
   534         SDL_free(data);
   547         SDL_free(data);
   535         [pool release];
   548     }
   536     }
   549     [pool release];
   537 }
   550 }
   538 
   551 
   539 SDL_bool
   552 SDL_bool
   540 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   553 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   541 {
   554 {