Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Xrandr support in the X11 target.
    Fixes Bugzilla #109, and as a bonus, Bugzilla #145, too!
  • Loading branch information
icculus committed Mar 22, 2006
1 parent 6ee00c2 commit e135810
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 10 deletions.
42 changes: 41 additions & 1 deletion configure.in
Expand Up @@ -789,9 +789,11 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [default=yes
, enable_x11_shared=yes)

case "$host" in
*-*-darwin*)
*-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
x11_lib='/usr/X11R6/lib/libX11.6.dylib'
x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
;;
*-*-osf*)
x11_lib='libX11.so'
Expand All @@ -810,6 +812,12 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [default=yes
if test "x$x11ext_lib" = "x"; then
x11ext_lib=[`ls $path/libXext.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
fi
if test "x$xrender_lib" = "x"; then
xrender_lib=[`ls $path/libXrender.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
fi
if test "x$xrandr_lib" = "x"; then
xrandr_lib=[`ls $path/libXrandr.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
fi
done
;;
esac
Expand All @@ -833,6 +841,7 @@ AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [default=yes
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
else
enable_x11_shared=no
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
fi
have_video=yes
Expand Down Expand Up @@ -884,6 +893,37 @@ AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen
AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
fi
AC_ARG_ENABLE(video-x11-xrandr,
AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [default=yes]]),
, enable_video_x11_xrandr=yes)
if test x$enable_video_x11_xrandr = xyes; then
definitely_enable_video_x11_xrandr=no
AC_CHECK_HEADER(X11/extensions/Xrandr.h,
have_xrandr_h_hdr=yes,
have_xrandr_h_hdr=no,
[#include <X11/Xlib.h>
])
if test x$have_xrandr_h_hdr = xyes; then
if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
echo "-- dynamic libXrender -> $xrender_lib"
echo "-- dynamic libXrandr -> $xrandr_lib"
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
definitely_enable_video_x11_xrandr=yes
else
AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
definitely_enable_video_x11_xrandr=yes
fi
fi
fi
fi

if test x$definitely_enable_video_x11_xrandr = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
fi
fi
fi
}
Expand Down
14 changes: 13 additions & 1 deletion docs/html/sdlenvvars.html
Expand Up @@ -576,6 +576,18 @@
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_X11_NO_XRANDR</TT
></DT
><DD
><P
>If set, don't attempt to use the Xrandr extension for resolution mode
switching. Normally Xrandr takes precedence over the XF86VidMode
extension, so setting this environment variable will cause the
XF86VidMode extension to be used if it is available.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_YUV_DIRECT</TT
></DT
><DD
Expand Down Expand Up @@ -1209,4 +1221,4 @@
></DIV
></BODY
></HTML
>
>
3 changes: 3 additions & 0 deletions include/SDL_config.h.in
Expand Up @@ -278,9 +278,12 @@
#undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
#undef SDL_VIDEO_DRIVER_X11_VIDMODE
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
#undef SDL_VIDEO_DRIVER_X11_XME
#undef SDL_VIDEO_DRIVER_X11_XRANDR
#undef SDL_VIDEO_DRIVER_X11_XV
#undef SDL_VIDEO_DRIVER_XBIOS

Expand Down
22 changes: 18 additions & 4 deletions src/video/x11/SDL_x11dyn.c
Expand Up @@ -21,13 +21,11 @@
*/
#include "SDL_config.h"

#if 0
#define DEBUG_DYNAMIC_X11 1
#endif
#define DEBUG_DYNAMIC_X11 0

#include "SDL_x11dyn.h"

#ifdef DEBUG_DYNAMIC_X11
#if DEBUG_DYNAMIC_X11
#include <stdio.h>
#endif

Expand All @@ -39,6 +37,10 @@ static const char *x11_library = SDL_VIDEO_DRIVER_X11_DYNAMIC;
static void *x11_handle = NULL;
static const char *x11ext_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT;
static void *x11ext_handle = NULL;
static const char *xrender_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER;
static void *xrender_handle = NULL;
static const char *xrandr_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR;
static void *xrandr_handle = NULL;

typedef struct
{
Expand All @@ -54,6 +56,8 @@ static void *X11_GetSym(const char *fnname, int *rc)
{
{ x11_handle, "libX11" },
{ x11ext_handle, "libX11ext" },
{ xrender_handle, "libXrender" },
{ xrandr_handle, "libXrandr" },
};

for (i = 0; i < (sizeof (libs) / sizeof (libs[0])); i++)
Expand Down Expand Up @@ -130,6 +134,14 @@ void SDL_X11_UnloadSymbols(void)
SDL_UnloadObject(x11ext_handle);
x11ext_handle = NULL;
}
if (xrender_handle != NULL) {
SDL_UnloadObject(xrender_handle);
xrender_handle = NULL;
}
if (xrandr_handle != NULL) {
SDL_UnloadObject(xrandr_handle);
xrandr_handle = NULL;
}
}
}
#endif
Expand All @@ -146,6 +158,8 @@ int SDL_X11_LoadSymbols(void)
int *thismod = NULL;
x11_handle = SDL_LoadObject(x11_library);
x11ext_handle = SDL_LoadObject(x11ext_library);
xrender_handle = SDL_LoadObject(xrender_library);
xrandr_handle = SDL_LoadObject(xrandr_library);
#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
#define SDL_X11_SYM(a,fn,x,y,z) p##fn = X11_GetSym(#fn,thismod);
#include "SDL_x11sym.h"
Expand Down
4 changes: 4 additions & 0 deletions src/video/x11/SDL_x11dyn.h
Expand Up @@ -38,6 +38,10 @@
#include <X11/extensions/XShm.h>
#endif

#if SDL_VIDEO_DRIVER_X11_XRANDR
#include <X11/extensions/Xrandr.h>
#endif

/*
* When using the "dynamic X11" functionality, we duplicate all the Xlib
* symbols that would be referenced by SDL inside of SDL itself.
Expand Down

0 comments on commit e135810

Please sign in to comment.