Cocoa: report SDL_WINDOWEVENT_EXPOSED events to the app (thanks, David!). Fixes Bugzilla #2644.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 2576284..2a02041 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -962,14 +962,29 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
@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 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
/* 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:)]) {