comparison src/video/cocoa/SDL_cocoawindow.m @ 5266:595814f561f7

There is only one width and height for the window. If those are changed during the course of a fullscreen mode change, then they'll stay that size when returning to windowed mode.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 11 Feb 2011 20:49:13 -0800
parents 9e70b360f423
children b530ef003506
comparison
equal deleted inserted replaced
5265:62d2bc792002 5266:595814f561f7
331 } 331 }
332 332
333 SDL_FingerID fingerId = (SDL_FingerID)[touch identity]; 333 SDL_FingerID fingerId = (SDL_FingerID)[touch identity];
334 float x = [touch normalizedPosition].x; 334 float x = [touch normalizedPosition].x;
335 float y = [touch normalizedPosition].y; 335 float y = [touch normalizedPosition].y;
336 /* Make the origin the upper left instead of the lower left */ 336 /* Make the origin the upper left instead of the lower left */
337 y = 1.0f - y; 337 y = 1.0f - y;
338 338
339 switch (type) { 339 switch (type) {
340 case COCOA_TOUCH_DOWN: 340 case COCOA_TOUCH_DOWN:
341 SDL_SendFingerDown(touchId, fingerId, SDL_TRUE, x, y, 1); 341 SDL_SendFingerDown(touchId, fingerId, SDL_TRUE, x, y, 1);
342 break; 342 break;
448 #endif 448 #endif
449 [nswindow setContentView: contentView]; 449 [nswindow setContentView: contentView];
450 [contentView release]; 450 [contentView release];
451 451
452 ConvertNSRect(&rect); 452 ConvertNSRect(&rect);
453 window->fullscreen.x = window->windowed.x = window->x = (int)rect.origin.x; 453 window->x = (int)rect.origin.x;
454 window->fullscreen.y = window->windowed.y = window->y = (int)rect.origin.y; 454 window->y = (int)rect.origin.y;
455 window->fullscreen.w = window->windowed.w = window->w = (int)rect.size.width; 455 window->w = (int)rect.size.width;
456 window->fullscreen.h = window->windowed.h = window->h = (int)rect.size.height; 456 window->h = (int)rect.size.height;
457 } 457 }
458 if ([nswindow isVisible]) { 458 if ([nswindow isVisible]) {
459 window->flags |= SDL_WINDOW_SHOWN; 459 window->flags |= SDL_WINDOW_SHOWN;
460 } else { 460 } else {
461 window->flags &= ~SDL_WINDOW_SHOWN; 461 window->flags &= ~SDL_WINDOW_SHOWN;
707 Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window) 707 Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window)
708 { 708 {
709 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 709 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
710 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 710 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
711 NSWindow *nswindow = data->nswindow; 711 NSWindow *nswindow = data->nswindow;
712 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
713 NSRect rect; 712 NSRect rect;
714 unsigned int style;
715 713
716 if (FULLSCREEN_VISIBLE(window)) { 714 if (FULLSCREEN_VISIBLE(window)) {
715 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
717 SDL_Rect bounds; 716 SDL_Rect bounds;
718 717
719 Cocoa_GetDisplayBounds(_this, display, &bounds); 718 Cocoa_GetDisplayBounds(_this, display, &bounds);
720 rect.origin.x = bounds.x; 719 rect.origin.x = bounds.x;
721 rect.origin.y = bounds.y; 720 rect.origin.y = bounds.y;
722 rect.size.width = bounds.w; 721 rect.size.width = bounds.w;
723 rect.size.height = bounds.h; 722 rect.size.height = bounds.h;
724 ConvertNSRect(&rect); 723 ConvertNSRect(&rect);
725 724
726 style = NSBorderlessWindowMask; 725 [nswindow setStyleMask:NSBorderlessWindowMask];
727 } else { 726 [nswindow setContentSize:rect.size];
728 rect.origin.x = window->windowed.x; 727 [nswindow setFrameOrigin:rect.origin];
729 rect.origin.y = window->windowed.y; 728 } else {
730 rect.size.width = window->windowed.w; 729 [nswindow setStyleMask:GetStyleMask(window)];
731 rect.size.height = window->windowed.h; 730
732 /* FIXME: This calculation is wrong, we're changing the origin */ 731 // This doesn't seem to do anything...
733 ConvertNSRect(&rect); 732 //[nswindow setFrameOrigin:origin];
734 733 }
735 style = GetStyleMask(window);
736 }
737
738 [nswindow setStyleMask:style];
739 [nswindow setContentSize:rect.size];
740 rect = [nswindow frameRectForContentRect:rect];
741 [nswindow setFrameOrigin:rect.origin];
742 734
743 #ifdef FULLSCREEN_TOGGLEABLE 735 #ifdef FULLSCREEN_TOGGLEABLE
744 if (FULLSCREEN_VISIBLE(window)) { 736 if (FULLSCREEN_VISIBLE(window)) {
745 /* OpenGL is rendering to the window, so make it visible! */ 737 /* OpenGL is rendering to the window, so make it visible! */
746 [nswindow setLevel:CGShieldingWindowLevel()]; 738 [nswindow setLevel:CGShieldingWindowLevel()];