Commit 82a00575 authored by Sam Lantinga's avatar Sam Lantinga

Tracking rectangles had some problems, it's easier to track things directly. ...

Tracking rectangles had some problems, it's easier to track things directly.  (fixes bug 1149, 1147, 1146)
parent 1a2a914b
...@@ -66,7 +66,6 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -66,7 +66,6 @@ static __inline__ void ConvertNSRect(NSRect *r)
[window setAcceptsMouseMovedEvents:YES]; [window setAcceptsMouseMovedEvents:YES];
[view setNextResponder:self]; [view setNextResponder:self];
[view addTrackingRect:[view visibleRect] owner:self userData:nil assumeInside:NO];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[view setAcceptsTouchEvents:YES]; [view setAcceptsTouchEvents:YES];
#endif #endif
...@@ -152,12 +151,20 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -152,12 +151,20 @@ static __inline__ void ConvertNSRect(NSRect *r)
SDL_SetKeyboardFocus(window); SDL_SetKeyboardFocus(window);
/* If we just gained focus we need the updated mouse position */ /* If we just gained focus we need the updated mouse position */
if (SDL_GetMouseFocus() == window) { {
NSPoint point; NSPoint point;
point = [NSEvent mouseLocation]; int x, y;
point = [_data->nswindow convertScreenToBase:point];
point.y = window->h - point.y; point = [_data->nswindow mouseLocationOutsideOfEventStream];
SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y); x = (int)point.x;
y = (int)(window->h - point.y);
if (x >= 0 && x < window->w && y >= 0 && y < window->h) {
if (SDL_GetMouseFocus() != window) {
[self mouseEntered:nil];
}
SDL_SendMouseMotion(window, 0, x, y);
}
} }
/* Check to see if someone updated the clipboard */ /* Check to see if someone updated the clipboard */
...@@ -288,6 +295,8 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -288,6 +295,8 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)mouseMoved:(NSEvent *)theEvent - (void)mouseMoved:(NSEvent *)theEvent
{ {
SDL_Window *window = _data->window; SDL_Window *window = _data->window;
NSPoint point;
int x, y;
#ifdef RELATIVE_MOTION #ifdef RELATIVE_MOTION
if (window->flags & SDL_WINDOW_INPUT_GRABBED) { if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
...@@ -295,13 +304,19 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -295,13 +304,19 @@ static __inline__ void ConvertNSRect(NSRect *r)
} }
#endif #endif
if (SDL_GetMouseFocus() == window) { point = [theEvent locationInWindow];
NSPoint point; x = (int)point.x;
y = (int)(window->h - point.y);
point = [theEvent locationInWindow];
point.y = window->h - point.y;
SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y); if (x < 0 || x >= window->w || y < 0 || y >= window->h) {
if (SDL_GetMouseFocus() == window) {
[self mouseExited:theEvent];
}
} else {
if (SDL_GetMouseFocus() != window) {
[self mouseEntered:theEvent];
}
SDL_SendMouseMotion(window, 0, x, y);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment