src/video/x11/SDL_x11modes.c
changeset 10019 36f7e8084508
parent 10015 d809627808b1
child 10030 061b1b467bd3
     1.1 --- a/src/video/x11/SDL_x11modes.c	Wed Apr 22 16:50:48 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Jan 04 23:52:40 2016 -0500
     1.3 @@ -1073,6 +1073,43 @@
     1.4      return data->ddpi != 0.0f ? 0 : -1;
     1.5  }
     1.6  
     1.7 +int
     1.8 +X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect)
     1.9 +{
    1.10 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.11 +    Display *display = data->display;
    1.12 +    Atom _NET_WORKAREA;
    1.13 +    int status, real_format;
    1.14 +    int retval = -1;
    1.15 +    Atom real_type;
    1.16 +    unsigned long items_read = 0, items_left = 0;
    1.17 +    unsigned char *propdata = NULL;
    1.18 +
    1.19 +    if (X11_GetDisplayBounds(_this, sdl_display, rect) < 0) {
    1.20 +        return -1;
    1.21 +    }
    1.22 +
    1.23 +    _NET_WORKAREA = X11_XInternAtom(display, "_NET_WORKAREA", False);
    1.24 +    status = X11_XGetWindowProperty(display, DefaultRootWindow(display),
    1.25 +                                    _NET_WORKAREA, 0L, 4L, False, XA_CARDINAL,
    1.26 +                                    &real_type, &real_format, &items_read,
    1.27 +                                    &items_left, &propdata);
    1.28 +    if ((status == Success) && (items_read >= 4)) {
    1.29 +        retval = 0;
    1.30 +        const long *p = (long*) propdata;
    1.31 +        const SDL_Rect usable = { (int)p[0], (int)p[1], (int)p[2], (int)p[3] };
    1.32 +        if (!SDL_IntersectRect(rect, &usable, rect)) {
    1.33 +            SDL_zerop(rect);
    1.34 +        }
    1.35 +    }
    1.36 +
    1.37 +    if (propdata) {
    1.38 +        X11_XFree(propdata);
    1.39 +    }
    1.40 +
    1.41 +    return retval;
    1.42 +}
    1.43 +
    1.44  #endif /* SDL_VIDEO_DRIVER_X11 */
    1.45  
    1.46  /* vi: set ts=4 sw=4 expandtab: */