src/video/cocoa/SDL_cocoawindow.m
changeset 5478 6b65ff3cee62
parent 5466 006883d5fa51
child 5502 ed5f117c949d
equal deleted inserted replaced
5477:50cd1fb880e5 5478:6b65ff3cee62
   668 void
   668 void
   669 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   669 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   670 {
   670 {
   671     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   671     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   672     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   672     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   673     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
       
   674     NSRect rect;
   673     NSRect rect;
   675     SDL_Rect bounds;
   674     Uint32 moveHack;
   676 
   675 
   677     Cocoa_GetDisplayBounds(_this, display, &bounds);
   676     rect.origin.x = window->x;
   678     if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
   677     rect.origin.y = window->y;
   679         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
       
   680     } else {
       
   681         rect.origin.x = window->x;
       
   682     }
       
   683     if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
       
   684         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
       
   685     } else {
       
   686         rect.origin.y = window->y;
       
   687     }
       
   688     rect.size.width = window->w;
   678     rect.size.width = window->w;
   689     rect.size.height = window->h;
   679     rect.size.height = window->h;
   690     ConvertNSRect(&rect);
   680     ConvertNSRect(&rect);
   691     rect = [nswindow frameRectForContentRect:rect];
   681 
       
   682     moveHack = s_moveHack;
       
   683     s_moveHack = 0;
   692     [nswindow setFrameOrigin:rect.origin];
   684     [nswindow setFrameOrigin:rect.origin];
       
   685     s_moveHack = moveHack;
       
   686 
   693     [pool release];
   687     [pool release];
   694 }
   688 }
   695 
   689 
   696 void
   690 void
   697 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   691 Cocoa_SetWindowSize(_THIS, SDL_Window * window)