Cocoa: report SDL_WINDOWEVENT_EXPOSED events to the app (thanks, David!).
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 May 2015 11:01:19 -0400
changeset 9623 b381999d8944
parent 9622 fb91c22f656b
child 9624 c5e1c4b7b7a1
Cocoa: report SDL_WINDOWEVENT_EXPOSED events to the app (thanks, David!). Fixes Bugzilla #2644.
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 09:55:41 2015 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 11:01:19 2015 -0400
@@ -962,14 +962,29 @@
 
 @end
 
-@interface SDLView : NSView
+@interface SDLView : NSView {
+    SDL_Window *_sdlWindow;
+}
+
+- (void)setSDLWindow:(SDL_Window*)window;
 
 /* The default implementation doesn't pass rightMouseDown to responder chain */
 - (void)rightMouseDown:(NSEvent *)theEvent;
 - (BOOL)mouseDownCanMoveWindow;
+- (void)drawRect:(NSRect)dirtyRect;
 @end
 
 @implementation SDLView
+- (void)setSDLWindow:(SDL_Window*)window
+{
+    _sdlWindow = window;
+}
+
+- (void)drawRect:(NSRect)dirtyRect
+{
+    SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0);
+}
+
 - (void)rightMouseDown:(NSEvent *)theEvent
 {
     [[self nextResponder] rightMouseDown:theEvent];
@@ -1136,7 +1151,8 @@
 
     /* Create a default view for this window */
     rect = [nswindow contentRectForFrameRect:[nswindow frame]];
-    NSView *contentView = [[SDLView alloc] initWithFrame:rect];
+    SDLView *contentView = [[SDLView alloc] initWithFrame:rect];
+    [contentView setSDLWindow:window];
 
     if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
         if ([contentView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {