comparison src/video/quartz/SDL_QuartzWM.m @ 683:5d2f027b3349

Date: Sat, 9 Aug 2003 20:14:06 -0400 From: Darrell Walisser Subject: Re: Updated projects? >> Did you get a chance to look at my "Custom Cocoa" demo? I have a few >> minor patches that enable SDL/Cocoa integration, and a project >> template. > > I didn't yet, but go ahead and send me the patches. :) > I updated the patch for current CVS. There are a lot of changes, but I don't think I've broken anything. This patch also improves the behavior of window minimize/deminimize.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 10 Aug 2003 07:21:43 +0000
parents 7ec821f3cbd0
children c5b2b6d2d1fe
comparison
equal deleted inserted replaced
682:8b2b97e466bc 683:5d2f027b3349
117 } 117 }
118 118
119 /* Convert SDL coordinate to Cocoa coordinate */ 119 /* Convert SDL coordinate to Cocoa coordinate */
120 static void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) { 120 static void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) {
121 121
122 int height;
123
124 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */ 122 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */
125 123
126 height = CGDisplayPixelsHigh (display_id); 124 p->y = CGDisplayPixelsHigh (display_id) - p->y - 1;
127 } 125 }
128 else { 126 else {
129 127
130 height = NSHeight ( [ qz_window frame ] ); 128 NSPoint newPoint;
131 if ( [ qz_window styleMask ] & NSTitledWindowMask ) { 129
132 130 newPoint = [ window_view convertPoint:*p toView:[ qz_window contentView ] ];
133 height -= 22; 131
134 } 132 *p = newPoint;
135 } 133 }
136
137 p->y = height - p->y - 1;
138 } 134 }
139 135
140 /* Convert Cocoa coordinate to SDL coordinate */ 136 /* Convert Cocoa coordinate to SDL coordinate */
141 static void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) { 137 static void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) {
142 138
143 QZ_PrivateSDLToCocoa (this, p); 139 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */
140
141 p->y = CGDisplayPixelsHigh (display_id) - p->y - 1;
142 }
143 else {
144
145 NSPoint newPoint;
146
147 newPoint = [ window_view convertPoint:*p fromView:[ qz_window contentView ] ];
148
149 *p = newPoint;
150 }
144 } 151 }
145 152
146 /* Convert SDL coordinate to window server (CoreGraphics) coordinate */ 153 /* Convert SDL coordinate to window server (CoreGraphics) coordinate */
147 static CGPoint QZ_PrivateSDLToCG (_THIS, NSPoint *p) { 154 static CGPoint QZ_PrivateSDLToCG (_THIS, NSPoint *p) {
148 155
163 cgp.y = p->y; 170 cgp.y = p->y;
164 171
165 return cgp; 172 return cgp;
166 } 173 }
167 174
175 #if 0 /* Dead code */
168 /* Convert window server (CoreGraphics) coordinate to SDL coordinate */ 176 /* Convert window server (CoreGraphics) coordinate to SDL coordinate */
169 static void QZ_PrivateCGToSDL (_THIS, NSPoint *p) { 177 static void QZ_PrivateCGToSDL (_THIS, NSPoint *p) {
170 178
171 if ( ! CGDisplayIsCaptured (display_id) ) { /* not captured => not fullscreen => local coord */ 179 if ( ! CGDisplayIsCaptured (display_id) ) { /* not captured => not fullscreen => local coord */
172 180
178 186
179 QZ_PrivateGlobalToLocal (this, p); 187 QZ_PrivateGlobalToLocal (this, p);
180 QZ_PrivateCocoaToSDL (this, p); 188 QZ_PrivateCocoaToSDL (this, p);
181 } 189 }
182 } 190 }
191 #endif /* Dead code */
183 192
184 static void QZ_PrivateWarpCursor (_THIS, int x, int y) { 193 static void QZ_PrivateWarpCursor (_THIS, int x, int y) {
185 194
186 NSPoint p; 195 NSPoint p;
187 CGPoint cgp; 196 CGPoint cgp;
188 197
189 p = NSMakePoint (x, y); 198 p = NSMakePoint (x, y);
190 cgp = QZ_PrivateSDLToCG (this, &p); 199 cgp = QZ_PrivateSDLToCG (this, &p);
191 QZ_PrivateCGToSDL (this, &p);
192 200
193 /* this is the magic call that fixes cursor "freezing" after warp */ 201 /* this is the magic call that fixes cursor "freezing" after warp */
194 CGSetLocalEventsSuppressionInterval (0.0); 202 CGSetLocalEventsSuppressionInterval (0.0);
195 CGWarpMouseCursorPosition (cgp); 203 CGWarpMouseCursorPosition (cgp);
196 } 204 }