Added SDL_GetDisplayUsableBounds().
authorRyan C. Gordon <icculus@icculus.org>
Mon, 04 Jan 2016 23:52:40 -0500
changeset 1001936f7e8084508
parent 10018 3c1384edf9fa
child 10020 08b9e569e1ce
Added SDL_GetDisplayUsableBounds().
.hgignore
include/SDL_video.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/cocoa/SDL_cocoamodes.h
src/video/cocoa/SDL_cocoamodes.m
src/video/cocoa/SDL_cocoavideo.m
src/video/uikit/SDL_uikitmodes.h
src/video/uikit/SDL_uikitmodes.m
src/video/uikit/SDL_uikitvideo.m
src/video/windows/SDL_windowsmodes.c
src/video/windows/SDL_windowsmodes.h
src/video/windows/SDL_windowsvideo.c
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11modes.h
src/video/x11/SDL_x11video.c
test/Makefile.in
test/testbounds.c
     1.1 --- a/.hgignore	Wed Apr 22 16:50:48 2015 -0400
     1.2 +++ b/.hgignore	Mon Jan 04 23:52:40 2016 -0500
     1.3 @@ -116,6 +116,7 @@
     1.4  test/testver
     1.5  test/testviewport
     1.6  test/testwm2
     1.7 +test/testbounds
     1.8  test/torturethread
     1.9  test/testdisplayinfo
    1.10  test/*.exe
     2.1 --- a/include/SDL_video.h	Wed Apr 22 16:50:48 2015 -0400
     2.2 +++ b/include/SDL_video.h	Mon Jan 04 23:52:40 2016 -0500
     2.3 @@ -312,6 +312,25 @@
     2.4  extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
     2.5  
     2.6  /**
     2.7 + *  \brief Get the usable desktop area represented by a display, with the
     2.8 + *         primary display located at 0,0
     2.9 + *
    2.10 + *  This is the same area as SDL_GetDisplayBounds() reports, but with portions
    2.11 + *  reserved by the system removed. For example, on Mac OS X, this subtracts
    2.12 + *  the area occupied by the menu bar and dock.
    2.13 + *
    2.14 + *  Setting a window to be fullscreen generally bypasses these unusable areas,
    2.15 + *  so these are good guidelines for the maximum space available to a
    2.16 + *  non-fullscreen window.
    2.17 + *
    2.18 + *  \return 0 on success, or -1 if the index is out of range.
    2.19 + *
    2.20 + *  \sa SDL_GetDisplayBounds()
    2.21 + *  \sa SDL_GetNumVideoDisplays()
    2.22 + */
    2.23 +extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect);
    2.24 +
    2.25 +/**
    2.26   *  \brief Returns the number of available display modes.
    2.27   *
    2.28   *  \sa SDL_GetDisplayMode()
     3.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Wed Apr 22 16:50:48 2015 -0400
     3.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Mon Jan 04 23:52:40 2016 -0500
     3.3 @@ -597,3 +597,4 @@
     3.4  #define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_REAL
     3.5  #define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_REAL
     3.6  #define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_REAL
     3.7 +#define SDL_GetDisplayUsableBounds SDL_GetDisplayUsableBounds_REAL
     4.1 --- a/src/dynapi/SDL_dynapi_procs.h	Wed Apr 22 16:50:48 2015 -0400
     4.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Mon Jan 04 23:52:40 2016 -0500
     4.3 @@ -631,3 +631,4 @@
     4.4  SDL_DYNAPI_PROC(SDL_JoystickPowerLevel,SDL_JoystickCurrentPowerLevel,(SDL_Joystick *a),(a),return)
     4.5  SDL_DYNAPI_PROC(SDL_GameController*,SDL_GameControllerFromInstanceID,(SDL_JoystickID a),(a),return)
     4.6  SDL_DYNAPI_PROC(SDL_Joystick*,SDL_JoystickFromInstanceID,(SDL_JoystickID a),(a),return)
     4.7 +SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(int a, SDL_Rect *b),(a,b),return)
     5.1 --- a/src/video/SDL_sysvideo.h	Wed Apr 22 16:50:48 2015 -0400
     5.2 +++ b/src/video/SDL_sysvideo.h	Mon Jan 04 23:52:40 2016 -0500
     5.3 @@ -176,6 +176,11 @@
     5.4      int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
     5.5  
     5.6      /*
     5.7 +     * Get the usable bounds of a display (bounds minus menubar or whatever)
     5.8 +     */
     5.9 +    int (*GetDisplayUsableBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
    5.10 +
    5.11 +    /*
    5.12       * Get a list of the available display modes for a display.
    5.13       */
    5.14      void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
     6.1 --- a/src/video/SDL_video.c	Wed Apr 22 16:50:48 2015 -0400
     6.2 +++ b/src/video/SDL_video.c	Mon Jan 04 23:52:40 2016 -0500
     6.3 @@ -684,7 +684,26 @@
     6.4          rect->w = display->current_mode.w;
     6.5          rect->h = display->current_mode.h;
     6.6      }
     6.7 -    return 0;
     6.8 +    return 0;  /* !!! FIXME: should this be an error if (rect==NULL) ? */
     6.9 +}
    6.10 +
    6.11 +int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect)
    6.12 +{
    6.13 +    CHECK_DISPLAY_INDEX(displayIndex, -1);
    6.14 +
    6.15 +    if (rect) {
    6.16 +        SDL_VideoDisplay *display = &_this->displays[displayIndex];
    6.17 +
    6.18 +        if (_this->GetDisplayUsableBounds) {
    6.19 +            if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
    6.20 +                return 0;
    6.21 +            }
    6.22 +        }
    6.23 +
    6.24 +        /* Oh well, just give the entire display bounds. */
    6.25 +        return SDL_GetDisplayBounds(displayIndex, rect);
    6.26 +    }
    6.27 +    return 0;  /* !!! FIXME: should this be an error if (rect==NULL) ? */
    6.28  }
    6.29  
    6.30  int
     7.1 --- a/src/video/cocoa/SDL_cocoamodes.h	Wed Apr 22 16:50:48 2015 -0400
     7.2 +++ b/src/video/cocoa/SDL_cocoamodes.h	Mon Jan 04 23:52:40 2016 -0500
     7.3 @@ -35,6 +35,7 @@
     7.4  
     7.5  extern void Cocoa_InitModes(_THIS);
     7.6  extern int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
     7.7 +extern int Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
     7.8  extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
     7.9  extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    7.10  extern void Cocoa_QuitModes(_THIS);
     8.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Wed Apr 22 16:50:48 2015 -0400
     8.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Mon Jan 04 23:52:40 2016 -0500
     8.3 @@ -19,6 +19,7 @@
     8.4    3. This notice may not be removed or altered from any source distribution.
     8.5  */
     8.6  #include "../../SDL_internal.h"
     8.7 +#include "SDL_assert.h"
     8.8  
     8.9  #if SDL_VIDEO_DRIVER_COCOA
    8.10  
    8.11 @@ -338,6 +339,41 @@
    8.12      return 0;
    8.13  }
    8.14  
    8.15 +int
    8.16 +Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
    8.17 +{
    8.18 +    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
    8.19 +    const CGDirectDisplayID cgdisplay = displaydata->display;
    8.20 +    NSArray *screens = [NSScreen screens];
    8.21 +    NSScreen *screen = nil;
    8.22 +
    8.23 +    /* !!! FIXME: maybe track the NSScreen in SDL_DisplayData? */
    8.24 +    for (NSScreen *i in screens) {
    8.25 +        const CGDirectDisplayID thisDisplay = (CGDirectDisplayID) [[[i deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
    8.26 +        if (thisDisplay == cgdisplay) {
    8.27 +            screen = i;
    8.28 +            break;
    8.29 +        }
    8.30 +    }
    8.31 +
    8.32 +    SDL_assert(screen != nil);  /* didn't find it?! */
    8.33 +    if (screen == nil) {
    8.34 +        return -1;
    8.35 +    }
    8.36 +
    8.37 +    const CGRect cgrect = CGDisplayBounds(cgdisplay);
    8.38 +    const NSRect frame = [screen visibleFrame];
    8.39 +
    8.40 +    // !!! FIXME: I assume -[NSScreen visibleFrame] is relative to the origin of the screen in question and not the whole desktop.
    8.41 +    // !!! FIXME: The math vs CGDisplayBounds might be incorrect if that's not the case, though. Check this.
    8.42 +    rect->x = (int)(cgrect.origin.x + frame.origin.x);
    8.43 +    rect->y = (int)(cgrect.origin.y + frame.origin.y);
    8.44 +    rect->w = (int)frame.size.width;
    8.45 +    rect->h = (int)frame.size.height;
    8.46 +
    8.47 +    return 0;
    8.48 +}
    8.49 +
    8.50  void
    8.51  Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    8.52  {
     9.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Wed Apr 22 16:50:48 2015 -0400
     9.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Mon Jan 04 23:52:40 2016 -0500
     9.3 @@ -73,6 +73,7 @@
     9.4      device->VideoInit = Cocoa_VideoInit;
     9.5      device->VideoQuit = Cocoa_VideoQuit;
     9.6      device->GetDisplayBounds = Cocoa_GetDisplayBounds;
     9.7 +    device->GetDisplayUsableBounds = Cocoa_GetDisplayUsableBounds;
     9.8      device->GetDisplayModes = Cocoa_GetDisplayModes;
     9.9      device->SetDisplayMode = Cocoa_SetDisplayMode;
    9.10      device->PumpEvents = Cocoa_PumpEvents;
    10.1 --- a/src/video/uikit/SDL_uikitmodes.h	Wed Apr 22 16:50:48 2015 -0400
    10.2 +++ b/src/video/uikit/SDL_uikitmodes.h	Mon Jan 04 23:52:40 2016 -0500
    10.3 @@ -43,6 +43,7 @@
    10.4  extern void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
    10.5  extern int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    10.6  extern void UIKit_QuitModes(_THIS);
    10.7 +extern int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
    10.8  
    10.9  #endif /* _SDL_uikitmodes_h */
   10.10  
    11.1 --- a/src/video/uikit/SDL_uikitmodes.m	Wed Apr 22 16:50:48 2015 -0400
    11.2 +++ b/src/video/uikit/SDL_uikitmodes.m	Mon Jan 04 23:52:40 2016 -0500
    11.3 @@ -242,6 +242,26 @@
    11.4      return 0;
    11.5  }
    11.6  
    11.7 +int
    11.8 +UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
    11.9 +{
   11.10 +    /* the default function iterates displays to make a fake offset,
   11.11 +       as if all the displays were side-by-side, which is fine for iOS. */
   11.12 +    const int displayIndex = (int) (display - _this->displays);
   11.13 +    if (SDL_GetDisplayBounds(displayIndex, rect) < 0) {
   11.14 +        return -1;
   11.15 +    }
   11.16 +
   11.17 +    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
   11.18 +    const CGRect frame = [data->uiscreen applicationFrame];
   11.19 +    const float scale = (float) data->scale;
   11.20 +    rect->x += (int) (frame.origin.x * scale);
   11.21 +    rect->y += (int) (frame.origin.y * scale);
   11.22 +    rect->w = (int) (frame.size.width * scale);
   11.23 +    rect->h = (int) (frame.size.height * scale);
   11.24 +    return 0;
   11.25 +}
   11.26 +
   11.27  void
   11.28  UIKit_QuitModes(_THIS)
   11.29  {
    12.1 --- a/src/video/uikit/SDL_uikitvideo.m	Wed Apr 22 16:50:48 2015 -0400
    12.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Mon Jan 04 23:52:40 2016 -0500
    12.3 @@ -85,6 +85,7 @@
    12.4      device->SetWindowFullscreen = UIKit_SetWindowFullscreen;
    12.5      device->DestroyWindow = UIKit_DestroyWindow;
    12.6      device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
    12.7 +    device->GetDisplayUsableBounds = UIKit_GetDisplayUsableBounds;
    12.8  
    12.9  #if SDL_IPHONE_KEYBOARD
   12.10      device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
    13.1 --- a/src/video/windows/SDL_windowsmodes.c	Wed Apr 22 16:50:48 2015 -0400
    13.2 +++ b/src/video/windows/SDL_windowsmodes.c	Mon Jan 04 23:52:40 2016 -0500
    13.3 @@ -332,6 +332,43 @@
    13.4      return data->DiagDPI != 0.0f ? 0 : -1;
    13.5  }
    13.6  
    13.7 +int
    13.8 +WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
    13.9 +{
   13.10 +    const SDL_DisplayModeData *data = (const SDL_DisplayModeData *) display->current_mode.driverdata;
   13.11 +    const DEVMODE *pDevMode = &data->DeviceMode;
   13.12 +    POINT pt = {
   13.13 +        /* !!! FIXME: no scale, right? */
   13.14 +        (LONG) (pDevMode->dmPosition.x + (pDevMode->dmPelsWidth / 2)),
   13.15 +        (LONG) (pDevMode->dmPosition.y + (pDevMode->dmPelsHeight / 2))
   13.16 +    };
   13.17 +    HMONITOR hmon = MonitorFromPoint(&pt, MONITOR_DEFAULTTONULL);
   13.18 +    MONITORINFO minfo;
   13.19 +    const RECT *work;
   13.20 +    BOOL rc = FALSE;
   13.21 +
   13.22 +    SDL_assert(hmon != NULL);
   13.23 +
   13.24 +    if (hmon != NULL) {
   13.25 +        SDL_zero(minfo);
   13.26 +        minfo.cbSize = sizeof (MONITORINFO);
   13.27 +        rc = GetMonitorInfo(hmon, &minfo);
   13.28 +        SDL_assert(rc);
   13.29 +    }
   13.30 +
   13.31 +    if (!rc) {
   13.32 +        return SDL_SetError("Couldn't find monitor data");
   13.33 +    }
   13.34 +
   13.35 +    work = &minfo->rcWork;
   13.36 +    rect->x = (int)SDL_ceil(work->left * data->ScaleX);
   13.37 +    rect->y = (int)SDL_ceil(work->top * data->ScaleY);
   13.38 +    rect->w = (int)SDL_ceil((work->right - work->left) * data->ScaleX);
   13.39 +    rect->h = (int)SDL_ceil((work->bottom - work->top) * data->ScaleY);
   13.40 +
   13.41 +    return 0;
   13.42 +}
   13.43 +
   13.44  void
   13.45  WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
   13.46  {
    14.1 --- a/src/video/windows/SDL_windowsmodes.h	Wed Apr 22 16:50:48 2015 -0400
    14.2 +++ b/src/video/windows/SDL_windowsmodes.h	Mon Jan 04 23:52:40 2016 -0500
    14.3 @@ -40,6 +40,7 @@
    14.4  
    14.5  extern int WIN_InitModes(_THIS);
    14.6  extern int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
    14.7 +extern int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
    14.8  extern int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
    14.9  extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   14.10  extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    15.1 --- a/src/video/windows/SDL_windowsvideo.c	Wed Apr 22 16:50:48 2015 -0400
    15.2 +++ b/src/video/windows/SDL_windowsvideo.c	Mon Jan 04 23:52:40 2016 -0500
    15.3 @@ -124,6 +124,7 @@
    15.4      device->VideoInit = WIN_VideoInit;
    15.5      device->VideoQuit = WIN_VideoQuit;
    15.6      device->GetDisplayBounds = WIN_GetDisplayBounds;
    15.7 +    device->GetDisplayUsableBounds = WIN_GetDisplayUsableBounds;
    15.8      device->GetDisplayDPI = WIN_GetDisplayDPI;
    15.9      device->GetDisplayModes = WIN_GetDisplayModes;
   15.10      device->SetDisplayMode = WIN_SetDisplayMode;
    16.1 --- a/src/video/x11/SDL_x11modes.c	Wed Apr 22 16:50:48 2015 -0400
    16.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Jan 04 23:52:40 2016 -0500
    16.3 @@ -1073,6 +1073,43 @@
    16.4      return data->ddpi != 0.0f ? 0 : -1;
    16.5  }
    16.6  
    16.7 +int
    16.8 +X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect)
    16.9 +{
   16.10 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   16.11 +    Display *display = data->display;
   16.12 +    Atom _NET_WORKAREA;
   16.13 +    int status, real_format;
   16.14 +    int retval = -1;
   16.15 +    Atom real_type;
   16.16 +    unsigned long items_read = 0, items_left = 0;
   16.17 +    unsigned char *propdata = NULL;
   16.18 +
   16.19 +    if (X11_GetDisplayBounds(_this, sdl_display, rect) < 0) {
   16.20 +        return -1;
   16.21 +    }
   16.22 +
   16.23 +    _NET_WORKAREA = X11_XInternAtom(display, "_NET_WORKAREA", False);
   16.24 +    status = X11_XGetWindowProperty(display, DefaultRootWindow(display),
   16.25 +                                    _NET_WORKAREA, 0L, 4L, False, XA_CARDINAL,
   16.26 +                                    &real_type, &real_format, &items_read,
   16.27 +                                    &items_left, &propdata);
   16.28 +    if ((status == Success) && (items_read >= 4)) {
   16.29 +        retval = 0;
   16.30 +        const long *p = (long*) propdata;
   16.31 +        const SDL_Rect usable = { (int)p[0], (int)p[1], (int)p[2], (int)p[3] };
   16.32 +        if (!SDL_IntersectRect(rect, &usable, rect)) {
   16.33 +            SDL_zerop(rect);
   16.34 +        }
   16.35 +    }
   16.36 +
   16.37 +    if (propdata) {
   16.38 +        X11_XFree(propdata);
   16.39 +    }
   16.40 +
   16.41 +    return retval;
   16.42 +}
   16.43 +
   16.44  #endif /* SDL_VIDEO_DRIVER_X11 */
   16.45  
   16.46  /* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/src/video/x11/SDL_x11modes.h	Wed Apr 22 16:50:48 2015 -0400
    17.2 +++ b/src/video/x11/SDL_x11modes.h	Mon Jan 04 23:52:40 2016 -0500
    17.3 @@ -77,6 +77,7 @@
    17.4  extern Uint32 X11_GetPixelFormatFromVisualInfo(Display * display,
    17.5                                                 XVisualInfo * vinfo);
    17.6  extern int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect);
    17.7 +extern int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect);
    17.8  extern int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi);
    17.9  
   17.10  #endif /* _SDL_x11modes_h */
    18.1 --- a/src/video/x11/SDL_x11video.c	Wed Apr 22 16:50:48 2015 -0400
    18.2 +++ b/src/video/x11/SDL_x11video.c	Mon Jan 04 23:52:40 2016 -0500
    18.3 @@ -218,6 +218,7 @@
    18.4      device->VideoQuit = X11_VideoQuit;
    18.5      device->GetDisplayModes = X11_GetDisplayModes;
    18.6      device->GetDisplayBounds = X11_GetDisplayBounds;
    18.7 +    device->GetDisplayUsableBounds = X11_GetDisplayUsableBounds;
    18.8      device->GetDisplayDPI = X11_GetDisplayDPI;
    18.9      device->SetDisplayMode = X11_SetDisplayMode;
   18.10      device->SuspendScreenSaver = X11_SuspendScreenSaver;
    19.1 --- a/test/Makefile.in	Wed Apr 22 16:50:48 2015 -0400
    19.2 +++ b/test/Makefile.in	Mon Jan 04 23:52:40 2016 -0500
    19.3 @@ -14,6 +14,7 @@
    19.4  	testatomic$(EXE) \
    19.5  	testaudioinfo$(EXE) \
    19.6  	testautomation$(EXE) \
    19.7 +	testbounds$(EXE) \
    19.8  	testdraw2$(EXE) \
    19.9  	testdrawchessboard$(EXE) \
   19.10  	testdropfile$(EXE) \
   19.11 @@ -270,6 +271,9 @@
   19.12  testdisplayinfo$(EXE): $(srcdir)/testdisplayinfo.c
   19.13  	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   19.14  
   19.15 +testbounds$(EXE): $(srcdir)/testbounds.c
   19.16 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   19.17 +
   19.18  controllermap$(EXE): $(srcdir)/controllermap.c
   19.19  	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   19.20  
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/testbounds.c	Mon Jan 04 23:52:40 2016 -0500
    20.3 @@ -0,0 +1,39 @@
    20.4 +/*
    20.5 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    20.6 +
    20.7 +  This software is provided 'as-is', without any express or implied
    20.8 +  warranty.  In no event will the authors be held liable for any damages
    20.9 +  arising from the use of this software.
   20.10 +
   20.11 +  Permission is granted to anyone to use this software for any purpose,
   20.12 +  including commercial applications, and to alter it and redistribute it
   20.13 +  freely.
   20.14 +*/
   20.15 +
   20.16 +#include "SDL.h"
   20.17 +
   20.18 +int main(int argc, char **argv)
   20.19 +{
   20.20 +    int total, i;
   20.21 +
   20.22 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   20.23 +        SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError());
   20.24 +    }
   20.25 +
   20.26 +    total = SDL_GetNumVideoDisplays();
   20.27 +    for (i = 0; i < total; i++) {
   20.28 +        SDL_Rect bounds = { -1,-1,-1,-1 }, usable = { -1,-1,-1,-1 };
   20.29 +        SDL_GetDisplayBounds(i, &bounds);
   20.30 +        SDL_GetDisplayUsableBounds(i, &usable);
   20.31 +        SDL_Log("Display #%d ('%s'): bounds={(%d,%d),%dx%d}, usable={(%d,%d),%dx%d}",
   20.32 +                i, SDL_GetDisplayName(i),
   20.33 +                bounds.x, bounds.y, bounds.w, bounds.h,
   20.34 +                usable.x, usable.y, usable.w, usable.h);
   20.35 +    }
   20.36 +
   20.37 +    SDL_Quit();
   20.38 +    return 0;
   20.39 +}
   20.40 +
   20.41 +/* vi: set ts=4 sw=4 expandtab: */
   20.42 +