diff options
Diffstat (limited to 'Source/3rdParty/SDL2/src/video/cocoa/SDL_cocoawindow.m')
-rw-r--r-- | Source/3rdParty/SDL2/src/video/cocoa/SDL_cocoawindow.m | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/Source/3rdParty/SDL2/src/video/cocoa/SDL_cocoawindow.m b/Source/3rdParty/SDL2/src/video/cocoa/SDL_cocoawindow.m index b1a5b46..a8e95cc 100644 --- a/Source/3rdParty/SDL2/src/video/cocoa/SDL_cocoawindow.m +++ b/Source/3rdParty/SDL2/src/video/cocoa/SDL_cocoawindow.m @@ -241,7 +241,7 @@ ScheduleContextUpdates(SDL_WindowData *data) static int GetHintCtrlClickEmulateRightClick() { - return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); } static NSUInteger @@ -908,7 +908,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) switch ([theEvent buttonNumber]) { case 0: if (([theEvent modifierFlags] & NSEventModifierFlagControl) && - GetHintCtrlClickEmulateRightClick()) { + GetHintCtrlClickEmulateRightClick()) { wasCtrlLeft = YES; button = SDL_BUTTON_RIGHT; } else { @@ -1143,14 +1143,18 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) - (BOOL)mouseDownCanMoveWindow; - (void)drawRect:(NSRect)dirtyRect; - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent; +- (BOOL)wantsUpdateLayer; +- (void)updateLayer; @end @implementation SDLView + - (void)setSDLWindow:(SDL_Window*)window { _sdlWindow = window; } +/* this is used on older macOS revisions. 10.8 and later use updateLayer. */ - (void)drawRect:(NSRect)dirtyRect { /* Force the graphics context to clear to black so we don't get a flash of @@ -1161,6 +1165,21 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0); } +-(BOOL) wantsUpdateLayer +{ + return YES; +} + +-(void) updateLayer +{ + /* Force the graphics context to clear to black so we don't get a flash of + white until the app is ready to draw. In practice on modern macOS, this + only gets called for window creation and other extraordinary events. */ + self.layer.backgroundColor = NSColor.blackColor.CGColor; + ScheduleContextUpdates((SDL_WindowData *) _sdlWindow->driverdata); + SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0); +} + - (void)rightMouseDown:(NSEvent *)theEvent { [[self nextResponder] rightMouseDown:theEvent]; @@ -1343,6 +1362,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) [contentView setWantsBestResolutionOpenGLSurface:YES]; } } + #if SDL_VIDEO_OPENGL_ES2 #if SDL_VIDEO_OPENGL_EGL if ((window->flags & SDL_WINDOW_OPENGL) && @@ -1354,9 +1374,6 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) [nswindow setContentView:contentView]; [contentView release]; - /* Allow files and folders to be dragged onto the window by users */ - [nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]]; - if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) { [nswindow release]; return -1; @@ -1864,6 +1881,17 @@ Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled) return 0; /* just succeed, the real work is done elsewhere. */ } +void +Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + if (accept) { + [data->nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]]; + } else { + [data->nswindow unregisterDraggedTypes]; + } +} + int Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity) { |