Added X11 Xinerama support - fullscreen starts on screen 0
authorSam Lantinga <slouken@libsdl.org>
Sat, 03 Nov 2001 17:03:16 +0000
changeset 22724878c14b391
parent 226 bb72c418a1f9
child 228 153f221b7d48
Added X11 Xinerama support - fullscreen starts on screen 0
configure.in
docs.html
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11video.h
     1.1 --- a/configure.in	Fri Nov 02 22:41:32 2001 +0000
     1.2 +++ b/configure.in	Sat Nov 03 17:03:16 2001 +0000
     1.3 @@ -602,6 +602,26 @@
     1.4                      SYSTEM_LIBS="$SYSTEM_LIBS -lXv"
     1.5                  fi
     1.6              fi
     1.7 +            AC_ARG_ENABLE(video-x11-xinerama,
     1.8 +[  --enable-video-x11-xinerama   enable X11 Xinerama support [default=yes]],
     1.9 +                            , enable_video_x11_xinerama=yes)
    1.10 +            if test x$enable_video_x11_xinerama = xyes; then
    1.11 +                AC_MSG_CHECKING(for X11 Xinerama support)
    1.12 +                video_x11_xinerama=no
    1.13 +                AC_TRY_COMPILE([
    1.14 +                 #include <X11/Xlib.h>
    1.15 +                 #include <X11/extensions/Xinerama.h>
    1.16 +                ],[
    1.17 +                 XineramaScreenInfo *xinerama;
    1.18 +                ],[
    1.19 +                video_x11_xinerama=yes
    1.20 +                ])
    1.21 +                AC_MSG_RESULT($video_x11_xinerama)
    1.22 +                if test x$video_x11_xinerama = xyes; then
    1.23 +                    CFLAGS="$CFLAGS -DHAVE_XINERAMA"
    1.24 +                    SYSTEM_LIBS="$SYSTEM_LIBS -lXinerama"
    1.25 +                fi
    1.26 +            fi
    1.27          fi
    1.28      fi
    1.29  }
     2.1 --- a/docs.html	Fri Nov 02 22:41:32 2001 +0000
     2.2 +++ b/docs.html	Sat Nov 03 17:03:16 2001 +0000
     2.3 @@ -16,6 +16,7 @@
     2.4  Major changes since SDL 1.0.0:
     2.5  </H2>
     2.6  <UL>
     2.7 +	<LI> 1.2.3: Added X11 Xinerama support - fullscreen starts on screen 0
     2.8  	<LI> 1.2.3: Added platform independent OpenGL header - SDL_opengl.h
     2.9  	<LI> 1.2.3: Fixed flashing the screen when creating a window on BeOS
    2.10  	<LI> 1.2.3: Added double-buffering support for SVGAlib (thanks Kutak!)
     3.1 --- a/src/video/x11/SDL_x11modes.c	Fri Nov 02 22:41:32 2001 +0000
     3.2 +++ b/src/video/x11/SDL_x11modes.c	Sat Nov 03 17:03:16 2001 +0000
     3.3 @@ -39,6 +39,9 @@
     3.4  #include "SDL_x11modes_c.h"
     3.5  #include "SDL_x11image_c.h"
     3.6  
     3.7 +#ifdef HAVE_XINERAMA
     3.8 +#include <X11/extensions/Xinerama.h>
     3.9 +#endif 
    3.10  
    3.11  #ifdef XFREE86_VM
    3.12  Bool XVidMode(GetModeInfo, (Display *dpy, int scr, XF86VidModeModeInfo *info))
    3.13 @@ -99,10 +102,11 @@
    3.14               XVidMode(GetAllModeLines, (SDL_Display,SDL_Screen,&nmodes,&modes))){
    3.15              qsort(modes, nmodes, sizeof *modes, cmpmodes);
    3.16  #ifdef XFREE86_DEBUG
    3.17 -  printf("Available modes:\n");
    3.18 -  for ( i = 0; i < nmodes; ++i ) {
    3.19 -    printf("Mode %d: %dx%d\n", i, modes[i]->hdisplay, modes[i]->vdisplay);
    3.20 -  }
    3.21 +            printf("Available modes:\n");
    3.22 +            for ( i = 0; i < nmodes; ++i ) {
    3.23 +                printf("Mode %d: %dx%d\n", i,
    3.24 +                        modes[i]->hdisplay, modes[i]->vdisplay);
    3.25 +            }
    3.26  #endif
    3.27              for ( i = nmodes-1; i > 0 ; --i ) {
    3.28                  if ( (modes[i]->hdisplay >= width) &&
    3.29 @@ -238,8 +242,8 @@
    3.30  #ifdef X_XF86VidModeGetDotClocks  /* Compiled under XFree86 4.0 */
    3.31                  /* Earlier X servers hang when doing vidmode */
    3.32  		if ( vm_major < 2 ) {
    3.33 -#ifdef DEBUG_XF86
    3.34 -  printf("Compiled under XFree86 4.0, server is XFree86 3.X\n");
    3.35 +#ifdef XFREE86_DEBUG
    3.36 +                    printf("Compiled under XFree86 4.0, server is XFree86 3.X\n");
    3.37  #endif
    3.38                      buggy_X11 = 1;
    3.39                  }
    3.40 @@ -335,18 +339,50 @@
    3.41          }
    3.42      }
    3.43  
    3.44 -#ifdef DEBUG_XF86
    3.45 +#ifdef XFREE86_DEBUG
    3.46      if ( use_vidmode ) {
    3.47 -        fprintf(stderr, "XFree86 VidMode is enabled\n");
    3.48 +        printf("XFree86 VidMode is enabled\n");
    3.49      }
    3.50      if ( SDL_modelist ) {
    3.51 -        fprintf(stderr, "X11 video mode list:\n");
    3.52 +        printf("X11 video mode list:\n");
    3.53          for ( i=0; SDL_modelist[i]; ++i ) {
    3.54 -            fprintf(stderr, "\t%dx%d\n",
    3.55 -                SDL_modelist[i]->w, SDL_modelist[i]->h);
    3.56 +            printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h);
    3.57          }
    3.58      }
    3.59 -#endif /* DEBUG_XF86 */
    3.60 +#endif /* XFREE86_DEBUG */
    3.61 +
    3.62 +    /* The default X/Y fullscreen offset is 0/0 */
    3.63 +    xinerama_x = 0;
    3.64 +    xinerama_y = 0;
    3.65 +
    3.66 +#ifdef HAVE_XINERAMA
    3.67 +    /* Query Xinerama extention */
    3.68 +    if ( XineramaQueryExtension(SDL_Display, &i, &i) &&
    3.69 +         XineramaIsActive(SDL_Display) ) {
    3.70 +        /* Find out which screen is the zero'th one */
    3.71 +        int screens;
    3.72 +        XineramaScreenInfo *xinerama;
    3.73 +
    3.74 +#ifdef XINERAMA_DEBUG
    3.75 +        printf("X11 detected Xinerama:\n");
    3.76 +#endif
    3.77 +        xinerama = XineramaQueryScreens(SDL_Display, &screens);
    3.78 +        for ( i = 0; i < screens; i++ ) {
    3.79 +#ifdef XINERAMA_DEBUG
    3.80 +            printf("xinerama %d: %dx%d+%d+%d\n",
    3.81 +                xinerama[i].screen_number,
    3.82 +                xinerama[i].width, xinerama[i].height,
    3.83 +                xinerama[i].x_org, xinerama[i].y_org);
    3.84 +#endif
    3.85 +            if ( xinerama[i].screen_number == 0 ) {
    3.86 +                xinerama_x = xinerama[i].x_org;
    3.87 +                xinerama_y = xinerama[i].y_org;
    3.88 +            }
    3.89 +        }
    3.90 +        XFree(xinerama);
    3.91 +    }
    3.92 +#endif /* HAVE_XINERAMA */
    3.93 +
    3.94      return 0;
    3.95  }
    3.96  
    3.97 @@ -390,13 +426,15 @@
    3.98      int x, y;
    3.99      int real_w, real_h;
   3.100  
   3.101 +    x = xinerama_x;
   3.102 +    y = xinerama_y;
   3.103      if ( currently_fullscreen ) {
   3.104          /* Switch resolution and cover it with the FSwindow */
   3.105 -        move_cursor_to(this, 0, 0);
   3.106 +        move_cursor_to(this, x, y);
   3.107          set_best_resolution(this, current_w, current_h);
   3.108 -        move_cursor_to(this, 0, 0);
   3.109 +        move_cursor_to(this, x, y);
   3.110          get_real_resolution(this, &real_w, &real_h);
   3.111 -        XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
   3.112 +        XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h);
   3.113          move_cursor_to(this, real_w/2, real_h/2);
   3.114  
   3.115          /* Center and reparent the drawing window */
     4.1 --- a/src/video/x11/SDL_x11video.h	Fri Nov 02 22:41:32 2001 +0000
     4.2 +++ b/src/video/x11/SDL_x11video.h	Sat Nov 03 17:03:16 2001 +0000
     4.3 @@ -47,6 +47,7 @@
     4.4  #define XVidMode(func, args)	XF86VidMode##func args
     4.5  #endif
     4.6  #endif /* XFREE86_VM */
     4.7 +
     4.8  #include <string.h>
     4.9  
    4.10  #include "SDL_mouse.h"
    4.11 @@ -120,6 +121,8 @@
    4.12          int x, y;
    4.13      } saved_view;
    4.14  #endif
    4.15 +    int xinerama_x;
    4.16 +    int xinerama_y;
    4.17      int use_vidmode;
    4.18      int currently_fullscreen;
    4.19  
    4.20 @@ -169,6 +172,8 @@
    4.21  #define SDL_modelist		(this->hidden->modelist)
    4.22  #define saved_mode		(this->hidden->saved_mode)
    4.23  #define saved_view		(this->hidden->saved_view)
    4.24 +#define xinerama_x		(this->hidden->xinerama_x)
    4.25 +#define xinerama_y		(this->hidden->xinerama_y)
    4.26  #define use_vidmode		(this->hidden->use_vidmode)
    4.27  #define currently_fullscreen	(this->hidden->currently_fullscreen)
    4.28  #define switch_waiting		(this->hidden->switch_waiting)