Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzWindow.m @ 724:6b3dfe0198bb
Atari CD-ROM support
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Sat, 27 Sep 2003 08:20:26 +0000 |
parents | 5d2f027b3349 |
children | c5b2b6d2d1fe |
rev | line source |
---|---|
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
2 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
3 This function makes the *SDL region* of the window 100% opaque. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
4 The genie effect uses the alpha component. Otherwise, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
5 it doesn't seem to matter what value it has. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
6 */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
7 static void QZ_SetPortAlphaOpaque () { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
8 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
9 SDL_Surface *surface = current_video->screen; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
10 int bpp; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
11 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
12 bpp = surface->format->BitsPerPixel; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
13 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
14 if (bpp == 32) { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
15 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
16 Uint32 *pixels = (Uint32*) surface->pixels; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
17 Uint32 rowPixels = surface->pitch / 4; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
18 Uint32 i, j; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
19 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
20 for (i = 0; i < surface->h; i++) |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
21 for (j = 0; j < surface->w; j++) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
22 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
23 pixels[ (i * rowPixels) + j ] |= 0xFF000000; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
24 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
25 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
26 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
27 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
28 /* Subclass of NSWindow to fix genie effect and support resize events */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
29 @interface SDL_QuartzWindow : NSWindow |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
30 {} |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
31 - (void)miniaturize:(id)sender; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
32 - (void)display; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
33 - (void)setFrame:(NSRect)frameRect display:(BOOL)flag; |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
34 - (void)appDidHide:(NSNotification*)note; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
35 - (void)appWillUnhide:(NSNotification*)note; |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
36 - (void)appDidUnhide:(NSNotification*)note; |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
37 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
38 @end |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
39 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
40 @implementation SDL_QuartzWindow |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
41 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
42 /* we override these methods to fix the miniaturize animation/dock icon bug */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
43 - (void)miniaturize:(id)sender |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
44 { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
45 if (SDL_VideoSurface->flags & SDL_OPENGL) { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
46 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
47 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
48 Future: Grab framebuffer and put into NSImage |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
49 [ qz_window setMiniwindowImage:image ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
50 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
51 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
52 else { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
53 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
54 /* make the alpha channel opaque so anim won't have holes in it */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
55 QZ_SetPortAlphaOpaque (); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
56 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
57 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
58 /* window is hidden now */ |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
59 SDL_PrivateAppActive (0, SDL_APPACTIVE); |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
60 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
61 [ super miniaturize:sender ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
62 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
63 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
64 - (void)display |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
65 { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
66 /* |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
67 This method fires just before the window deminaturizes from the Dock. |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
68 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
69 We'll save the current visible surface, let the window manager redraw any |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
70 UI elements, and restore the SDL surface. This way, no expose event |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
71 is required, and the deminiaturize works perfectly. |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
72 */ |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
73 SDL_VideoDevice *this = (SDL_VideoDevice*)current_video; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
74 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
75 /* make sure pixels are fully opaque */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
76 if (! ( SDL_VideoSurface->flags & SDL_OPENGL ) ) |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
77 QZ_SetPortAlphaOpaque (); |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
78 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
79 /* save current visible SDL surface */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
80 [ self cacheImageInRect:[ window_view frame ] ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
81 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
82 /* let the window manager redraw controls, border, etc */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
83 [ super display ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
84 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
85 /* restore visible SDL surface */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
86 [ self restoreCachedImage ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
87 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
88 /* window is visible again */ |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
89 SDL_PrivateAppActive (1, SDL_APPACTIVE); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
90 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
91 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
92 - (void)setFrame:(NSRect)frameRect display:(BOOL)flag |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
93 { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
94 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
95 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
96 If the video surface is NULL, this originated from QZ_SetVideoMode, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
97 so don't send the resize event. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
98 */ |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
99 SDL_VideoDevice *this = (SDL_VideoDevice*)current_video; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
100 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
101 if (this && SDL_VideoSurface == NULL) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
102 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
103 [ super setFrame:frameRect display:flag ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
104 } |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
105 else if (this && qz_window) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
106 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
107 NSRect newViewFrame; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
108 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
109 [ super setFrame:frameRect display:flag ]; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
110 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
111 newViewFrame = [ window_view frame ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
112 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
113 SDL_PrivateResize (newViewFrame.size.width, newViewFrame.size.height); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
114 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
115 /* If not OpenGL, we have to update the pixels and pitch */ |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
116 if ( ! ( SDL_VideoSurface->flags & SDL_OPENGL ) ) { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
117 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
118 CGrafPtr thePort = [ window_view qdPort ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
119 LockPortBits ( thePort ); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
120 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
121 SDL_VideoSurface->pixels = GetPixBaseAddr ( GetPortPixMap ( thePort ) ); |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
122 SDL_VideoSurface->pitch = GetPixRowBytes ( GetPortPixMap ( thePort ) ); |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
123 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
124 /* |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
125 SDL_VideoSurface->pixels now points to the window's pixels |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
126 We want it to point to the *view's* pixels |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
127 */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
128 { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
129 int vOffset = [ qz_window frame ].size.height - |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
130 newViewFrame.size.height - newViewFrame.origin.y; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
131 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
132 int hOffset = newViewFrame.origin.x; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
133 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
134 SDL_VideoSurface->pixels += (vOffset * SDL_VideoSurface->pitch) + hOffset * (device_bpp/8); |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
135 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
136 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
137 UnlockPortBits ( thePort ); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
138 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
139 } |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
140 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
141 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
142 - (void)appDidHide:(NSNotification*)note |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
143 { |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
144 SDL_PrivateAppActive (0, SDL_APPACTIVE); |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
145 } |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
146 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
147 - (void)appWillUnhide:(NSNotification*)note |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
148 { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
149 SDL_VideoDevice *this = (SDL_VideoDevice*)current_video; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
150 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
151 if ( this ) { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
152 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
153 /* make sure pixels are fully opaque */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
154 if (! ( SDL_VideoSurface->flags & SDL_OPENGL ) ) |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
155 QZ_SetPortAlphaOpaque (); |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
156 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
157 /* save current visible SDL surface */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
158 [ self cacheImageInRect:[ window_view frame ] ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
159 } |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
160 } |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
161 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
162 - (void)appDidUnhide:(NSNotification*)note |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
163 { |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
164 /* restore cached image, since it may not be current, post expose event too */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
165 [ self restoreCachedImage ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
166 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
167 //SDL_PrivateExpose (); |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
168 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
169 SDL_PrivateAppActive (1, SDL_APPACTIVE); |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
170 } |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
171 |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
172 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
173 { |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
174 /* Make our window subclass receive these application notifications */ |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
175 [ [ NSNotificationCenter defaultCenter ] addObserver:self |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
176 selector:@selector(appDidHide:) name:NSApplicationDidHideNotification object:NSApp ]; |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
177 |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
178 [ [ NSNotificationCenter defaultCenter ] addObserver:self |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
179 selector:@selector(appDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp ]; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
180 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
181 [ [ NSNotificationCenter defaultCenter ] addObserver:self |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
182 selector:@selector(appWillUnhide:) name:NSApplicationWillUnhideNotification object:NSApp ]; |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
183 |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
184 return [ super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag ]; |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
185 } |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
186 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
187 @end |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
188 |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
189 /* Delegate for our NSWindow to send SDLQuit() on close */ |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
190 @interface SDL_QuartzWindowDelegate : NSObject |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
191 {} |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
192 - (BOOL)windowShouldClose:(id)sender; |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
193 @end |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
194 |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
195 @implementation SDL_QuartzWindowDelegate |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
196 - (BOOL)windowShouldClose:(id)sender |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
197 { |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
198 SDL_PrivateQuit(); |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
199 return NO; |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
200 } |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
201 @end |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
202 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
203 /* Subclass of NSQuickDrawView for the window's subview */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
204 @interface SDL_QuartzWindowView : NSQuickDrawView |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
205 {} |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
206 @end |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
207 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
208 @implementation SDL_QuartzWindowView |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
209 @end |