src/video/cocoa/SDL_cocoawindow.m
author Sam Lantinga <slouken@libsdl.org>
Thu, 08 Jul 2010 22:54:03 -0700
changeset 4503 524dfefd554c
parent 4498 3d91e31fcf71
child 4673 c17ac64abb70
permissions -rw-r--r--
Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 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->nswindow setNextResponder:self];
    48     if ([_data->nswindow delegate] != nil) {
    49         [center addObserver:self selector:@selector(windowDisExpose:) name:NSWindowDidExposeNotification object:_data->nswindow];
    50         [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:_data->nswindow];
    51         [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:_data->nswindow];
    52         [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:_data->nswindow];
    53         [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:_data->nswindow];
    54         [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:_data->nswindow];
    55         [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:_data->nswindow];
    56     } else {
    57         [_data->nswindow 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->nswindow setAcceptsMouseMovedEvents:YES];
    63 }
    64 
    65 - (void)close
    66 {
    67     NSNotificationCenter *center;
    68 
    69     center = [NSNotificationCenter defaultCenter];
    70 
    71     [_data->nswindow setNextResponder:nil];
    72     if ([_data->nswindow delegate] != self) {
    73         [center removeObserver:self name:NSWindowDidExposeNotification object:_data->nswindow];
    74         [center removeObserver:self name:NSWindowDidMoveNotification object:_data->nswindow];
    75         [center removeObserver:self name:NSWindowDidResizeNotification object:_data->nswindow];
    76         [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:_data->nswindow];
    77         [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:_data->nswindow];
    78         [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:_data->nswindow];
    79         [center removeObserver:self name:NSWindowDidResignKeyNotification object:_data->nswindow];
    80     } else {
    81         [_data->nswindow 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->nswindow contentRectForFrameRect:[_data->nswindow 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->nswindow contentRectForFrameRect:[_data->nswindow 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     /* We're going to get keyboard events, since we're key. */
   130     SDL_SetKeyboardFocus(_data->window);
   131 
   132     /* Check to see if someone updated the clipboard */
   133     Cocoa_CheckClipboardUpdate(_data->videodata);
   134 }
   135 
   136 - (void)windowDidResignKey:(NSNotification *)aNotification
   137 {
   138     /* Some other window will get mouse events, since we're not key. */
   139     if (SDL_GetMouseFocus() == _data->window) {
   140         SDL_SetMouseFocus(NULL);
   141     }
   142 
   143     /* Some other window will get keyboard events, since we're not key. */
   144     if (SDL_GetKeyboardFocus() == _data->window) {
   145         SDL_SetKeyboardFocus(NULL);
   146     }
   147 }
   148 
   149 - (void)windowDidHide:(NSNotification *)aNotification
   150 {
   151     SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
   152 }
   153 
   154 - (void)windowDidUnhide:(NSNotification *)aNotification
   155 {
   156     SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
   157 }
   158 
   159 - (void)mouseDown:(NSEvent *)theEvent
   160 {
   161     int button;
   162 
   163     switch ([theEvent buttonNumber]) {
   164     case 0:
   165         button = SDL_BUTTON_LEFT;
   166         break;
   167     case 1:
   168         button = SDL_BUTTON_RIGHT;
   169         break;
   170     case 2:
   171         button = SDL_BUTTON_MIDDLE;
   172         break;
   173     default:
   174         button = [theEvent buttonNumber];
   175         break;
   176     }
   177     SDL_SendMouseButton(_data->window, SDL_PRESSED, button);
   178 }
   179 
   180 - (void)rightMouseDown:(NSEvent *)theEvent
   181 {
   182     [self mouseDown:theEvent];
   183 }
   184 
   185 - (void)otherMouseDown:(NSEvent *)theEvent
   186 {
   187     [self mouseDown:theEvent];
   188 }
   189 
   190 - (void)mouseUp:(NSEvent *)theEvent
   191 {
   192     int button;
   193 
   194     switch ([theEvent buttonNumber]) {
   195     case 0:
   196         button = SDL_BUTTON_LEFT;
   197         break;
   198     case 1:
   199         button = SDL_BUTTON_RIGHT;
   200         break;
   201     case 2:
   202         button = SDL_BUTTON_MIDDLE;
   203         break;
   204     default:
   205         button = [theEvent buttonNumber];
   206         break;
   207     }
   208     SDL_SendMouseButton(_data->window, SDL_RELEASED, button);
   209 }
   210 
   211 - (void)rightMouseUp:(NSEvent *)theEvent
   212 {
   213     [self mouseUp:theEvent];
   214 }
   215 
   216 - (void)otherMouseUp:(NSEvent *)theEvent
   217 {
   218     [self mouseUp:theEvent];
   219 }
   220 
   221 - (void)mouseMoved:(NSEvent *)theEvent
   222 {
   223     SDL_Window *window = _data->window;
   224     NSPoint point;
   225 
   226     point = [theEvent locationInWindow];
   227     point.y = window->h - point.y;
   228     if ( point.x < 0 || point.x >= window->w ||
   229          point.y < 0 || point.y >= window->h ) {
   230         if (SDL_GetMouseFocus() == window) {
   231             SDL_SetMouseFocus(NULL);
   232         }
   233     } else {
   234         SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y);
   235     }
   236 }
   237 
   238 - (void)mouseDragged:(NSEvent *)theEvent
   239 {
   240     [self mouseMoved:theEvent];
   241 }
   242 
   243 - (void)rightMouseDragged:(NSEvent *)theEvent
   244 {
   245     [self mouseMoved:theEvent];
   246 }
   247 
   248 - (void)otherMouseDragged:(NSEvent *)theEvent
   249 {
   250     [self mouseMoved:theEvent];
   251 }
   252 
   253 - (void)scrollWheel:(NSEvent *)theEvent
   254 {
   255     float x = [theEvent deltaX];
   256     float y = [theEvent deltaY];
   257 
   258     if (x > 0) {
   259         x += 0.9f;
   260     } else if (x < 0) {
   261         x -= 0.9f;
   262     }
   263     if (y > 0) {
   264         y += 0.9f;
   265     } else if (y < 0) {
   266         y -= 0.9f;
   267     }
   268     SDL_SendMouseWheel(_data->window, (int)x, (int)y);
   269 }
   270 
   271 @end
   272 
   273 @interface SDLWindow : NSWindow
   274 /* These are needed for borderless/fullscreen windows */
   275 - (BOOL)canBecomeKeyWindow;
   276 - (BOOL)canBecomeMainWindow;
   277 @end
   278 
   279 @implementation SDLWindow
   280 - (BOOL)canBecomeKeyWindow
   281 {
   282     return YES;
   283 }
   284 
   285 - (BOOL)canBecomeMainWindow
   286 {
   287     return YES;
   288 }
   289 @end
   290 
   291 static int
   292 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
   293 {
   294     NSAutoreleasePool *pool;
   295     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   296     SDL_VideoDisplay *display = window->display;
   297     SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
   298     SDL_WindowData *data;
   299 
   300     /* Allocate the window data */
   301     data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
   302     if (!data) {
   303         SDL_OutOfMemory();
   304         return -1;
   305     }
   306     data->window = window;
   307     data->nswindow = nswindow;
   308     data->created = created;
   309     data->display = displaydata->display;
   310     data->videodata = videodata;
   311 
   312     pool = [[NSAutoreleasePool alloc] init];
   313 
   314     /* Create an event listener for the window */
   315     data->listener = [[Cocoa_WindowListener alloc] init];
   316     [data->listener listen:data];
   317 
   318     /* Fill in the SDL window with the window data */
   319     {
   320         SDL_Rect bounds;
   321         NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
   322         ConvertNSRect(&rect);
   323         Cocoa_GetDisplayBounds(_this, display, &bounds);
   324         window->x = (int)rect.origin.x - bounds.x;
   325         window->y = (int)rect.origin.y - bounds.y;
   326         window->w = (int)rect.size.width;
   327         window->h = (int)rect.size.height;
   328     }
   329     if ([nswindow isVisible]) {
   330         window->flags |= SDL_WINDOW_SHOWN;
   331     } else {
   332         window->flags &= ~SDL_WINDOW_SHOWN;
   333     }
   334     {
   335         unsigned int style = [nswindow styleMask];
   336 
   337         if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
   338             window->flags |= SDL_WINDOW_BORDERLESS;
   339         } else {
   340             window->flags &= ~SDL_WINDOW_BORDERLESS;
   341         }
   342         if (style & NSResizableWindowMask) {
   343             window->flags |= SDL_WINDOW_RESIZABLE;
   344         } else {
   345             window->flags &= ~SDL_WINDOW_RESIZABLE;
   346         }
   347     }
   348     if ([nswindow isZoomed]) {
   349         window->flags |= SDL_WINDOW_MAXIMIZED;
   350     } else {
   351         window->flags &= ~SDL_WINDOW_MAXIMIZED;
   352     }
   353     if ([nswindow isMiniaturized]) {
   354         window->flags |= SDL_WINDOW_MINIMIZED;
   355     } else {
   356         window->flags &= ~SDL_WINDOW_MINIMIZED;
   357     }
   358     if ([nswindow isKeyWindow]) {
   359         window->flags |= SDL_WINDOW_INPUT_FOCUS;
   360         SDL_SetKeyboardFocus(data->window);
   361 
   362         if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   363             /* FIXME */
   364         }
   365     }
   366 
   367     /* All done! */
   368     [pool release];
   369     window->driverdata = data;
   370     return 0;
   371 }
   372 
   373 int
   374 Cocoa_CreateWindow(_THIS, SDL_Window * window)
   375 {
   376     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   377     NSWindow *nswindow;
   378     SDL_VideoDisplay *display = window->display;
   379     NSRect rect;
   380     SDL_Rect bounds;
   381     unsigned int style;
   382 
   383     Cocoa_GetDisplayBounds(_this, display, &bounds);
   384     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   385         || window->x == SDL_WINDOWPOS_CENTERED) {
   386         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
   387     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
   388         rect.origin.x = bounds.x;
   389     } else {
   390         rect.origin.x = bounds.x + window->x;
   391     }
   392     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   393         || window->y == SDL_WINDOWPOS_CENTERED) {
   394         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
   395     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
   396         rect.origin.y = bounds.y;
   397     } else {
   398         rect.origin.y = bounds.y + window->y;
   399     }
   400     rect.size.width = window->w;
   401     rect.size.height = window->h;
   402     ConvertNSRect(&rect);
   403 
   404     if (window->flags & SDL_WINDOW_BORDERLESS) {
   405         style = NSBorderlessWindowMask;
   406     } else {
   407         style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
   408     }
   409     if (window->flags & SDL_WINDOW_RESIZABLE) {
   410         style |= NSResizableWindowMask;
   411     }
   412 
   413     /* Figure out which screen to place this window */
   414     NSArray *screens = [NSScreen screens];
   415     NSScreen *screen = nil;
   416     NSScreen *candidate;
   417     int i, count = [screens count];
   418     for (i = 0; i < count; ++i) {
   419         candidate = [screens objectAtIndex:i];
   420         NSRect screenRect = [candidate frame];
   421         if (rect.origin.x >= screenRect.origin.x &&
   422             rect.origin.x < screenRect.origin.x + screenRect.size.width &&
   423             rect.origin.y >= screenRect.origin.y &&
   424             rect.origin.y < screenRect.origin.y + screenRect.size.height) {
   425             screen = candidate;
   426             rect.origin.x -= screenRect.origin.x;
   427             rect.origin.y -= screenRect.origin.y;
   428         }
   429     }
   430     nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE screen:screen];
   431 
   432     [pool release];
   433 
   434     if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
   435         [nswindow release];
   436         return -1;
   437     }
   438     return 0;
   439 }
   440 
   441 int
   442 Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   443 {
   444     NSAutoreleasePool *pool;
   445     NSWindow *nswindow = (NSWindow *) data;
   446     NSString *title;
   447 
   448     pool = [[NSAutoreleasePool alloc] init];
   449 
   450     /* Query the title from the existing window */
   451     title = [nswindow title];
   452     if (title) {
   453         window->title = SDL_strdup([title UTF8String]);
   454     }
   455 
   456     [pool release];
   457 
   458     return SetupWindowData(_this, window, nswindow, SDL_FALSE);
   459 }
   460 
   461 void
   462 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
   463 {
   464     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   465     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   466     NSString *string;
   467 
   468     if(window->title) {
   469         string = [[NSString alloc] initWithUTF8String:window->title];
   470     } else {
   471         string = [[NSString alloc] init];
   472     }
   473     [nswindow setTitle:string];
   474     [string release];
   475 
   476     [pool release];
   477 }
   478 
   479 void
   480 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   481 {
   482     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   483     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   484     SDL_VideoDisplay *display = window->display;
   485     NSRect rect;
   486     SDL_Rect bounds;
   487 
   488     Cocoa_GetDisplayBounds(_this, display, &bounds);
   489     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   490         || window->x == SDL_WINDOWPOS_CENTERED) {
   491         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
   492     } else {
   493         rect.origin.x = bounds.x + window->x;
   494     }
   495     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   496         || window->y == SDL_WINDOWPOS_CENTERED) {
   497         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
   498     } else {
   499         rect.origin.y = bounds.y + window->y;
   500     }
   501     rect.size.width = window->w;
   502     rect.size.height = window->h;
   503     ConvertNSRect(&rect);
   504     rect = [nswindow frameRectForContentRect:rect];
   505     [nswindow setFrameOrigin:rect.origin];
   506     [pool release];
   507 }
   508 
   509 void
   510 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   511 {
   512     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   513     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   514     NSSize size;
   515 
   516     size.width = window->w;
   517     size.height = window->h;
   518     [nswindow setContentSize:size];
   519     [pool release];
   520 }
   521 
   522 void
   523 Cocoa_ShowWindow(_THIS, SDL_Window * window)
   524 {
   525     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   526     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   527 
   528     if (![nswindow isMiniaturized]) {
   529         [nswindow makeKeyAndOrderFront:nil];
   530     }
   531     [pool release];
   532 }
   533 
   534 void
   535 Cocoa_HideWindow(_THIS, SDL_Window * window)
   536 {
   537     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   538     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   539 
   540     [nswindow orderOut:nil];
   541     [pool release];
   542 }
   543 
   544 void
   545 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
   546 {
   547     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   548     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   549 
   550     [nswindow makeKeyAndOrderFront:nil];
   551     [pool release];
   552 }
   553 
   554 void
   555 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
   556 {
   557     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   558     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   559 
   560     [nswindow zoom:nil];
   561     [pool release];
   562 }
   563 
   564 void
   565 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
   566 {
   567     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   568     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   569 
   570     [nswindow miniaturize:nil];
   571     [pool release];
   572 }
   573 
   574 void
   575 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   576 {
   577     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   578     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   579 
   580     if ([nswindow isMiniaturized]) {
   581         [nswindow deminiaturize:nil];
   582     } else if ([nswindow isZoomed]) {
   583         [nswindow zoom:nil];
   584     }
   585     [pool release];
   586 }
   587 
   588 void
   589 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
   590 {
   591     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
   592         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   593         /* FIXME: Grab mouse */
   594     } else {
   595         /* FIXME: Release mouse */
   596     }
   597 }
   598 
   599 void
   600 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
   601 {
   602     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   603     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   604 
   605     if (data) {
   606         [data->listener close];
   607         [data->listener release];
   608         if (data->created) {
   609             [data->nswindow close];
   610         }
   611         SDL_free(data);
   612     }
   613     [pool release];
   614 }
   615 
   616 SDL_bool
   617 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   618 {
   619     //NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   620 
   621     if (info->version.major <= SDL_MAJOR_VERSION) {
   622         //info->window = nswindow;
   623         return SDL_TRUE;
   624     } else {
   625         SDL_SetError("Application not compiled with SDL %d.%d\n",
   626                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   627         return SDL_FALSE;
   628     }
   629 }
   630 
   631 /* vi: set ts=4 sw=4 expandtab: */