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