src/video/cocoa/SDL_cocoawindow.m
author Sam Lantinga <slouken@libsdl.org>
Wed, 02 Dec 2009 07:25:06 +0000
changeset 3509 8fde6aeb58df
parent 3508 a12068b6f44f
child 3517 e7eec78e4b92
permissions -rw-r--r--
Changed so that it's obvious that the two code blocks are related.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_syswm.h"
    25 #include "../SDL_sysvideo.h"
    26 #include "../../events/SDL_keyboard_c.h"
    27 #include "../../events/SDL_mouse_c.h"
    28 #include "../../events/SDL_windowevents_c.h"
    29 
    30 #include "SDL_cocoavideo.h"
    31 
    32 static __inline__ void ConvertNSRect(NSRect *r)
    33 {
    34     r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
    35 }
    36 
    37 @implementation Cocoa_WindowListener
    38 
    39 - (void)listen:(SDL_WindowData *)data
    40 {
    41     NSNotificationCenter *center;
    42 
    43     _data = data;
    44 
    45     center = [NSNotificationCenter defaultCenter];
    46 
    47     [_data->window setNextResponder:self];
    48     if ([_data->window delegate] != nil) {
    49         [center addObserver:self selector:@selector(windowDisExpose:) name:NSWindowDidExposeNotification object:_data->window];
    50         [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:_data->window];
    51         [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:_data->window];
    52         [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:_data->window];
    53         [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:_data->window];
    54         [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:_data->window];
    55         [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:_data->window];
    56     } else {
    57         [_data->window setDelegate:self];
    58     }
    59     [center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp];
    60     [center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];
    61 
    62     [_data->window setAcceptsMouseMovedEvents:YES];
    63 }
    64 
    65 - (void)close
    66 {
    67     NSNotificationCenter *center;
    68 
    69     center = [NSNotificationCenter defaultCenter];
    70 
    71     [_data->window setNextResponder:nil];
    72     if ([_data->window delegate] != self) {
    73         [center removeObserver:self name:NSWindowDidExposeNotification object:_data->window];
    74         [center removeObserver:self name:NSWindowDidMoveNotification object:_data->window];
    75         [center removeObserver:self name:NSWindowDidResizeNotification object:_data->window];
    76         [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:_data->window];
    77         [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:_data->window];
    78         [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:_data->window];
    79         [center removeObserver:self name:NSWindowDidResignKeyNotification object:_data->window];
    80     } else {
    81         [_data->window setDelegate:nil];
    82     }
    83     [center removeObserver:self name:NSApplicationDidHideNotification object:NSApp];
    84     [center removeObserver:self name:NSApplicationDidUnhideNotification object:NSApp];
    85 }
    86 
    87 - (BOOL)windowShouldClose:(id)sender
    88 {
    89     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0);
    90     return NO;
    91 }
    92 
    93 - (void)windowDidExpose:(NSNotification *)aNotification
    94 {
    95     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_EXPOSED, 0, 0);
    96 }
    97 
    98 - (void)windowDidMove:(NSNotification *)aNotification
    99 {
   100     int x, y;
   101     NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]];
   102     ConvertNSRect(&rect);
   103     x = (int)rect.origin.x;
   104     y = (int)rect.origin.y;
   105     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MOVED, x, y);
   106 }
   107 
   108 - (void)windowDidResize:(NSNotification *)aNotification
   109 {
   110     int w, h;
   111     NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]];
   112     w = (int)rect.size.width;
   113     h = (int)rect.size.height;
   114     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_RESIZED, w, h);
   115 }
   116 
   117 - (void)windowDidMiniaturize:(NSNotification *)aNotification
   118 {
   119     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
   120 }
   121 
   122 - (void)windowDidDeminiaturize:(NSNotification *)aNotification
   123 {
   124     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_RESTORED, 0, 0);
   125 }
   126 
   127 - (void)windowDidBecomeKey:(NSNotification *)aNotification
   128 {
   129     int index;
   130 
   131     /* We're going to get keyboard events, since we're key. */
   132     index = _data->videodata->keyboard;
   133     SDL_SetKeyboardFocus(index, _data->windowID);
   134 }
   135 
   136 - (void)windowDidResignKey:(NSNotification *)aNotification
   137 {
   138     int index;
   139     SDL_Mouse *mouse;
   140 
   141     /* Some other window will get mouse events, since we're not key. */
   142     index = _data->videodata->mouse;
   143     mouse = SDL_GetMouse(index);
   144     if (mouse->focus == _data->windowID) {
   145         SDL_SetMouseFocus(index, 0);
   146     }
   147 
   148     /* Some other window will get keyboard events, since we're not key. */
   149     index = _data->videodata->keyboard;
   150     SDL_SetKeyboardFocus(index, 0);
   151 }
   152 
   153 - (void)windowDidHide:(NSNotification *)aNotification
   154 {
   155     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 0);
   156 }
   157 
   158 - (void)windowDidUnhide:(NSNotification *)aNotification
   159 {
   160     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 0);
   161 }
   162 
   163 - (void)mouseDown:(NSEvent *)theEvent
   164 {
   165     int index;
   166     int button;
   167 
   168     index = _data->videodata->mouse;
   169     switch ([theEvent buttonNumber]) {
   170     case 0:
   171         button = SDL_BUTTON_LEFT;
   172         break;
   173     case 1:
   174         button = SDL_BUTTON_RIGHT;
   175         break;
   176     case 2:
   177         button = SDL_BUTTON_MIDDLE;
   178         break;
   179     default:
   180         button = [theEvent buttonNumber];
   181         break;
   182     }
   183     SDL_SendMouseButton(index, SDL_PRESSED, button);
   184 }
   185 
   186 - (void)rightMouseDown:(NSEvent *)theEvent
   187 {
   188     [self mouseDown:theEvent];
   189 }
   190 
   191 - (void)otherMouseDown:(NSEvent *)theEvent
   192 {
   193     [self mouseDown:theEvent];
   194 }
   195 
   196 - (void)mouseUp:(NSEvent *)theEvent
   197 {
   198     int index;
   199     int button;
   200 
   201     index = _data->videodata->mouse;
   202     switch ([theEvent buttonNumber]) {
   203     case 0:
   204         button = SDL_BUTTON_LEFT;
   205         break;
   206     case 1:
   207         button = SDL_BUTTON_RIGHT;
   208         break;
   209     case 2:
   210         button = SDL_BUTTON_MIDDLE;
   211         break;
   212     default:
   213         button = [theEvent buttonNumber];
   214         break;
   215     }
   216     SDL_SendMouseButton(index, SDL_RELEASED, button);
   217 }
   218 
   219 - (void)rightMouseUp:(NSEvent *)theEvent
   220 {
   221     [self mouseUp:theEvent];
   222 }
   223 
   224 - (void)otherMouseUp:(NSEvent *)theEvent
   225 {
   226     [self mouseUp:theEvent];
   227 }
   228 
   229 - (void)mouseMoved:(NSEvent *)theEvent
   230 {
   231     SDL_Window *window = SDL_GetWindowFromID(_data->windowID);
   232     int index;
   233     SDL_Mouse *mouse;
   234     NSPoint point;
   235 
   236     index = _data->videodata->mouse;
   237     mouse = SDL_GetMouse(index);
   238 
   239     point = [NSEvent mouseLocation];
   240     if ( (window->flags & SDL_WINDOW_FULLSCREEN) ) {
   241         NSRect rect = CGDisplayBounds(_data->display);
   242 
   243         point.x = point.x - rect.origin.x;
   244         point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - rect.origin.y;
   245     } else {
   246         point.x = point.x - window->x;
   247         point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - window->y;
   248     }
   249     if ( point.x < 0 || point.x >= window->w ||
   250          point.y < 0 || point.y >= window->h ) {
   251         if (mouse->focus != 0) {
   252             SDL_SetMouseFocus(index, 0);
   253         }
   254     } else {
   255         if (mouse->focus != _data->windowID) {
   256             SDL_SetMouseFocus(index, _data->windowID);
   257         }
   258         SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0);
   259     }
   260 }
   261 
   262 - (void)mouseDragged:(NSEvent *)theEvent
   263 {
   264     [self mouseMoved:theEvent];
   265 }
   266 
   267 - (void)rightMouseDragged:(NSEvent *)theEvent
   268 {
   269     [self mouseMoved:theEvent];
   270 }
   271 
   272 - (void)otherMouseDragged:(NSEvent *)theEvent
   273 {
   274     [self mouseMoved:theEvent];
   275 }
   276 
   277 - (void)scrollWheel:(NSEvent *)theEvent
   278 {
   279     int index;
   280 
   281     index = _data->videodata->mouse;
   282     SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
   283 }
   284 
   285 @end
   286 
   287 @interface SDLWindow : NSWindow
   288 /* These are needed for borderless/fullscreen windows */
   289 - (BOOL)canBecomeKeyWindow;
   290 - (BOOL)canBecomeMainWindow;
   291 @end
   292 
   293 @implementation SDLWindow
   294 - (BOOL)canBecomeKeyWindow
   295 {
   296     return YES;
   297 }
   298 
   299 - (BOOL)canBecomeMainWindow
   300 {
   301     return YES;
   302 }
   303 @end
   304 
   305 static int
   306 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
   307 {
   308     NSAutoreleasePool *pool;
   309     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   310     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   311     SDL_WindowData *data;
   312 
   313     /* Allocate the window data */
   314     data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
   315     if (!data) {
   316         SDL_OutOfMemory();
   317         return -1;
   318     }
   319     data->windowID = window->id;
   320     data->window = nswindow;
   321     data->created = created;
   322     data->display = displaydata->display;
   323     data->videodata = videodata;
   324 
   325     pool = [[NSAutoreleasePool alloc] init];
   326 
   327     /* Create an event listener for the window */
   328     data->listener = [[Cocoa_WindowListener alloc] init];
   329     [data->listener listen:data];
   330 
   331     /* Fill in the SDL window with the window data */
   332     {
   333         NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
   334         ConvertNSRect(&rect);
   335         window->x = (int)rect.origin.x;
   336         window->y = (int)rect.origin.y;
   337         window->w = (int)rect.size.width;
   338         window->h = (int)rect.size.height;
   339     }
   340     if ([nswindow isVisible]) {
   341         window->flags |= SDL_WINDOW_SHOWN;
   342     } else {
   343         window->flags &= ~SDL_WINDOW_SHOWN;
   344     }
   345     {
   346         unsigned int style = [nswindow styleMask];
   347 
   348         if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
   349             window->flags |= SDL_WINDOW_BORDERLESS;
   350         } else {
   351             window->flags &= ~SDL_WINDOW_BORDERLESS;
   352         }
   353         if (style & NSResizableWindowMask) {
   354             window->flags |= SDL_WINDOW_RESIZABLE;
   355         } else {
   356             window->flags &= ~SDL_WINDOW_RESIZABLE;
   357         }
   358     }
   359     if ([nswindow isZoomed]) {
   360         window->flags |= SDL_WINDOW_MAXIMIZED;
   361     } else {
   362         window->flags &= ~SDL_WINDOW_MAXIMIZED;
   363     }
   364     if ([nswindow isMiniaturized]) {
   365         window->flags |= SDL_WINDOW_MINIMIZED;
   366     } else {
   367         window->flags &= ~SDL_WINDOW_MINIMIZED;
   368     }
   369     if ([nswindow isKeyWindow]) {
   370         int index = data->videodata->keyboard;
   371         window->flags |= SDL_WINDOW_INPUT_FOCUS;
   372         SDL_SetKeyboardFocus(index, data->windowID);
   373 
   374         if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   375             /* FIXME */
   376         }
   377     }
   378 
   379     /* All done! */
   380     [pool release];
   381     window->driverdata = data;
   382     return 0;
   383 }
   384 
   385 int
   386 Cocoa_CreateWindow(_THIS, SDL_Window * window)
   387 {
   388     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   389     NSWindow *nswindow;
   390     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   391     NSRect rect;
   392     unsigned int style;
   393     NSString *title;
   394     int status;
   395 
   396     rect = CGDisplayBounds(displaydata->display);
   397     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   398         || window->x == SDL_WINDOWPOS_CENTERED) {
   399         rect.origin.x += (rect.size.width - window->w) / 2;
   400     } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
   401         rect.origin.x = window->x;
   402     }
   403     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   404         || window->y == SDL_WINDOWPOS_CENTERED) {
   405         rect.origin.y += (rect.size.height - window->h) / 2;
   406     } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
   407         rect.origin.y = window->y;
   408     }
   409     rect.size.width = window->w;
   410     rect.size.height = window->h;
   411     ConvertNSRect(&rect);
   412 
   413     if (window->flags & SDL_WINDOW_BORDERLESS) {
   414         style = NSBorderlessWindowMask;
   415     } else {
   416         style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
   417     }
   418     if (window->flags & SDL_WINDOW_RESIZABLE) {
   419         style |= NSResizableWindowMask;
   420     }
   421 
   422     /* Figure out which screen to place this window */
   423     NSArray *screens = [NSScreen screens];
   424     NSScreen *screen = nil;
   425     NSScreen *candidate;
   426     for (candidate in screens) {
   427         NSRect screenRect = [candidate frame];
   428         if (rect.origin.x >= screenRect.origin.x &&
   429             rect.origin.x < screenRect.origin.x + screenRect.size.width &&
   430             rect.origin.y >= screenRect.origin.y &&
   431             rect.origin.y < screenRect.origin.y + screenRect.size.height) {
   432             screen = candidate;
   433             rect.origin.x -= screenRect.origin.x;
   434             rect.origin.y -= screenRect.origin.y;
   435         }
   436     }
   437     nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE screen:screen];
   438 
   439     [pool release];
   440 
   441     if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
   442         [nswindow release];
   443         return -1;
   444     }
   445     return 0;
   446 }
   447 
   448 int
   449 Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   450 {
   451     NSAutoreleasePool *pool;
   452     NSWindow *nswindow = (NSWindow *) data;
   453     NSString *title;
   454     int status;
   455 
   456     pool = [[NSAutoreleasePool alloc] init];
   457 
   458     /* Query the title from the existing window */
   459     title = [nswindow title];
   460     if (title) {
   461         window->title = SDL_strdup([title UTF8String]);
   462     }
   463 
   464     [pool release];
   465 
   466     return SetupWindowData(_this, window, nswindow, SDL_FALSE);
   467 }
   468 
   469 void
   470 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
   471 {
   472     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   473     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   474     NSString *string;
   475 
   476     if(window->title) {
   477         string = [[NSString alloc] initWithUTF8String:window->title];
   478     } else {
   479         string = [[NSString alloc] init];
   480     }
   481     [nswindow setTitle:string];
   482     [string release];
   483 
   484     [pool release];
   485 }
   486 
   487 void
   488 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   489 {
   490     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   491     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   492     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   493     NSRect rect;
   494 
   495     rect = CGDisplayBounds(displaydata->display);
   496     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   497         || window->x == SDL_WINDOWPOS_CENTERED) {
   498         rect.origin.x += (rect.size.width - window->w) / 2;
   499     } else {
   500         rect.origin.x = window->x;
   501     }
   502     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   503         || window->y == SDL_WINDOWPOS_CENTERED) {
   504         rect.origin.y += (rect.size.height - window->h) / 2;
   505     } else {
   506         rect.origin.y = window->y;
   507     }
   508     rect.size.width = window->w;
   509     rect.size.height = window->h;
   510     ConvertNSRect(&rect);
   511     rect = [nswindow frameRectForContentRect:rect];
   512     [nswindow setFrameOrigin:rect.origin];
   513     [pool release];
   514 }
   515 
   516 void
   517 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   518 {
   519     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   520     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   521     NSSize size;
   522 
   523     size.width = window->w;
   524     size.height = window->h;
   525     [nswindow setContentSize:size];
   526     [pool release];
   527 }
   528 
   529 void
   530 Cocoa_ShowWindow(_THIS, SDL_Window * window)
   531 {
   532     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   533     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   534 
   535     if (![nswindow isMiniaturized]) {
   536         [nswindow makeKeyAndOrderFront:nil];
   537     }
   538     [pool release];
   539 }
   540 
   541 void
   542 Cocoa_HideWindow(_THIS, SDL_Window * window)
   543 {
   544     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   545     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   546 
   547     [nswindow orderOut:nil];
   548     [pool release];
   549 }
   550 
   551 void
   552 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
   553 {
   554     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   555     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   556 
   557     [nswindow makeKeyAndOrderFront:nil];
   558     [pool release];
   559 }
   560 
   561 void
   562 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
   563 {
   564     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   565     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   566 
   567     [nswindow zoom:nil];
   568     [pool release];
   569 }
   570 
   571 void
   572 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
   573 {
   574     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   575     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   576 
   577     [nswindow miniaturize:nil];
   578     [pool release];
   579 }
   580 
   581 void
   582 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   583 {
   584     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   585     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   586 
   587     if ([nswindow isMiniaturized]) {
   588         [nswindow deminiaturize:nil];
   589     } else if ([nswindow isZoomed]) {
   590         [nswindow zoom:nil];
   591     }
   592     [pool release];
   593 }
   594 
   595 void
   596 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
   597 {
   598     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
   599         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   600         /* FIXME: Grab mouse */
   601     } else {
   602         /* FIXME: Release mouse */
   603     }
   604 }
   605 
   606 void
   607 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
   608 {
   609     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   610     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   611 
   612     if (data) {
   613         [data->listener close];
   614         [data->listener release];
   615         if (data->created) {
   616             [data->window close];
   617         }
   618         SDL_free(data);
   619     }
   620     [pool release];
   621 }
   622 
   623 SDL_bool
   624 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   625 {
   626     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   627 
   628     if (info->version.major <= SDL_MAJOR_VERSION) {
   629         //info->window = nswindow;
   630         return SDL_TRUE;
   631     } else {
   632         SDL_SetError("Application not compiled with SDL %d.%d\n",
   633                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   634         return SDL_FALSE;
   635     }
   636 }
   637 
   638 /* vi: set ts=4 sw=4 expandtab: */