src/video/cocoa/SDL_cocoawindow.m
author Sam Lantinga <slouken@libsdl.org>
Thu, 22 Oct 2009 04:46:11 +0000
changeset 3409 c8f580ebc96a
parent 3075 4c28a9655933
child 3414 1e45c3012a4f
permissions -rw-r--r--
Adam Strzelecki to SDL

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