Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzVideo.m @ 683:5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
From: Darrell Walisser
Subject: Re: Updated projects?
>> Did you get a chance to look at my "Custom Cocoa" demo? I have a few
>> minor patches that enable SDL/Cocoa integration, and a project
>> template.
>
> I didn't yet, but go ahead and send me the patches. :)
>
I updated the patch for current CVS. There are a lot of changes, but I
don't think I've broken anything. This patch also improves the behavior
of window minimize/deminimize.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 10 Aug 2003 07:21:43 +0000 |
parents | be597a247e20 |
children | c5b2b6d2d1fe |
comparison
equal
deleted
inserted
replaced
682:8b2b97e466bc | 683:5d2f027b3349 |
---|---|
394 | 394 |
395 /* Restore original screen resolution/bpp */ | 395 /* Restore original screen resolution/bpp */ |
396 CGDisplaySwitchToMode (display_id, save_mode); | 396 CGDisplaySwitchToMode (display_id, save_mode); |
397 CGReleaseAllDisplays (); | 397 CGReleaseAllDisplays (); |
398 ShowMenuBar (); | 398 ShowMenuBar (); |
399 | |
400 /* | 399 /* |
401 Reset the main screen's rectangle | 400 Reset the main screen's rectangle |
402 See comment in QZ_SetVideoFullscreen for why we do this | 401 See comment in QZ_SetVideoFullscreen for why we do this |
403 */ | 402 */ |
404 screen_rect = NSMakeRect(0,0,device_width,device_height); | 403 screen_rect = NSMakeRect(0,0,device_width,device_height); |
578 | 577 |
579 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width, | 578 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width, |
580 int height, int bpp, Uint32 flags) { | 579 int height, int bpp, Uint32 flags) { |
581 unsigned int style; | 580 unsigned int style; |
582 NSRect contentRect; | 581 NSRect contentRect; |
582 BOOL isCustom = NO; | |
583 int center_window = 1; | 583 int center_window = 1; |
584 int origin_x, origin_y; | 584 int origin_x, origin_y; |
585 | 585 |
586 current->flags = 0; | 586 current->flags = 0; |
587 current->w = width; | 587 current->w = width; |
600 if ( (mode_flags & SDL_FULLSCREEN) || | 600 if ( (mode_flags & SDL_FULLSCREEN) || |
601 ((mode_flags ^ flags) & (SDL_NOFRAME|SDL_RESIZABLE)) || | 601 ((mode_flags ^ flags) & (SDL_NOFRAME|SDL_RESIZABLE)) || |
602 (mode_flags & SDL_OPENGL) || | 602 (mode_flags & SDL_OPENGL) || |
603 (flags & SDL_OPENGL) ) | 603 (flags & SDL_OPENGL) ) |
604 QZ_UnsetVideoMode (this); | 604 QZ_UnsetVideoMode (this); |
605 | 605 |
606 /* Check for user-specified window and view */ | |
607 { | |
608 char *windowPtrString = getenv ("SDL_NSWindowPointer"); | |
609 char *viewPtrString = getenv ("SDL_NSQuickDrawViewPointer"); | |
610 | |
611 if (windowPtrString && viewPtrString) { | |
612 | |
613 /* Release any previous window */ | |
614 if ( qz_window ) { | |
615 [ qz_window release ]; | |
616 qz_window = nil; | |
617 } | |
618 | |
619 qz_window = (NSWindow*)atoi(windowPtrString); | |
620 window_view = (NSQuickDrawView*)atoi(viewPtrString); | |
621 isCustom = YES; | |
622 | |
623 /* | |
624 Retain reference to window because we | |
625 might release it in QZ_UnsetVideoMode | |
626 */ | |
627 [ qz_window retain ]; | |
628 | |
629 style = [ qz_window styleMask ]; | |
630 /* Check resizability */ | |
631 if ( style & NSResizableWindowMask ) | |
632 current->flags |= SDL_RESIZABLE; | |
633 | |
634 /* Check frame */ | |
635 if ( style & NSBorderlessWindowMask ) | |
636 current->flags |= SDL_NOFRAME; | |
637 } | |
638 } | |
639 | |
606 /* Check if we should recreate the window */ | 640 /* Check if we should recreate the window */ |
607 if (qz_window == nil) { | 641 if (qz_window == nil) { |
608 | 642 |
609 /* Set the window style based on input flags */ | 643 /* Set the window style based on input flags */ |
610 if ( flags & SDL_NOFRAME ) { | 644 if ( flags & SDL_NOFRAME ) { |
648 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ]; | 682 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ]; |
649 } | 683 } |
650 /* We already have a window, just change its size */ | 684 /* We already have a window, just change its size */ |
651 else { | 685 else { |
652 | 686 |
653 [ qz_window setContentSize:contentRect.size ]; | 687 if (!isCustom) { |
654 current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags; | 688 [ qz_window setContentSize:contentRect.size ]; |
689 current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags; | |
690 } | |
655 } | 691 } |
656 | 692 |
657 /* For OpenGL, we bind the context to a subview */ | 693 /* For OpenGL, we bind the context to a subview */ |
658 if ( flags & SDL_OPENGL ) { | 694 if ( flags & SDL_OPENGL ) { |
659 | 695 |
690 | 726 |
691 current->flags |= SDL_SWSURFACE; | 727 current->flags |= SDL_SWSURFACE; |
692 current->flags |= SDL_PREALLOC; | 728 current->flags |= SDL_PREALLOC; |
693 current->flags |= SDL_ASYNCBLIT; | 729 current->flags |= SDL_ASYNCBLIT; |
694 | 730 |
695 /* Offset below the title bar to fill the full content region */ | 731 /* |
696 current->pixels += ((int)([ qz_window frame ].size.height) - height) * current->pitch; | 732 current->pixels now points to the window's pixels |
697 | 733 We want it to point to the *view's* pixels |
734 */ | |
735 { | |
736 int vOffset = [ qz_window frame ].size.height - | |
737 [ window_view frame ].size.height - [ window_view frame ].origin.y; | |
738 | |
739 int hOffset = [ window_view frame ].origin.x; | |
740 | |
741 current->pixels += (vOffset * current->pitch) + hOffset * (device_bpp/8); | |
742 } | |
698 this->UpdateRects = QZ_UpdateRects; | 743 this->UpdateRects = QZ_UpdateRects; |
699 this->LockHWSurface = QZ_LockWindow; | 744 this->LockHWSurface = QZ_LockWindow; |
700 this->UnlockHWSurface = QZ_UnlockWindow; | 745 this->UnlockHWSurface = QZ_UnlockWindow; |
701 } | 746 } |
702 | 747 |