|
@@ -27,7 +27,9 @@
|
|
|
|
|
|
#include "../../events/SDL_mouse_c.h"
|
|
|
|
|
|
-// #define DEBUG_COCOAMOUSE
|
|
|
+#if 0
|
|
|
+#define DEBUG_COCOAMOUSE
|
|
|
+#endif
|
|
|
|
|
|
#ifdef DEBUG_COCOAMOUSE
|
|
|
#define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__)
|
|
@@ -230,11 +232,11 @@ static bool Cocoa_ShowCursor(SDL_Cursor *cursor)
|
|
|
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
|
|
SDL_Window *window = (device ? device->windows : NULL);
|
|
|
for (; window != NULL; window = window->next) {
|
|
|
- SDL_CocoaWindowData *internal = (__bridge SDL_CocoaWindowData *)window->internal;
|
|
|
- if (internal) {
|
|
|
- [internal.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
|
|
|
- withObject:[internal.nswindow contentView]
|
|
|
- waitUntilDone:NO];
|
|
|
+ SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
|
|
|
+ if (data) {
|
|
|
+ [data.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
|
|
|
+ withObject:[data.nswindow contentView]
|
|
|
+ waitUntilDone:NO];
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -428,6 +430,13 @@ static void Cocoa_HandleTitleButtonEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static NSWindow *Cocoa_MouseFocus;
|
|
|
+
|
|
|
+NSWindow *Cocoa_GetMouseFocus()
|
|
|
+{
|
|
|
+ return Cocoa_MouseFocus;
|
|
|
+}
|
|
|
+
|
|
|
void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|
|
{
|
|
|
SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID;
|
|
@@ -437,7 +446,14 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
|
|
|
CGFloat lastMoveX, lastMoveY;
|
|
|
float deltaX, deltaY;
|
|
|
bool seenWarp;
|
|
|
+
|
|
|
switch ([event type]) {
|
|
|
+ case NSEventTypeMouseEntered:
|
|
|
+ Cocoa_MouseFocus = [event window];
|
|
|
+ return;
|
|
|
+ case NSEventTypeMouseExited:
|
|
|
+ Cocoa_MouseFocus = NULL;
|
|
|
+ return;
|
|
|
case NSEventTypeMouseMoved:
|
|
|
case NSEventTypeLeftMouseDragged:
|
|
|
case NSEventTypeRightMouseDragged:
|