Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed bug 2240 - On OS/X after calling SDL_SetWindowBordered right mo…
…use clicks no longer register

philhassey

On OS/X after calling SDL_SetWindowBordered right mouse clicks no longer register.

Steps to Reproduce:

1. Open a windowed window on OS/X.  (With the border on.)

2. e.button.button will give values 1,2,3 depending on which mouse button I click.

3. Call SDL_SetWindowBordered to disable the border.

4. e.button.button will only give values 1,2.  3 (right mouse button) stops coming through.

Expected result:

I expect all mouse buttons to register.
  • Loading branch information
slouken committed Nov 15, 2013
1 parent ef97aab commit 4295a92
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -88,6 +88,31 @@ static void ConvertNSRect(NSRect *r)
return style;
}

static SDL_bool
SetWindowStyle(SDL_Window * window, unsigned int style)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = data->nswindow;

if (![nswindow respondsToSelector: @selector(setStyleMask:)]) {
return SDL_FALSE;
}

/* The view responder chain gets messed with during setStyleMask */
if ([[nswindow contentView] nextResponder] == data->listener) {
[[nswindow contentView] setNextResponder:nil];
}

[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)style];

/* The view responder chain gets messed with during setStyleMask */
if ([[nswindow contentView] nextResponder] != data->listener) {
[[nswindow contentView] setNextResponder:data->listener];
}

return SDL_TRUE;
}


@implementation Cocoa_WindowListener

Expand Down Expand Up @@ -422,10 +447,9 @@ - (void)windowDidResignKey:(NSNotification *)aNotification
- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
NSWindow *nswindow = _data->nswindow;

window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
[nswindow setStyleMask:(NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask)];
SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));

isFullscreenSpace = YES;
inFullscreenTransition = YES;
Expand Down Expand Up @@ -454,10 +478,9 @@ - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
- (void)windowWillExitFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
NSWindow *nswindow = _data->nswindow;

window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
[nswindow setStyleMask:GetWindowStyle(window)];
SetWindowStyle(window, GetWindowStyle(window));

isFullscreenSpace = NO;
inFullscreenTransition = YES;
Expand Down Expand Up @@ -1173,9 +1196,7 @@ - (void)resetCursorRects
Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
[nswindow setStyleMask:GetWindowStyle(window)];
if (SetWindowStyle(window, GetWindowStyle(window))) {
if (bordered) {
Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */
}
Expand Down

0 comments on commit 4295a92

Please sign in to comment.