mirror of https://github.com/encounter/SDL.git
cocoa: Patched to compile and also handle possible malloc failure.
This commit is contained in:
parent
3e720d2a80
commit
d3bedda4df
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "SDL_cocoavideo.h"
|
#include "SDL_cocoavideo.h"
|
||||||
|
|
||||||
extern void Cocoa_InitMouse(_THIS);
|
extern int Cocoa_InitMouse(_THIS);
|
||||||
extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event);
|
extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event);
|
||||||
extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event);
|
extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event);
|
||||||
extern void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y);
|
extern void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y);
|
||||||
|
|
|
@ -327,13 +327,16 @@ Cocoa_GetGlobalMouseState(int *x, int *y)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
Cocoa_InitMouse(_THIS)
|
Cocoa_InitMouse(_THIS)
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
SDL_MouseData *driverdata = (SDL_MouseData*) SDL_calloc(1, sizeof(SDL_MouseData));
|
||||||
|
if (driverdata == NULL) {
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
}
|
||||||
|
|
||||||
mouse->driverdata = SDL_calloc(1, sizeof(SDL_MouseData));
|
mouse->driverdata = driverdata;
|
||||||
|
|
||||||
mouse->CreateCursor = Cocoa_CreateCursor;
|
mouse->CreateCursor = Cocoa_CreateCursor;
|
||||||
mouse->CreateSystemCursor = Cocoa_CreateSystemCursor;
|
mouse->CreateSystemCursor = Cocoa_CreateSystemCursor;
|
||||||
mouse->ShowCursor = Cocoa_ShowCursor;
|
mouse->ShowCursor = Cocoa_ShowCursor;
|
||||||
|
@ -346,11 +349,12 @@ Cocoa_InitMouse(_THIS)
|
||||||
|
|
||||||
SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor());
|
SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor());
|
||||||
|
|
||||||
Cocoa_InitMouseEventTap(mouse->driverdata);
|
Cocoa_InitMouseEventTap(driverdata);
|
||||||
|
|
||||||
const NSPoint location = [NSEvent mouseLocation];
|
const NSPoint location = [NSEvent mouseLocation];
|
||||||
mouse->driverdata->lastMoveX = location.x;
|
driverdata->lastMoveX = location.x;
|
||||||
mouse->driverdata->lastMoveY = location.y;
|
driverdata->lastMoveY = location.y;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -168,7 +168,9 @@ Cocoa_VideoInit(_THIS)
|
||||||
|
|
||||||
Cocoa_InitModes(_this);
|
Cocoa_InitModes(_this);
|
||||||
Cocoa_InitKeyboard(_this);
|
Cocoa_InitKeyboard(_this);
|
||||||
Cocoa_InitMouse(_this);
|
if (Cocoa_InitMouse(_this) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
|
data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue