src/video/cocoa/SDL_cocoawindow.m
author Sam Lantinga <slouken@libsdl.org>
Sat, 05 Dec 2009 19:57:49 +0000
changeset 3525 455a6c47d2c6
parent 3517 e7eec78e4b92
child 3528 59ff7a2beb57
permissions -rw-r--r--
Fixed compilation on Mac OS X 10.4
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_syswm.h"
    25 #include "../SDL_sysvideo.h"
    26 #include "../../events/SDL_keyboard_c.h"
    27 #include "../../events/SDL_mouse_c.h"
    28 #include "../../events/SDL_windowevents_c.h"
    29 
    30 #include "SDL_cocoavideo.h"
    31 
    32 static __inline__ void ConvertNSRect(NSRect *r)
    33 {
    34     r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
    35 }
    36 
    37 @implementation Cocoa_WindowListener
    38 
    39 - (void)listen:(SDL_WindowData *)data
    40 {
    41     NSNotificationCenter *center;
    42 
    43     _data = data;
    44 
    45     center = [NSNotificationCenter defaultCenter];
    46 
    47     [_data->window setNextResponder:self];
    48     if ([_data->window delegate] != nil) {
    49         [center addObserver:self selector:@selector(windowDisExpose:) name:NSWindowDidExposeNotification object:_data->window];
    50         [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:_data->window];
    51         [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:_data->window];
    52         [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:_data->window];
    53         [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:_data->window];
    54         [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:_data->window];
    55         [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:_data->window];
    56     } else {
    57         [_data->window setDelegate:self];
    58     }
    59     [center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp];
    60     [center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];
    61 
    62     [_data->window setAcceptsMouseMovedEvents:YES];
    63 }
    64 
    65 - (void)close
    66 {
    67     NSNotificationCenter *center;
    68 
    69     center = [NSNotificationCenter defaultCenter];
    70 
    71     [_data->window setNextResponder:nil];
    72     if ([_data->window delegate] != self) {
    73         [center removeObserver:self name:NSWindowDidExposeNotification object:_data->window];
    74         [center removeObserver:self name:NSWindowDidMoveNotification object:_data->window];
    75         [center removeObserver:self name:NSWindowDidResizeNotification object:_data->window];
    76         [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:_data->window];
    77         [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:_data->window];
    78         [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:_data->window];
    79         [center removeObserver:self name:NSWindowDidResignKeyNotification object:_data->window];
    80     } else {
    81         [_data->window setDelegate:nil];
    82     }
    83     [center removeObserver:self name:NSApplicationDidHideNotification object:NSApp];
    84     [center removeObserver:self name:NSApplicationDidUnhideNotification object:NSApp];
    85 }
    86 
    87 - (BOOL)windowShouldClose:(id)sender
    88 {
    89     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0);
    90     return NO;
    91 }
    92 
    93 - (void)windowDidExpose:(NSNotification *)aNotification
    94 {
    95     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_EXPOSED, 0, 0);
    96 }
    97 
    98 - (void)windowDidMove:(NSNotification *)aNotification
    99 {
   100     int x, y;
   101     NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]];
   102     ConvertNSRect(&rect);
   103     x = (int)rect.origin.x;
   104     y = (int)rect.origin.y;
   105     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MOVED, x, y);
   106 }
   107 
   108 - (void)windowDidResize:(NSNotification *)aNotification
   109 {
   110     int w, h;
   111     NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]];
   112     w = (int)rect.size.width;
   113     h = (int)rect.size.height;
   114     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_RESIZED, w, h);
   115 }
   116 
   117 - (void)windowDidMiniaturize:(NSNotification *)aNotification
   118 {
   119     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
   120 }
   121 
   122 - (void)windowDidDeminiaturize:(NSNotification *)aNotification
   123 {
   124     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_RESTORED, 0, 0);
   125 }
   126 
   127 - (void)windowDidBecomeKey:(NSNotification *)aNotification
   128 {
   129     int index;
   130 
   131     /* We're going to get keyboard events, since we're key. */
   132     index = _data->videodata->keyboard;
   133     SDL_SetKeyboardFocus(index, _data->windowID);
   134 }
   135 
   136 - (void)windowDidResignKey:(NSNotification *)aNotification
   137 {
   138     int index;
   139     SDL_Mouse *mouse;
   140 
   141     /* Some other window will get mouse events, since we're not key. */
   142     index = _data->videodata->mouse;
   143     mouse = SDL_GetMouse(index);
   144     if (mouse->focus == _data->windowID) {
   145         SDL_SetMouseFocus(index, 0);
   146     }
   147 
   148     /* Some other window will get keyboard events, since we're not key. */
   149     index = _data->videodata->keyboard;
   150     SDL_SetKeyboardFocus(index, 0);
   151 }
   152 
   153 - (void)windowDidHide:(NSNotification *)aNotification
   154 {
   155     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 0);
   156 }
   157 
   158 - (void)windowDidUnhide:(NSNotification *)aNotification
   159 {
   160     SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 0);
   161 }
   162 
   163 - (void)mouseDown:(NSEvent *)theEvent
   164 {
   165     int index;
   166     int button;
   167 
   168     index = _data->videodata->mouse;
   169     switch ([theEvent buttonNumber]) {
   170     case 0:
   171         button = SDL_BUTTON_LEFT;
   172         break;
   173     case 1:
   174         button = SDL_BUTTON_RIGHT;
   175         break;
   176     case 2:
   177         button = SDL_BUTTON_MIDDLE;
   178         break;
   179     default:
   180         button = [theEvent buttonNumber];
   181         break;
   182     }
   183     SDL_SendMouseButton(index, SDL_PRESSED, button);
   184 }
   185 
   186 - (void)rightMouseDown:(NSEvent *)theEvent
   187 {
   188     [self mouseDown:theEvent];
   189 }
   190 
   191 - (void)otherMouseDown:(NSEvent *)theEvent
   192 {
   193     [self mouseDown:theEvent];
   194 }
   195 
   196 - (void)mouseUp:(NSEvent *)theEvent
   197 {
   198     int index;
   199     int button;
   200 
   201     index = _data->videodata->mouse;
   202     switch ([theEvent buttonNumber]) {
   203     case 0:
   204         button = SDL_BUTTON_LEFT;
   205         break;
   206     case 1:
   207         button = SDL_BUTTON_RIGHT;
   208         break;
   209     case 2:
   210         button = SDL_BUTTON_MIDDLE;
   211         break;
   212     default:
   213         button = [theEvent buttonNumber];
   214         break;
   215     }
   216     SDL_SendMouseButton(index, SDL_RELEASED, button);
   217 }
   218 
   219 - (void)rightMouseUp:(NSEvent *)theEvent
   220 {
   221     [self mouseUp:theEvent];
   222 }
   223 
   224 - (void)otherMouseUp:(NSEvent *)theEvent
   225 {
   226     [self mouseUp:theEvent];
   227 }
   228 
   229 - (void)mouseMoved:(NSEvent *)theEvent
   230 {
   231     SDL_Window *window = SDL_GetWindowFromID(_data->windowID);
   232     int index;
   233     SDL_Mouse *mouse;
   234     NSPoint point;
   235 
   236     index = _data->videodata->mouse;
   237     mouse = SDL_GetMouse(index);
   238     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->windowID) {
   247             SDL_SetMouseFocus(index, _data->windowID);
   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_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   302     SDL_WindowData *data;
   303 
   304     /* Allocate the window data */
   305     data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
   306     if (!data) {
   307         SDL_OutOfMemory();
   308         return -1;
   309     }
   310     data->windowID = window->id;
   311     data->window = nswindow;
   312     data->created = created;
   313     data->display = displaydata->display;
   314     data->videodata = videodata;
   315 
   316     pool = [[NSAutoreleasePool alloc] init];
   317 
   318     /* Create an event listener for the window */
   319     data->listener = [[Cocoa_WindowListener alloc] init];
   320     [data->listener listen:data];
   321 
   322     /* Fill in the SDL window with the window data */
   323     {
   324         NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
   325         ConvertNSRect(&rect);
   326         window->x = (int)rect.origin.x;
   327         window->y = (int)rect.origin.y;
   328         window->w = (int)rect.size.width;
   329         window->h = (int)rect.size.height;
   330     }
   331     if ([nswindow isVisible]) {
   332         window->flags |= SDL_WINDOW_SHOWN;
   333     } else {
   334         window->flags &= ~SDL_WINDOW_SHOWN;
   335     }
   336     {
   337         unsigned int style = [nswindow styleMask];
   338 
   339         if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
   340             window->flags |= SDL_WINDOW_BORDERLESS;
   341         } else {
   342             window->flags &= ~SDL_WINDOW_BORDERLESS;
   343         }
   344         if (style & NSResizableWindowMask) {
   345             window->flags |= SDL_WINDOW_RESIZABLE;
   346         } else {
   347             window->flags &= ~SDL_WINDOW_RESIZABLE;
   348         }
   349     }
   350     if ([nswindow isZoomed]) {
   351         window->flags |= SDL_WINDOW_MAXIMIZED;
   352     } else {
   353         window->flags &= ~SDL_WINDOW_MAXIMIZED;
   354     }
   355     if ([nswindow isMiniaturized]) {
   356         window->flags |= SDL_WINDOW_MINIMIZED;
   357     } else {
   358         window->flags &= ~SDL_WINDOW_MINIMIZED;
   359     }
   360     if ([nswindow isKeyWindow]) {
   361         int index = data->videodata->keyboard;
   362         window->flags |= SDL_WINDOW_INPUT_FOCUS;
   363         SDL_SetKeyboardFocus(index, data->windowID);
   364 
   365         if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   366             /* FIXME */
   367         }
   368     }
   369 
   370     /* All done! */
   371     [pool release];
   372     window->driverdata = data;
   373     return 0;
   374 }
   375 
   376 int
   377 Cocoa_CreateWindow(_THIS, SDL_Window * window)
   378 {
   379     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   380     NSWindow *nswindow;
   381     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   382     NSRect rect;
   383     unsigned int style;
   384     NSString *title;
   385     int status;
   386 
   387     rect = Cocoa_DisplayBounds(displaydata->display);
   388     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   389         || window->x == SDL_WINDOWPOS_CENTERED) {
   390         rect.origin.x += (rect.size.width - window->w) / 2;
   391     } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
   392         rect.origin.x = window->x;
   393     }
   394     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   395         || window->y == SDL_WINDOWPOS_CENTERED) {
   396         rect.origin.y += (rect.size.height - window->h) / 2;
   397     } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
   398         rect.origin.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         screen = [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     int status;
   448 
   449     pool = [[NSAutoreleasePool alloc] init];
   450 
   451     /* Query the title from the existing window */
   452     title = [nswindow title];
   453     if (title) {
   454         window->title = SDL_strdup([title UTF8String]);
   455     }
   456 
   457     [pool release];
   458 
   459     return SetupWindowData(_this, window, nswindow, SDL_FALSE);
   460 }
   461 
   462 void
   463 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
   464 {
   465     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   466     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   467     NSString *string;
   468 
   469     if(window->title) {
   470         string = [[NSString alloc] initWithUTF8String:window->title];
   471     } else {
   472         string = [[NSString alloc] init];
   473     }
   474     [nswindow setTitle:string];
   475     [string release];
   476 
   477     [pool release];
   478 }
   479 
   480 void
   481 Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
   482 {
   483     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   484     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   485     SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   486     NSRect rect;
   487 
   488     rect = Cocoa_DisplayBounds(displaydata->display);
   489     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   490         || window->x == SDL_WINDOWPOS_CENTERED) {
   491         rect.origin.x += (rect.size.width - window->w) / 2;
   492     } else {
   493         rect.origin.x = window->x;
   494     }
   495     if ((window->flags & SDL_WINDOW_FULLSCREEN)
   496         || window->y == SDL_WINDOWPOS_CENTERED) {
   497         rect.origin.y += (rect.size.height - window->h) / 2;
   498     } else {
   499         rect.origin.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)->window;
   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)->window;
   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)->window;
   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)->window;
   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)->window;
   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)->window;
   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)->window;
   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->window 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)->window;
   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: */