src/video/cocoa/SDL_cocoawindow.m
author Sam Lantinga <slouken@libsdl.org>
Tue, 01 Dec 2009 12:08:34 +0000
changeset 3507 3712547eac4f
parent 3506 e829b6098435
child 3508 a12068b6f44f
permissions -rw-r--r--
The window positions are relative to the origin of the windowing system (upper left of the primary display).
Fixed the mouse positions for windowed mouse movement.
     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     NSRect rect;
   236 
   237     index = _data->videodata->mouse;
   238     mouse = SDL_GetMouse(index);
   239 
   240     point = [NSEvent mouseLocation];
   241     if ( (window->flags & SDL_WINDOW_FULLSCREEN) ) {
   242         rect.size.width = CGDisplayPixelsWide(kCGDirectMainDisplay);
   243         rect.size.height = CGDisplayPixelsHigh(kCGDirectMainDisplay);
   244         point.x = point.x - rect.origin.x;
   245         point.y = rect.size.height - point.y;
   246     } else {
   247         point.x -= window->x;
   248         point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - window->y;
   249     }
   250     if ( point.x < 0 || point.x >= window->w ||
   251          point.y < 0 || point.y >= window->h ) {
   252         if (mouse->focus != 0) {
   253             SDL_SetMouseFocus(index, 0);
   254         }
   255     } else {
   256         if (mouse->focus != _data->windowID) {
   257             SDL_SetMouseFocus(index, _data->windowID);
   258         }
   259         SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0);
   260     }
   261 }
   262 
   263 - (void)mouseDragged:(NSEvent *)theEvent
   264 {
   265     [self mouseMoved:theEvent];
   266 }
   267 
   268 - (void)rightMouseDragged:(NSEvent *)theEvent
   269 {
   270     [self mouseMoved:theEvent];
   271 }
   272 
   273 - (void)otherMouseDragged:(NSEvent *)theEvent
   274 {
   275     [self mouseMoved:theEvent];
   276 }
   277 
   278 - (void)scrollWheel:(NSEvent *)theEvent
   279 {
   280     int index;
   281 
   282     index = _data->videodata->mouse;
   283     SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
   284 }
   285 
   286 @end
   287 
   288 @interface SDLWindow : NSWindow
   289 /* These are needed for borderless/fullscreen windows */
   290 - (BOOL)canBecomeKeyWindow;
   291 - (BOOL)canBecomeMainWindow;
   292 @end
   293 
   294 @implementation SDLWindow
   295 - (BOOL)canBecomeKeyWindow
   296 {
   297     return YES;
   298 }
   299 
   300 - (BOOL)canBecomeMainWindow
   301 {
   302     return YES;
   303 }
   304 @end
   305 
   306 static int
   307 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
   308 {
   309     NSAutoreleasePool *pool;
   310     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   311     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   312     SDL_WindowData *data;
   313 
   314     /* Allocate the window data */
   315     data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
   316     if (!data) {
   317         SDL_OutOfMemory();
   318         return -1;
   319     }
   320     data->windowID = window->id;
   321     data->window = nswindow;
   322     data->created = created;
   323     data->display = displaydata->display;
   324     data->videodata = videodata;
   325 
   326     pool = [[NSAutoreleasePool alloc] init];
   327 
   328     /* Create an event listener for the window */
   329     data->listener = [[Cocoa_WindowListener alloc] init];
   330     [data->listener listen:data];
   331 
   332     /* Fill in the SDL window with the window data */
   333     {
   334         NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
   335         ConvertNSRect(&rect);
   336         window->x = (int)rect.origin.x;
   337         window->y = (int)rect.origin.y;
   338         window->w = (int)rect.size.width;
   339         window->h = (int)rect.size.height;
   340     }
   341     if ([nswindow isVisible]) {
   342         window->flags |= SDL_WINDOW_SHOWN;
   343     } else {
   344         window->flags &= ~SDL_WINDOW_SHOWN;
   345     }
   346     {
   347         unsigned int style = [nswindow styleMask];
   348 
   349         if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
   350             window->flags |= SDL_WINDOW_BORDERLESS;
   351         } else {
   352             window->flags &= ~SDL_WINDOW_BORDERLESS;
   353         }
   354         if (style & NSResizableWindowMask) {
   355             window->flags |= SDL_WINDOW_RESIZABLE;
   356         } else {
   357             window->flags &= ~SDL_WINDOW_RESIZABLE;
   358         }
   359     }
   360     if ([nswindow isZoomed]) {
   361         window->flags |= SDL_WINDOW_MAXIMIZED;
   362     } else {
   363         window->flags &= ~SDL_WINDOW_MAXIMIZED;
   364     }
   365     if ([nswindow isMiniaturized]) {
   366         window->flags |= SDL_WINDOW_MINIMIZED;
   367     } else {
   368         window->flags &= ~SDL_WINDOW_MINIMIZED;
   369     }
   370     if ([nswindow isKeyWindow]) {
   371         int index = data->videodata->keyboard;
   372         window->flags |= SDL_WINDOW_INPUT_FOCUS;
   373         SDL_SetKeyboardFocus(index, data->windowID);
   374 
   375         if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   376             /* FIXME */
   377         }
   378     }
   379 
   380     /* All done! */
   381     [pool release];
   382     window->driverdata = data;
   383     return 0;
   384 }
   385 
   386 int
   387 Cocoa_CreateWindow(_THIS, SDL_Window * window)
   388 {
   389     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   390     NSWindow *nswindow;
   391     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   392     NSRect rect;
   393     unsigned int style;
   394     NSString *title;
   395     int status;
   396 
   397     rect = CGDisplayBounds(displaydata->display);
   398     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   399         || window->x == SDL_WINDOWPOS_CENTERED) {
   400         rect.origin.x += (rect.size.width - window->w) / 2;
   401     } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
   402         rect.origin.x = window->x;
   403     }
   404     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   405         || window->y == SDL_WINDOWPOS_CENTERED) {
   406         rect.origin.y += (rect.size.height - window->h) / 2;
   407     } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
   408         rect.origin.y = window->y;
   409     }
   410     rect.size.width = window->w;
   411     rect.size.height = window->h;
   412     ConvertNSRect(&rect);
   413 
   414     if (window->flags & SDL_WINDOW_BORDERLESS) {
   415         style = NSBorderlessWindowMask;
   416     } else {
   417         style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
   418     }
   419     if (window->flags & SDL_WINDOW_RESIZABLE) {
   420         style |= NSResizableWindowMask;
   421     }
   422 
   423     /* Figure out which screen to place this window */
   424     NSArray *screens = [NSScreen screens];
   425     NSScreen *screen = nil;
   426     NSScreen *candidate;
   427     for (candidate in screens) {
   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_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   494     NSRect rect;
   495 
   496     rect = CGDisplayBounds(displaydata->display);
   497     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   498         || window->x == SDL_WINDOWPOS_CENTERED) {
   499         rect.origin.x += (rect.size.width - window->w) / 2;
   500     } else {
   501         rect.origin.x = window->x;
   502     }
   503     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   504         || window->y == SDL_WINDOWPOS_CENTERED) {
   505         rect.origin.y += (rect.size.height - window->h) / 2;
   506     } else {
   507         rect.origin.y = window->y;
   508     }
   509     rect.size.width = window->w;
   510     rect.size.height = window->h;
   511     ConvertNSRect(&rect);
   512     rect = [nswindow frameRectForContentRect:rect];
   513     [nswindow setFrameOrigin:rect.origin];
   514     [pool release];
   515 }
   516 
   517 void
   518 Cocoa_SetWindowSize(_THIS, SDL_Window * window)
   519 {
   520     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   521     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   522     NSSize size;
   523 
   524     size.width = window->w;
   525     size.height = window->h;
   526     [nswindow setContentSize:size];
   527     [pool release];
   528 }
   529 
   530 void
   531 Cocoa_ShowWindow(_THIS, SDL_Window * window)
   532 {
   533     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   534     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   535 
   536     if (![nswindow isMiniaturized]) {
   537         [nswindow makeKeyAndOrderFront:nil];
   538     }
   539     [pool release];
   540 }
   541 
   542 void
   543 Cocoa_HideWindow(_THIS, SDL_Window * window)
   544 {
   545     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   546     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   547 
   548     [nswindow orderOut:nil];
   549     [pool release];
   550 }
   551 
   552 void
   553 Cocoa_RaiseWindow(_THIS, SDL_Window * window)
   554 {
   555     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   556     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   557 
   558     [nswindow makeKeyAndOrderFront:nil];
   559     [pool release];
   560 }
   561 
   562 void
   563 Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
   564 {
   565     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   566     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   567 
   568     [nswindow zoom:nil];
   569     [pool release];
   570 }
   571 
   572 void
   573 Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
   574 {
   575     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   576     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   577 
   578     [nswindow miniaturize:nil];
   579     [pool release];
   580 }
   581 
   582 void
   583 Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   584 {
   585     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   586     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   587 
   588     if ([nswindow isMiniaturized]) {
   589         [nswindow deminiaturize:nil];
   590     } else if ([nswindow isZoomed]) {
   591         [nswindow zoom:nil];
   592     }
   593     [pool release];
   594 }
   595 
   596 void
   597 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
   598 {
   599     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
   600         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   601         /* FIXME: Grab mouse */
   602     } else {
   603         /* FIXME: Release mouse */
   604     }
   605 }
   606 
   607 void
   608 Cocoa_DestroyWindow(_THIS, SDL_Window * window)
   609 {
   610     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   611     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   612 
   613     if (data) {
   614         [data->listener close];
   615         [data->listener release];
   616         if (data->created) {
   617             [data->window close];
   618         }
   619         SDL_free(data);
   620     }
   621     [pool release];
   622 }
   623 
   624 SDL_bool
   625 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   626 {
   627     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   628 
   629     if (info->version.major <= SDL_MAJOR_VERSION) {
   630         //info->window = nswindow;
   631         return SDL_TRUE;
   632     } else {
   633         SDL_SetError("Application not compiled with SDL %d.%d\n",
   634                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   635         return SDL_FALSE;
   636     }
   637 }
   638 
   639 /* vi: set ts=4 sw=4 expandtab: */