Skip to content

Commit

Permalink
Cocoa: report SDL_WINDOWEVENT_EXPOSED events to the app (thanks, Davi…
Browse files Browse the repository at this point in the history
…d!).

Fixes Bugzilla #2644.
  • Loading branch information
icculus committed May 26, 2015
1 parent 22704ac commit bb437f0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -962,14 +962,29 @@ - (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent

@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];
Expand Down Expand Up @@ -1136,7 +1151,8 @@ - (void)resetCursorRects

/* 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:)]) {
Expand Down

0 comments on commit bb437f0

Please sign in to comment.