src/video/cocoa/SDL_cocoawindow.m
author Sam Lantinga <slouken@libsdl.org>
Thu, 21 Jan 2010 06:21:52 +0000
changeset 3685 64ce267332c6
parent 3530 e96be66e3673
child 3688 6512cba48440
permissions -rw-r--r--
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
     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->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
    90     return NO;
    91 }
    92 
    93 - (void)windowDidExpose:(NSNotification *)aNotification
    94 {
    95     SDL_SendWindowEvent(_data->window, 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->window, 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->window, SDL_WINDOWEVENT_RESIZED, w, h);
   115 }
   116 
   117 - (void)windowDidMiniaturize:(NSNotification *)aNotification
   118 {
   119     SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
   120 }
   121 
   122 - (void)windowDidDeminiaturize:(NSNotification *)aNotification
   123 {
   124     SDL_SendWindowEvent(_data->window, 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->window);
   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->window) {
   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->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
   156 }
   157 
   158 - (void)windowDidUnhide:(NSNotification *)aNotification
   159 {
   160     SDL_SendWindowEvent(_data->window, 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 = _data->window;
   232     int index;
   233     SDL_Mouse *mouse;
   234     NSPoint point;
   235 
   236     index = _data->videodata->mouse;
   237     mouse = SDL_GetMouse(index);
   238     point = [theEvent locationInWindow];
   239     point.y = window->h - point.y;
   240     if ( point.x < 0 || point.x >= window->w ||
   241          point.y < 0 || point.y >= window->h ) {
   242         if (mouse->focus != 0) {
   243             SDL_SetMouseFocus(index, 0);
   244         }
   245     } else {
   246         if (mouse->focus != _data->window) {
   247             SDL_SetMouseFocus(index, _data->window);
   248         }
   249         SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0);
   250     }
   251 }
   252 
   253 - (void)mouseDragged:(NSEvent *)theEvent
   254 {
   255     [self mouseMoved:theEvent];
   256 }
   257 
   258 - (void)rightMouseDragged:(NSEvent *)theEvent
   259 {
   260     [self mouseMoved:theEvent];
   261 }
   262 
   263 - (void)otherMouseDragged:(NSEvent *)theEvent
   264 {
   265     [self mouseMoved:theEvent];
   266 }
   267 
   268 - (void)scrollWheel:(NSEvent *)theEvent
   269 {
   270     int index;
   271 
   272     index = _data->videodata->mouse;
   273     SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
   274 }
   275 
   276 @end
   277 
   278 @interface SDLWindow : NSWindow
   279 /* These are needed for borderless/fullscreen windows */
   280 - (BOOL)canBecomeKeyWindow;
   281 - (BOOL)canBecomeMainWindow;
   282 @end
   283 
   284 @implementation SDLWindow
   285 - (BOOL)canBecomeKeyWindow
   286 {
   287     return YES;
   288 }
   289 
   290 - (BOOL)canBecomeMainWindow
   291 {
   292     return YES;
   293 }
   294 @end
   295 
   296 static int
   297 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
   298 {
   299     NSAutoreleasePool *pool;
   300     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   301     SDL_VideoDisplay *display = window->display;
   302     SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
   303     SDL_WindowData *data;
   304 
   305     /* Allocate the window data */
   306     data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
   307     if (!data) {
   308         SDL_OutOfMemory();
   309         return -1;
   310     }
   311     data->window = window;
   312     data->window = nswindow;
   313     data->created = created;
   314     data->display = displaydata->display;
   315     data->videodata = videodata;
   316 
   317     pool = [[NSAutoreleasePool alloc] init];
   318 
   319     /* Create an event listener for the window */
   320     data->listener = [[Cocoa_WindowListener alloc] init];
   321     [data->listener listen:data];
   322 
   323     /* Fill in the SDL window with the window data */
   324     {
   325         SDL_Rect bounds;
   326         NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
   327         ConvertNSRect(&rect);
   328         Cocoa_GetDisplayBounds(_this, display, &bounds);
   329         window->x = (int)rect.origin.x - bounds.x;
   330         window->y = (int)rect.origin.y - bounds.y;
   331         window->w = (int)rect.size.width;
   332         window->h = (int)rect.size.height;
   333     }
   334     if ([nswindow isVisible]) {
   335         window->flags |= SDL_WINDOW_SHOWN;
   336     } else {
   337         window->flags &= ~SDL_WINDOW_SHOWN;
   338     }
   339     {
   340         unsigned int style = [nswindow styleMask];
   341 
   342         if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
   343             window->flags |= SDL_WINDOW_BORDERLESS;
   344         } else {
   345             window->flags &= ~SDL_WINDOW_BORDERLESS;
   346         }
   347         if (style & NSResizableWindowMask) {
   348             window->flags |= SDL_WINDOW_RESIZABLE;
   349         } else {
   350             window->flags &= ~SDL_WINDOW_RESIZABLE;
   351         }
   352     }
   353     if ([nswindow isZoomed]) {
   354         window->flags |= SDL_WINDOW_MAXIMIZED;
   355     } else {
   356         window->flags &= ~SDL_WINDOW_MAXIMIZED;
   357     }
   358     if ([nswindow isMiniaturized]) {
   359         window->flags |= SDL_WINDOW_MINIMIZED;
   360     } else {
   361         window->flags &= ~SDL_WINDOW_MINIMIZED;
   362     }
   363     if ([nswindow isKeyWindow]) {
   364         int index = data->videodata->keyboard;
   365         window->flags |= SDL_WINDOW_INPUT_FOCUS;
   366         SDL_SetKeyboardFocus(index, data->window);
   367 
   368         if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   369             /* FIXME */
   370         }
   371     }
   372 
   373     /* All done! */
   374     [pool release];
   375     window->driverdata = data;
   376     return 0;
   377 }
   378 
   379 int
   380 Cocoa_CreateWindow(_THIS, SDL_Window * window)
   381 {
   382     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   383     NSWindow *nswindow;
   384     SDL_VideoDisplay *display = window->display;
   385     NSRect rect;
   386     SDL_Rect bounds;
   387     unsigned int style;
   388     NSString *title;
   389     int status;
   390 
   391     Cocoa_GetDisplayBounds(_this, display, &bounds);
   392     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   393         || window->x == SDL_WINDOWPOS_CENTERED) {
   394         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
   395     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
   396         rect.origin.x = bounds.x;
   397     } else {
   398         rect.origin.x = bounds.x + window->x;
   399     }
   400     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   401         || window->y == SDL_WINDOWPOS_CENTERED) {
   402         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
   403     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
   404         rect.origin.y = bounds.y;
   405     } else {
   406         rect.origin.y = bounds.y + window->y;
   407     }
   408     rect.size.width = window->w;
   409     rect.size.height = window->h;
   410     ConvertNSRect(&rect);
   411 
   412     if (window->flags & SDL_WINDOW_BORDERLESS) {
   413         style = NSBorderlessWindowMask;
   414     } else {
   415         style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
   416     }
   417     if (window->flags & SDL_WINDOW_RESIZABLE) {
   418         style |= NSResizableWindowMask;
   419     }
   420 
   421     /* Figure out which screen to place this window */
   422     NSArray *screens = [NSScreen screens];
   423     NSScreen *screen = nil;
   424     NSScreen *candidate;
   425     int i, count = [screens count];
   426     for (i = 0; i < count; ++i) {
   427         candidate = [screens objectAtIndex:i];
   428         NSRect screenRect = [candidate frame];
   429         if (rect.origin.x >= screenRect.origin.x &&
   430             rect.origin.x < screenRect.origin.x + screenRect.size.width &&
   431             rect.origin.y >= screenRect.origin.y &&
   432             rect.origin.y < screenRect.origin.y + screenRect.size.height) {
   433             screen = candidate;
   434             rect.origin.x -= screenRect.origin.x;
   435             rect.origin.y -= screenRect.origin.y;
   436         }
   437     }
   438     nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE screen:screen];
   439 
   440     [pool release];
   441 
   442     if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
   443         [nswindow release];
   444         return -1;
   445     }
   446     return 0;
   447 }
   448 
   449 int
   450 Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   451 {
   452     NSAutoreleasePool *pool;
   453     NSWindow *nswindow = (NSWindow *) data;
   454     NSString *title;
   455     int status;
   456 
   457     pool = [[NSAutoreleasePool alloc] init];
   458 
   459     /* Query the title from the existing window */
   460     title = [nswindow title];
   461     if (title) {
   462         window->title = SDL_strdup([title UTF8String]);
   463     }
   464 
   465     [pool release];
   466 
   467     return SetupWindowData(_this, window, nswindow, SDL_FALSE);
   468 }
   469 
   470 void
   471 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
   472 {
   473     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   474     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   475     NSString *string;
   476 
   477     if(window->title) {
   478         string = [[NSString alloc] initWithUTF8String:window->title];
   479     } else {
   480         string = [[NSString alloc] init];
   481     }
   482     [nswindow setTitle:string];
   483     [string release];
   484 
   485     [pool release];
   486 }
   487 
   488 void
   489 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   490 {
   491     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   492     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   493     SDL_VideoDisplay *display = window->display;
   494     NSRect rect;
   495     SDL_Rect bounds;
   496 
   497     Cocoa_GetDisplayBounds(_this, display, &bounds);
   498     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   499         || window->x == SDL_WINDOWPOS_CENTERED) {
   500         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
   501     } else {
   502         rect.origin.x = bounds.x + window->x;
   503     }
   504     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   505         || window->y == SDL_WINDOWPOS_CENTERED) {
   506         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
   507     } else {
   508         rect.origin.y = bounds.y + window->y;
   509     }
   510     rect.size.width = window->w;
   511     rect.size.height = window->h;
   512     ConvertNSRect(&rect);
   513     rect = [nswindow frameRectForContentRect:rect];
   514     [nswindow setFrameOrigin:rect.origin];
   515     [pool release];
   516 }
   517 
   518 void
   519 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   520 {
   521     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   522     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   523     NSSize size;
   524 
   525     size.width = window->w;
   526     size.height = window->h;
   527     [nswindow setContentSize:size];
   528     [pool release];
   529 }
   530 
   531 void
   532 Cocoa_ShowWindow(_THIS, SDL_Window * window)
   533 {
   534     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   535     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   536 
   537     if (![nswindow isMiniaturized]) {
   538         [nswindow makeKeyAndOrderFront:nil];
   539     }
   540     [pool release];
   541 }
   542 
   543 void
   544 Cocoa_HideWindow(_THIS, SDL_Window * window)
   545 {
   546     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   547     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   548 
   549     [nswindow orderOut:nil];
   550     [pool release];
   551 }
   552 
   553 void
   554 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
   555 {
   556     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   557     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   558 
   559     [nswindow makeKeyAndOrderFront:nil];
   560     [pool release];
   561 }
   562 
   563 void
   564 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
   565 {
   566     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   567     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   568 
   569     [nswindow zoom:nil];
   570     [pool release];
   571 }
   572 
   573 void
   574 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
   575 {
   576     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   577     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   578 
   579     [nswindow miniaturize:nil];
   580     [pool release];
   581 }
   582 
   583 void
   584 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   585 {
   586     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   587     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   588 
   589     if ([nswindow isMiniaturized]) {
   590         [nswindow deminiaturize:nil];
   591     } else if ([nswindow isZoomed]) {
   592         [nswindow zoom:nil];
   593     }
   594     [pool release];
   595 }
   596 
   597 void
   598 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
   599 {
   600     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
   601         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   602         /* FIXME: Grab mouse */
   603     } else {
   604         /* FIXME: Release mouse */
   605     }
   606 }
   607 
   608 void
   609 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
   610 {
   611     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   612     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   613 
   614     if (data) {
   615         [data->listener close];
   616         [data->listener release];
   617         if (data->created) {
   618             [data->window close];
   619         }
   620         SDL_free(data);
   621     }
   622     [pool release];
   623 }
   624 
   625 SDL_bool
   626 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   627 {
   628     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   629 
   630     if (info->version.major <= SDL_MAJOR_VERSION) {
   631         //info->window = nswindow;
   632         return SDL_TRUE;
   633     } else {
   634         SDL_SetError("Application not compiled with SDL %d.%d\n",
   635                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   636         return SDL_FALSE;
   637     }
   638 }
   639 
   640 /* vi: set ts=4 sw=4 expandtab: */