Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzWM.m @ 4236:1fc8c8a5ff00 SDL-1.2
Fixed endianness issues with fullscreen mode
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 23 Sep 2009 06:56:28 +0000 |
parents | 976bc19f8f6b |
children | 2b8c1aea633b |
rev | line source |
---|---|
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1 /* |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
4159 | 3 Copyright (C) 1997-2009 Sam Lantinga |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
4 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
9 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
13 Library General Public License for more details. |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
14 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
18 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
19 Sam Lantinga |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
20 slouken@libsdl.org |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
21 */ |
1403
376665398b25
Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents:
1207
diff
changeset
|
22 #include "SDL_config.h" |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
23 |
761
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:
4066
diff
changeset
|
25 #include "SDL_QuartzWM.h" |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
26 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
27 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
28 void QZ_FreeWMCursor (_THIS, WMcursor *cursor) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
29 |
1883 | 30 if ( cursor != NULL ) { |
31 [ cursor->nscursor release ]; | |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
32 free (cursor); |
1883 | 33 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
34 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
35 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
36 WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
37 int w, int h, int hot_x, int hot_y) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
38 WMcursor *cursor; |
1883 | 39 NSBitmapImageRep *imgrep; |
40 NSImage *img; | |
41 unsigned char *planes[5]; | |
42 int i; | |
43 NSAutoreleasePool *pool; | |
44 | |
45 pool = [ [ NSAutoreleasePool alloc ] init ]; | |
46 | |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
47 /* Allocate the cursor memory */ |
1756
eed7a3f396ce
Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents:
1629
diff
changeset
|
48 cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); |
1883 | 49 if (cursor == NULL) goto outOfMemory; |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
50 |
1883 | 51 /* create the image representation and get the pointers to its storage */ |
52 imgrep = [ [ [ NSBitmapImageRep alloc ] initWithBitmapDataPlanes: NULL pixelsWide: w pixelsHigh: h bitsPerSample: 1 samplesPerPixel: 2 hasAlpha: YES isPlanar: YES colorSpaceName: NSDeviceBlackColorSpace bytesPerRow: (w+7)/8 bitsPerPixel: 0 ] autorelease ]; | |
53 if (imgrep == nil) goto outOfMemory; | |
54 [ imgrep getBitmapDataPlanes: planes ]; | |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
55 |
1883 | 56 /* copy data and mask, extending the mask to all black pixels because the inversion effect doesn't work with Cocoa's alpha-blended cursors */ |
57 for (i = 0; i < (w+7)/8*h; i++) { | |
58 planes[0][i] = data[i]; | |
59 planes[1][i] = mask[i] | data[i]; | |
60 } | |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
61 |
1883 | 62 /* create image and cursor */ |
63 img = [ [ [ NSImage alloc ] initWithSize: NSMakeSize(w, h) ] autorelease ]; | |
64 if (img == nil) goto outOfMemory; | |
65 [ img addRepresentation: imgrep ]; | |
66 if (system_version < 0x1030) { /* on 10.2, cursors must be 16*16 */ | |
67 if (w > 16 || h > 16) { /* too big: scale it down */ | |
68 [ img setScalesWhenResized: YES ]; | |
69 hot_x = hot_x*16/w; | |
70 hot_y = hot_y*16/h; | |
71 } | |
72 else { /* too small (or just right): extend it (from the bottom left corner, so hot_y must be adjusted) */ | |
73 hot_y += 16 - h; | |
74 } | |
75 [ img setSize: NSMakeSize(16, 16) ]; | |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
76 } |
1883 | 77 cursor->nscursor = [ [ NSCursor alloc ] initWithImage: img hotSpot: NSMakePoint(hot_x, hot_y) ]; |
78 if (cursor->nscursor == nil) goto outOfMemory; | |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
79 |
1883 | 80 [ pool release ]; |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
81 return(cursor); |
1883 | 82 |
83 outOfMemory: | |
84 [ pool release ]; | |
85 if (cursor != NULL) SDL_free(cursor); | |
86 SDL_OutOfMemory(); | |
87 return(NULL); | |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
88 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
89 |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
90 void QZ_UpdateCursor (_THIS) { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
91 BOOL state; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
92 |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
93 if (cursor_should_be_visible || !(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
94 state = YES; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
95 } else { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
96 state = NO; |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
97 } |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
98 if (state != cursor_visible) { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
99 if (state) { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
100 [ NSCursor unhide ]; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
101 } else { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
102 [ NSCursor hide ]; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
103 } |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
104 cursor_visible = state; |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
105 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
106 } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
107 |
779
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
108 BOOL QZ_IsMouseInWindow (_THIS) { |
4065 | 109 if (qz_window == nil || (mode_flags & SDL_FULLSCREEN)) return YES; /*fullscreen*/ |
1192 | 110 else { |
111 NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ]; | |
112 p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */ | |
113 return NSPointInRect(p, [ window_view frame ]); | |
114 } | |
779
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
115 } |
68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
761
diff
changeset
|
116 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
117 int QZ_ShowWMCursor (_THIS, WMcursor *cursor) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
118 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
119 if ( cursor == NULL) { |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
120 if ( cursor_should_be_visible ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
121 cursor_should_be_visible = NO; |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
122 QZ_ChangeGrabState (this, QZ_HIDECURSOR); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
123 } |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
124 QZ_UpdateCursor(this); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
125 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
126 else { |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
127 if (qz_window ==nil || (mode_flags & SDL_FULLSCREEN)) { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
128 [ cursor->nscursor set ]; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
129 } |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
130 else { |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
131 [ qz_window invalidateCursorRectsForView: [ qz_window contentView ] ]; |
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
132 } |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
133 if ( ! cursor_should_be_visible ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
134 cursor_should_be_visible = YES; |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
135 QZ_ChangeGrabState (this, QZ_SHOWCURSOR); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
136 } |
4070
b8f2db95145e
Patch from Christian Walther
Sam Lantinga <slouken@libsdl.org>
parents:
4066
diff
changeset
|
137 QZ_UpdateCursor(this); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
138 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
139 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
140 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
141 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
142 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
143 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
144 Coordinate conversion functions, for convenience |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
145 Cocoa sets the origin at the lower left corner of the window/screen |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
146 SDL, CoreGraphics/WindowServer, and QuickDraw use the origin at the upper left corner |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
147 The routines were written so they could be called before SetVideoMode() has finished; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
148 this might have limited usefulness at the moment, but the extra cost is trivial. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
149 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
150 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
151 /* Convert Cocoa screen coordinate to Cocoa window coordinate */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
152 void QZ_PrivateGlobalToLocal (_THIS, NSPoint *p) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
153 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
154 *p = [ qz_window convertScreenToBase:*p ]; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
155 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
156 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
157 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
158 /* Convert Cocoa window coordinate to Cocoa screen coordinate */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
159 void QZ_PrivateLocalToGlobal (_THIS, NSPoint *p) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
160 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
161 *p = [ qz_window convertBaseToScreen:*p ]; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
162 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
163 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
164 /* Convert SDL coordinate to Cocoa coordinate */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
165 void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
166 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
167 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
168 |
876
9e84d106ec19
(Said Max Horn on the SDL mailing list...)
Ryan C. Gordon <icculus@icculus.org>
parents:
779
diff
changeset
|
169 p->y = CGDisplayPixelsHigh (display_id) - p->y; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
170 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
171 else { |
934
af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
876
diff
changeset
|
172 |
af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
876
diff
changeset
|
173 *p = [ window_view convertPoint:*p toView: nil ]; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
174 p->y = [window_view frame].size.height - p->y; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
175 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
176 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
177 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
178 /* Convert Cocoa coordinate to SDL coordinate */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
179 void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
180 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
181 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */ |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
182 |
876
9e84d106ec19
(Said Max Horn on the SDL mailing list...)
Ryan C. Gordon <icculus@icculus.org>
parents:
779
diff
changeset
|
183 p->y = CGDisplayPixelsHigh (display_id) - p->y; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
184 } |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
185 else { |
934
af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
876
diff
changeset
|
186 |
af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents:
876
diff
changeset
|
187 *p = [ window_view convertPoint:*p fromView: nil ]; |
4204
976bc19f8f6b
1.2 Quartz video: Ripped out QuickDraw and QuickTime.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
188 p->y = [window_view frame].size.height - p->y; |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
189 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
190 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
191 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
192 /* Convert SDL coordinate to window server (CoreGraphics) coordinate */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
193 CGPoint QZ_PrivateSDLToCG (_THIS, NSPoint *p) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
194 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
195 CGPoint cgp; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
196 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
197 if ( ! CGDisplayIsCaptured (display_id) ) { /* not captured => not fullscreen => local coord */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
198 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
199 int height; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
200 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
201 QZ_PrivateSDLToCocoa (this, p); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
202 QZ_PrivateLocalToGlobal (this, p); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
203 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
204 height = CGDisplayPixelsHigh (display_id); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
205 p->y = height - p->y; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
206 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
207 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
208 cgp.x = p->x; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
209 cgp.y = p->y; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
210 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
211 return cgp; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
212 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
213 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
214 #if 0 /* Dead code */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
215 /* Convert window server (CoreGraphics) coordinate to SDL coordinate */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
216 void QZ_PrivateCGToSDL (_THIS, NSPoint *p) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
217 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
218 if ( ! CGDisplayIsCaptured (display_id) ) { /* not captured => not fullscreen => local coord */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
219 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
220 int height; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
221 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
222 /* Convert CG Global to Cocoa Global */ |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
223 height = CGDisplayPixelsHigh (display_id); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
224 p->y = height - p->y; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
225 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
226 QZ_PrivateGlobalToLocal (this, p); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
227 QZ_PrivateCocoaToSDL (this, p); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
228 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
229 } |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
230 #endif /* Dead code */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
231 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
232 void QZ_PrivateWarpCursor (_THIS, int x, int y) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
233 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
234 NSPoint p; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
235 CGPoint cgp; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
236 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
237 p = NSMakePoint (x, y); |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
238 cgp = QZ_PrivateSDLToCG (this, &p); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
239 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
240 /* this is the magic call that fixes cursor "freezing" after warp */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
241 CGSetLocalEventsSuppressionInterval (0.0); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
242 CGWarpMouseCursorPosition (cgp); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
243 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
244 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
245 void QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
246 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
247 /* Only allow warping when in foreground */ |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
248 if ( ! [ NSApp isActive ] ) |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
249 return; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
250 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
251 /* Do the actual warp */ |
1207 | 252 if (grab_state != QZ_INVISIBLE_GRAB) QZ_PrivateWarpCursor (this, x, y); |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
253 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
254 /* Generate the mouse moved event */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
255 SDL_PrivateMouseMotion (0, 0, x, y); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
256 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
257 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
258 void QZ_MoveWMCursor (_THIS, int x, int y) { } |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
259 void QZ_CheckMouseMode (_THIS) { } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
260 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
261 void QZ_SetCaption (_THIS, const char *title, const char *icon) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
262 |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
263 if ( qz_window != nil ) { |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
264 NSString *string; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
265 if ( title != NULL ) { |
951
121f56c1277d
Date: Sun, 29 Aug 2004 20:55:54 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
934
diff
changeset
|
266 string = [ [ NSString alloc ] initWithUTF8String:title ]; |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
267 [ qz_window setTitle:string ]; |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
268 [ string release ]; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
269 } |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
270 if ( icon != NULL ) { |
951
121f56c1277d
Date: Sun, 29 Aug 2004 20:55:54 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
934
diff
changeset
|
271 string = [ [ NSString alloc ] initWithUTF8String:icon ]; |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
272 [ qz_window setMiniwindowTitle:string ]; |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
273 [ string release ]; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
274 } |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
275 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
276 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
277 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
278 void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask) |
269
4125b9859c71
Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
279 { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
280 NSBitmapImageRep *imgrep; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
281 NSImage *img; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
282 SDL_Surface *mergedSurface; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
283 NSAutoreleasePool *pool; |
1812 | 284 Uint8 *pixels; |
285 SDL_bool iconSrcAlpha; | |
286 Uint8 iconAlphaValue; | |
287 int i, j, maskPitch, index; | |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
288 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
289 pool = [ [ NSAutoreleasePool alloc ] init ]; |
1812 | 290 |
291 imgrep = [ [ [ NSBitmapImageRep alloc ] initWithBitmapDataPlanes: NULL pixelsWide: icon->w pixelsHigh: icon->h bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES isPlanar: NO colorSpaceName: NSDeviceRGBColorSpace bytesPerRow: 4*icon->w bitsPerPixel: 32 ] autorelease ]; | |
292 if (imgrep == nil) goto freePool; | |
293 pixels = [ imgrep bitmapData ]; | |
294 SDL_memset(pixels, 0, 4*icon->w*icon->h); /* make the background, which will survive in colorkeyed areas, completely transparent */ | |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
295 |
1812 | 296 #if SDL_BYTEORDER == SDL_BIG_ENDIAN |
297 #define BYTEORDER_DEPENDENT_RGBA_MASKS 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF | |
298 #else | |
299 #define BYTEORDER_DEPENDENT_RGBA_MASKS 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 | |
300 #endif | |
301 mergedSurface = SDL_CreateRGBSurfaceFrom(pixels, icon->w, icon->h, 32, 4*icon->w, BYTEORDER_DEPENDENT_RGBA_MASKS); | |
302 if (mergedSurface == NULL) goto freePool; | |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
303 |
1812 | 304 /* blit, with temporarily cleared SRCALPHA flag because we want to copy, not alpha-blend */ |
305 iconSrcAlpha = ((icon->flags & SDL_SRCALPHA) != 0); | |
306 iconAlphaValue = icon->format->alpha; | |
307 SDL_SetAlpha(icon, 0, 255); | |
308 SDL_BlitSurface(icon, NULL, mergedSurface, NULL); | |
309 if (iconSrcAlpha) SDL_SetAlpha(icon, SDL_SRCALPHA, iconAlphaValue); | |
592
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
310 |
1812 | 311 SDL_FreeSurface(mergedSurface); |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
312 |
1812 | 313 /* apply mask, source alpha, and premultiply color values by alpha */ |
314 maskPitch = (icon->w+7)/8; | |
315 for (i = 0; i < icon->h; i++) { | |
316 for (j = 0; j < icon->w; j++) { | |
317 index = i*4*icon->w + j*4; | |
318 if (!(mask[i*maskPitch + j/8] & (128 >> j%8))) { | |
319 pixels[index + 3] = 0; | |
320 } | |
321 else { | |
322 if (iconSrcAlpha) { | |
323 if (icon->format->Amask == 0) pixels[index + 3] = icon->format->alpha; | |
324 } | |
325 else { | |
326 pixels[index + 3] = 255; | |
327 } | |
328 } | |
329 if (pixels[index + 3] < 255) { | |
330 pixels[index + 0] = (Uint16)pixels[index + 0]*pixels[index + 3]/255; | |
331 pixels[index + 1] = (Uint16)pixels[index + 1]*pixels[index + 3]/255; | |
332 pixels[index + 2] = (Uint16)pixels[index + 2]*pixels[index + 3]/255; | |
592
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
333 } |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
334 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
335 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
336 |
1812 | 337 img = [ [ [ NSImage alloc ] initWithSize: NSMakeSize(icon->w, icon->h) ] autorelease ]; |
338 if (img == nil) goto freePool; | |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
339 [ img addRepresentation: imgrep ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
340 [ NSApp setApplicationIconImage:img ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
341 |
269
4125b9859c71
Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
342 freePool: |
1812 | 343 [ pool release ]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
344 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
345 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
346 int QZ_IconifyWindow (_THIS) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
347 |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
348 if ( ! [ qz_window isMiniaturized ] ) { |
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
349 [ qz_window miniaturize:nil ]; |
4122
cb7b118b400a
Fixed return value for iconifying the window in a couple spots.
Sam Lantinga <slouken@libsdl.org>
parents:
4070
diff
changeset
|
350 if ( ! [ qz_window isMiniaturized ] ) { |
cb7b118b400a
Fixed return value for iconifying the window in a couple spots.
Sam Lantinga <slouken@libsdl.org>
parents:
4070
diff
changeset
|
351 SDL_SetError ("window iconification failed"); |
cb7b118b400a
Fixed return value for iconifying the window in a couple spots.
Sam Lantinga <slouken@libsdl.org>
parents:
4070
diff
changeset
|
352 return 0; |
cb7b118b400a
Fixed return value for iconifying the window in a couple spots.
Sam Lantinga <slouken@libsdl.org>
parents:
4070
diff
changeset
|
353 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
354 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
355 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
356 else { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
357 SDL_SetError ("window already iconified"); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
358 return 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
359 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
360 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
361 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
362 /* |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
363 int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info) { |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
364 info->nsWindowPtr = qz_window; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
365 return 0; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
366 }*/ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
367 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
368 void QZ_ChangeGrabState (_THIS, int action) { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
369 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
370 /* |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
371 Figure out what the next state should be based on the action. |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
372 Ignore actions that can't change the current state. |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
373 */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
374 if ( grab_state == QZ_UNGRABBED ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
375 if ( action == QZ_ENABLE_GRAB ) { |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
376 if ( cursor_should_be_visible ) |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
377 grab_state = QZ_VISIBLE_GRAB; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
378 else |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
379 grab_state = QZ_INVISIBLE_GRAB; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
380 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
381 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
382 else if ( grab_state == QZ_VISIBLE_GRAB ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
383 if ( action == QZ_DISABLE_GRAB ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
384 grab_state = QZ_UNGRABBED; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
385 else if ( action == QZ_HIDECURSOR ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
386 grab_state = QZ_INVISIBLE_GRAB; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
387 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
388 else { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
389 assert( grab_state == QZ_INVISIBLE_GRAB ); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
390 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
391 if ( action == QZ_DISABLE_GRAB ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
392 grab_state = QZ_UNGRABBED; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
393 else if ( action == QZ_SHOWCURSOR ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
394 grab_state = QZ_VISIBLE_GRAB; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
395 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
396 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
397 /* now apply the new state */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
398 if (grab_state == QZ_UNGRABBED) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
399 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
400 CGAssociateMouseAndMouseCursorPosition (1); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
401 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
402 else if (grab_state == QZ_VISIBLE_GRAB) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
403 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
404 CGAssociateMouseAndMouseCursorPosition (1); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
405 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
406 else { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
407 assert( grab_state == QZ_INVISIBLE_GRAB ); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
408 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
409 QZ_PrivateWarpCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
410 CGAssociateMouseAndMouseCursorPosition (0); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
411 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
412 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
413 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
414 SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
415 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
416 int doGrab = grab_mode & SDL_GRAB_ON; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
417 /*int fullscreen = grab_mode & SDL_GRAB_FULLSCREEN;*/ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
418 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
419 if ( this->screen == NULL ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
420 SDL_SetError ("QZ_GrabInput: screen is NULL"); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
421 return SDL_GRAB_OFF; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
422 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
423 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
424 if ( ! video_set ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
425 /*SDL_SetError ("QZ_GrabInput: video is not set, grab will take effect on mode switch"); */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
426 current_grab_mode = grab_mode; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
427 return grab_mode; /* Will be set later on mode switch */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
428 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
429 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
430 if ( grab_mode != SDL_GRAB_QUERY ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
431 if ( doGrab ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
432 QZ_ChangeGrabState (this, QZ_ENABLE_GRAB); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
433 else |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
434 QZ_ChangeGrabState (this, QZ_DISABLE_GRAB); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
435 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
436 current_grab_mode = doGrab ? SDL_GRAB_ON : SDL_GRAB_OFF; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
437 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
438 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
439 return current_grab_mode; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
440 } |