comparison src/video/cocoa/SDL_cocoawindow.m @ 4484:9322f7db8603

Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event. Fixed a bug where only mouse wheel up was sent on Mac OS X Fixed a bug where mouse window focus was getting hosed by the fullscreen mouse code on Mac OS X
author Sam Lantinga <slouken@libsdl.org>
date Mon, 05 Jul 2010 22:48:13 -0700
parents 3e69e077cb95
children 3d91e31fcf71
comparison
equal deleted inserted replaced
4483:539f3eca8798 4484:9322f7db8603
169 break; 169 break;
170 default: 170 default:
171 button = [theEvent buttonNumber]; 171 button = [theEvent buttonNumber];
172 break; 172 break;
173 } 173 }
174 SDL_SendMouseButton(SDL_PRESSED, button); 174 SDL_SendMouseButton(_data->window, SDL_PRESSED, button);
175 } 175 }
176 176
177 - (void)rightMouseDown:(NSEvent *)theEvent 177 - (void)rightMouseDown:(NSEvent *)theEvent
178 { 178 {
179 [self mouseDown:theEvent]; 179 [self mouseDown:theEvent];
200 break; 200 break;
201 default: 201 default:
202 button = [theEvent buttonNumber]; 202 button = [theEvent buttonNumber];
203 break; 203 break;
204 } 204 }
205 SDL_SendMouseButton(SDL_RELEASED, button); 205 SDL_SendMouseButton(_data->window, SDL_RELEASED, button);
206 } 206 }
207 207
208 - (void)rightMouseUp:(NSEvent *)theEvent 208 - (void)rightMouseUp:(NSEvent *)theEvent
209 { 209 {
210 [self mouseUp:theEvent]; 210 [self mouseUp:theEvent];
226 point.y < 0 || point.y >= window->h ) { 226 point.y < 0 || point.y >= window->h ) {
227 if (SDL_GetMouseFocus() == window) { 227 if (SDL_GetMouseFocus() == window) {
228 SDL_SetMouseFocus(NULL); 228 SDL_SetMouseFocus(NULL);
229 } 229 }
230 } else { 230 } else {
231 SDL_SetMouseFocus(_data->window); 231 SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y);
232 SDL_SendMouseMotion(0, (int)point.x, (int)point.y);
233 } 232 }
234 } 233 }
235 234
236 - (void)mouseDragged:(NSEvent *)theEvent 235 - (void)mouseDragged:(NSEvent *)theEvent
237 { 236 {
248 [self mouseMoved:theEvent]; 247 [self mouseMoved:theEvent];
249 } 248 }
250 249
251 - (void)scrollWheel:(NSEvent *)theEvent 250 - (void)scrollWheel:(NSEvent *)theEvent
252 { 251 {
253 SDL_SendMouseWheel((int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f)); 252 float x = [theEvent deltaX];
253 float y = [theEvent deltaY];
254
255 if (x > 0) {
256 x += 0.9f;
257 } else if (x < 0) {
258 x -= 0.9f;
259 }
260 if (y > 0) {
261 y += 0.9f;
262 } else if (y < 0) {
263 y -= 0.9f;
264 }
265 SDL_SendMouseWheel(_data->window, (int)x, (int)y);
254 } 266 }
255 267
256 @end 268 @end
257 269
258 @interface SDLWindow : NSWindow 270 @interface SDLWindow : NSWindow