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