src/video/x11/SDL_x11video.h
author Ryan C. Gordon <icculus@icculus.org>
Wed, 22 Mar 2006 11:13:58 +0000
changeset 1589 34cca785be57
parent 1545 8d9bb0cf2c2a
child 1659 14717b52abc0
child 1765 c2c6ff414ef5
permissions -rw-r--r--
Xrandr support in the X11 target.

Fixes Bugzilla #109, and as a bonus, Bugzilla #145, too!
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 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 #ifndef _SDL_x11video_h
    25 #define _SDL_x11video_h
    26 
    27 #include <X11/Xlib.h>
    28 #include <X11/Xutil.h>
    29 #include <X11/Xatom.h>
    30 
    31 #include "SDL_mouse.h"
    32 #include "../SDL_sysvideo.h"
    33 
    34 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE
    35 #include "../Xext/extensions/xf86dga.h"
    36 #endif
    37 #if SDL_VIDEO_DRIVER_X11_VIDMODE
    38 #include "../Xext/extensions/xf86vmode.h"
    39 #endif
    40 #if SDL_VIDEO_DRIVER_X11_XME
    41 #include "../Xext/extensions/xme.h"
    42 #endif
    43 #if SDL_VIDEO_DRIVER_X11_XRANDR
    44 #include <X11/extensions/Xrandr.h>
    45 #endif
    46 
    47 #include "SDL_x11dyn.h"
    48 
    49 /* Hidden "this" pointer for the video functions */
    50 #define _THIS	SDL_VideoDevice *this
    51 
    52 /* Private display data */
    53 struct SDL_PrivateVideoData {
    54     int local_X11;		/* Flag: true if local display */
    55     Display *X11_Display;	/* Used for events and window management */
    56     Display *GFX_Display;	/* Used for graphics and colormap stuff */
    57     Visual *SDL_Visual;		/* The visual used by our window */
    58     Window WMwindow;		/* Input window, managed by window manager */
    59     Window FSwindow;		/* Fullscreen window, completely unmanaged */
    60     Window SDL_Window;		/* Shared by both displays (no X security?) */
    61     Atom WM_DELETE_WINDOW;	/* "close-window" protocol atom */
    62     WMcursor *BlankCursor;	/* The invisible cursor */
    63     XIM X11_IM;		/* Used to communicate with the input method (IM) server */
    64     XIC X11_IC;		/* Used for retaining the state, properties, and semantics of communication with                                                  the input method (IM) server */
    65 
    66     char *SDL_windowid;		/* Flag: true if we have been passed a window */
    67 
    68     /* Direct Graphics Access extension information */
    69     int using_dga;
    70 
    71 #ifndef NO_SHARED_MEMORY
    72     /* MIT shared memory extension information */
    73     int use_mitshm;
    74     XShmSegmentInfo shminfo;
    75 #endif
    76 
    77     /* The variables used for displaying graphics */
    78     XImage *Ximage;		/* The X image for our window */
    79     GC	gc;			/* The graphic context for drawing */
    80 
    81     /* The current width and height of the fullscreen mode */
    82     int window_w;
    83     int window_h;
    84 
    85     /* Support for internal mouse warping */
    86     struct {
    87         int x;
    88         int y;
    89     } mouse_last;
    90     struct {
    91         int numerator;
    92         int denominator;
    93         int threshold;
    94     } mouse_accel;
    95     int mouse_relative;
    96 
    97     /* The current list of available video modes */
    98     SDL_Rect **modelist;
    99 
   100     /* available visuals of interest to us, sorted deepest first */
   101     struct {
   102 	Visual *visual;
   103 	int depth;		/* number of significant bits/pixel */
   104 	int bpp;		/* pixel quantum in bits */
   105     } visuals[2*5];		/* at most 2 entries for 8, 15, 16, 24, 32 */
   106     int nvisuals;
   107 
   108     Visual *vis;		/* current visual in use */
   109     int depth;			/* current visual depth (not bpp) */
   110 
   111     /* Variables used by the X11 video mode code */
   112 #if SDL_VIDEO_DRIVER_X11_VIDMODE
   113     SDL_NAME(XF86VidModeModeInfo) saved_mode;
   114     struct {
   115         int x, y;
   116     } saved_view;
   117 #endif
   118 #if SDL_VIDEO_DRIVER_X11_XME /* XiG XME fullscreen */
   119     int use_xme;
   120     XiGMiscResolutionInfo saved_res;
   121 #endif
   122 #if SDL_VIDEO_DRIVER_X11_XRANDR
   123     XRRScreenConfiguration* screen_config;
   124     int saved_size_id;
   125     Rotation saved_rotation;
   126 #endif
   127 
   128     int xinerama_x;
   129     int xinerama_y;
   130     int use_vidmode;
   131     int use_xrandr;
   132     int currently_fullscreen;
   133 
   134     /* Automatic mode switching support (entering/leaving fullscreen) */
   135     Uint32 switch_waiting;
   136     Uint32 switch_time;
   137 
   138     /* Prevent too many XSync() calls */
   139     int blit_queued;
   140 
   141     /* Colormap handling */
   142     Colormap DisplayColormap;	/* The default display colormap */
   143     Colormap XColorMap;		/* The current window colormap */
   144     int *XPixels;		/* pixels value allocation counts */
   145     float gamma_saved[3];	/* Saved gamma values for VidMode gamma */
   146     int gamma_changed;		/* flag: has VidMode gamma been modified? */
   147 
   148     short *iconcolors;		/* List of colors used by the icon */
   149 };
   150 
   151 /* Old variable names */
   152 #define local_X11		(this->hidden->local_X11)
   153 #define SDL_Display		(this->hidden->X11_Display)
   154 #define GFX_Display		(this->hidden->GFX_Display)
   155 #define SDL_Screen		DefaultScreen(this->hidden->X11_Display)
   156 #define SDL_Visual		(this->hidden->vis)
   157 #define SDL_Root		RootWindow(SDL_Display, SDL_Screen)
   158 #define WMwindow		(this->hidden->WMwindow)
   159 #define FSwindow		(this->hidden->FSwindow)
   160 #define SDL_Window		(this->hidden->SDL_Window)
   161 #define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
   162 #define SDL_BlankCursor		(this->hidden->BlankCursor)
   163 #define SDL_IM			(this->hidden->X11_IM)
   164 #define SDL_IC			(this->hidden->X11_IC)
   165 #define SDL_windowid		(this->hidden->SDL_windowid)
   166 #define using_dga		(this->hidden->using_dga)
   167 #define use_mitshm		(this->hidden->use_mitshm)
   168 #define shminfo			(this->hidden->shminfo)
   169 #define SDL_Ximage		(this->hidden->Ximage)
   170 #define SDL_GC			(this->hidden->gc)
   171 #define window_w		(this->hidden->window_w)
   172 #define window_h		(this->hidden->window_h)
   173 #define mouse_last		(this->hidden->mouse_last)
   174 #define mouse_accel		(this->hidden->mouse_accel)
   175 #define mouse_relative		(this->hidden->mouse_relative)
   176 #define SDL_modelist		(this->hidden->modelist)
   177 #define saved_mode		(this->hidden->saved_mode)
   178 #define saved_view		(this->hidden->saved_view)
   179 #define use_xme			(this->hidden->use_xme)
   180 #define saved_res		(this->hidden->saved_res)
   181 #define use_xrandr		(this->hidden->use_xrandr)
   182 #define screen_config		(this->hidden->screen_config)
   183 #define saved_size_id		(this->hidden->saved_size_id)
   184 #define saved_rotation		(this->hidden->saved_rotation)
   185 #define xinerama_x		(this->hidden->xinerama_x)
   186 #define xinerama_y		(this->hidden->xinerama_y)
   187 #define use_vidmode		(this->hidden->use_vidmode)
   188 #define currently_fullscreen	(this->hidden->currently_fullscreen)
   189 #define switch_waiting		(this->hidden->switch_waiting)
   190 #define switch_time		(this->hidden->switch_time)
   191 #define blit_queued		(this->hidden->blit_queued)
   192 #define SDL_DisplayColormap	(this->hidden->DisplayColormap)
   193 #define SDL_PrivateColormap	(this->hidden->PrivateColormap)
   194 #define SDL_XColorMap		(this->hidden->XColorMap)
   195 #define SDL_XPixels		(this->hidden->XPixels)
   196 #define gamma_saved		(this->hidden->gamma_saved)
   197 #define gamma_changed		(this->hidden->gamma_changed)
   198 #define SDL_iconcolors		(this->hidden->iconcolors)
   199 /* Some versions of XFree86 have bugs - detect if this is one of them */
   200 #define BUGGY_XFREE86(condition, buggy_version) \
   201 ((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
   202  (VendorRelease(SDL_Display) condition buggy_version))
   203 
   204 #endif /* _SDL_x11video_h */