Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzWindow.m @ 4249:429c8dd3175d SDL-1.2
Fixed bug #713
Don't clamp the mouse coordinates to the video surface size, instead clamp them to the last known window size.
This allows users to get the correct mouse coordinates even if they don't call SDL_SetVideoMode() in response to an SDL_VIDEORESIZE event (used as a hack to retain the OpenGL context on Windows and Linux after a window resize)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 27 Sep 2009 05:18:43 +0000 |
parents | cb44bf8f8a0f |
children |
rev | line source |
---|---|
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
1 /* |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
4159 | 3 Copyright (C) 1997-2009 Sam Lantinga |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
4 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
9 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
13 Library General Public License for more details. |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
14 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
16 License along with this library; if not, write to the Free |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
18 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
19 Sam Lantinga |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
20 slouken@libsdl.org |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
21 */ |
1403
376665398b25
Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents:
779
diff
changeset
|
22 #include "SDL_config.h" |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
23 |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
24 #include "SDL_QuartzVideo.h" |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
25 #include "SDL_QuartzWM.h" |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
26 #include "SDL_QuartzWindow.h" |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
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 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
29 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
|
30 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
|
31 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
|
32 */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
33 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
|
34 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
35 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
|
36 int bpp; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
37 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
38 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
|
39 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
40 if (bpp == 32) { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
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 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
|
43 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
|
44 Uint32 i, j; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
45 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
46 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
|
47 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
|
48 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
49 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
|
50 } |
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 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
53 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
54 @implementation SDL_QuartzWindow |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
55 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
56 /* 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
|
57 - (void)miniaturize:(id)sender |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
58 { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
59 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
|
60 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
61 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
62 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
|
63 [ 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
|
64 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
65 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
66 else { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
67 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
68 /* 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
|
69 QZ_SetPortAlphaOpaque (); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
70 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
71 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
72 /* window is hidden now */ |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
73 SDL_PrivateAppActive (0, SDL_APPACTIVE); |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
74 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
75 [ super miniaturize:sender ]; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
76 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
77 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
78 - (void)display |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
79 { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
80 /* |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
81 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
|
82 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 */ |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
87 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
|
88 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
89 /* 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
|
90 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
|
91 QZ_SetPortAlphaOpaque (); |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
92 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
93 /* save current visible SDL surface */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
94 [ self cacheImageInRect:[ window_view frame ] ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
95 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
96 /* 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
|
97 [ super display ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
98 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
99 /* restore visible SDL surface */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
100 [ self restoreCachedImage ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
101 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
102 /* window is visible again */ |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
103 SDL_PrivateAppActive (1, SDL_APPACTIVE); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
104 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
105 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
106 - (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
|
107 { |
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 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
110 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
|
111 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
|
112 */ |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
113 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
|
114 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
115 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
|
116 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
117 [ 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
|
118 } |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
119 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
|
120 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
121 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
|
122 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
123 [ 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
|
124 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
125 newViewFrame = [ window_view frame ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
126 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
127 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
|
128 } |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
129 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
272
diff
changeset
|
130 |
4240 | 131 /* QZ_DoActivate() calls a low-level CoreGraphics routine to adjust |
132 the cursor position, if input is being grabbed. If app activation is | |
133 triggered by a mouse click in the title bar, then the window manager | |
134 gets confused and thinks we're dragging the window. The solution | |
135 below postpones the activate event to avoid this scenario. */ | |
136 - (void)becomeKeyWindow | |
137 { | |
138 NSEvent *event = [self currentEvent]; | |
139 if ([event type] == NSLeftMouseDown && [event window] == self) | |
140 watchForMouseUp = YES; | |
141 else | |
142 [super becomeKeyWindow]; | |
143 } | |
144 | |
145 - (void)sendEvent:(NSEvent *)event | |
146 { | |
147 [super sendEvent:event]; | |
148 if (watchForMouseUp && [event type] == NSLeftMouseUp) | |
149 { | |
150 watchForMouseUp = NO; | |
151 [super becomeKeyWindow]; | |
152 } | |
153 } | |
154 | |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
155 - (void)appDidHide:(NSNotification*)note |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
156 { |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
157 SDL_PrivateAppActive (0, SDL_APPACTIVE); |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
158 } |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
159 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
160 - (void)appWillUnhide:(NSNotification*)note |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
161 { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
162 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
|
163 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
164 if ( this ) { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
165 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
166 /* 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
|
167 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
|
168 QZ_SetPortAlphaOpaque (); |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
169 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
170 /* save current visible SDL surface */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
171 [ self cacheImageInRect:[ window_view frame ] ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
172 } |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
173 } |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
174 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
175 - (void)appDidUnhide:(NSNotification*)note |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
176 { |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
177 /* 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
|
178 [ self restoreCachedImage ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
179 |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
180 /*SDL_PrivateExpose ();*/ |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
181 |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
182 SDL_PrivateAppActive (1, SDL_APPACTIVE); |
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 |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
185 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag |
631
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
186 { |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
187 /* 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
|
188 [ [ NSNotificationCenter defaultCenter ] addObserver:self |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
189 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
|
190 |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
191 [ [ NSNotificationCenter defaultCenter ] addObserver:self |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
192 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
|
193 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
194 [ [ NSNotificationCenter defaultCenter ] addObserver:self |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
631
diff
changeset
|
195 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
|
196 |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
197 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
|
198 } |
52864d66d168
Date: Mon, 5 May 2003 00:08:51 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
199 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
200 @end |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
201 |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
202 @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
|
203 - (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
|
204 { |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
205 SDL_PrivateQuit(); |
56
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
206 return NO; |
ce9cd2cf0d0d
Date: Sun, 10 Jun 2001 17:33:44 -0500
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
207 } |
779
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
208 |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
209 - (void)windowDidBecomeKey:(NSNotification *)aNotification |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
210 { |
1629 | 211 QZ_DoActivate (current_video); |
779
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
212 } |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
213 |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
214 - (void)windowDidResignKey:(NSNotification *)aNotification |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
215 { |
1629 | 216 QZ_DoDeactivate (current_video); |
779
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
217 } |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
218 |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
56
diff
changeset
|
219 @end |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
220 |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
221 @implementation SDL_QuartzView |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
222 |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
223 - (void)resetCursorRects |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
224 { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
225 SDL_Cursor *sdlc = SDL_GetCursor(); |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
226 if (sdlc != NULL && sdlc->wm_cursor != NULL) { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
227 [self addCursorRect: [self visibleRect] cursor: sdlc->wm_cursor->nscursor]; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
228 } |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
229 } |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
230 |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
231 @end |