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
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
#ifndef _SDL_x11video_h
slouken@0
    25
#define _SDL_x11video_h
slouken@0
    26
slouken@0
    27
#include <X11/Xlib.h>
slouken@0
    28
#include <X11/Xutil.h>
slouken@0
    29
#include <X11/Xatom.h>
icculus@1168
    30
slouken@1361
    31
#include "SDL_mouse.h"
slouken@1361
    32
#include "../SDL_sysvideo.h"
slouken@1361
    33
slouken@1361
    34
#if SDL_VIDEO_DRIVER_X11_DGAMOUSE
slouken@1361
    35
#include "../Xext/extensions/xf86dga.h"
slouken@0
    36
#endif
slouken@1659
    37
#if SDL_VIDEO_DRIVER_X11_XINERAMA
slouken@1659
    38
#include "../Xext/extensions/Xinerama.h"
slouken@1662
    39
#endif
slouken@1659
    40
#if SDL_VIDEO_DRIVER_X11_XRANDR
slouken@1659
    41
#include <X11/extensions/Xrandr.h>
slouken@1659
    42
#endif
slouken@1361
    43
#if SDL_VIDEO_DRIVER_X11_VIDMODE
slouken@1361
    44
#include "../Xext/extensions/xf86vmode.h"
slouken@0
    45
#endif
slouken@1361
    46
#if SDL_VIDEO_DRIVER_X11_XME
slouken@1361
    47
#include "../Xext/extensions/xme.h"
slouken@242
    48
#endif
slouken@1659
    49
#if SDL_VIDEO_DRIVER_X11_DPMS
slouken@1659
    50
#include <X11/extensions/dpms.h>
icculus@1589
    51
#endif
slouken@227
    52
icculus@1168
    53
#include "SDL_x11dyn.h"
slouken@0
    54
slouken@0
    55
/* Hidden "this" pointer for the video functions */
slouken@0
    56
#define _THIS	SDL_VideoDevice *this
slouken@0
    57
slouken@0
    58
/* Private display data */
slouken@1662
    59
struct SDL_PrivateVideoData
slouken@1662
    60
{
slouken@1662
    61
    int local_X11;              /* Flag: true if local display */
slouken@1662
    62
    Display *X11_Display;       /* Used for events and window management */
slouken@1662
    63
    Display *GFX_Display;       /* Used for graphics and colormap stuff */
slouken@1662
    64
    Visual *SDL_Visual;         /* The visual used by our window */
slouken@1662
    65
    Window WMwindow;            /* Input window, managed by window manager */
slouken@1662
    66
    Window FSwindow;            /* Fullscreen window, completely unmanaged */
slouken@1662
    67
    Window SDL_Window;          /* Shared by both displays (no X security?) */
slouken@1662
    68
    Atom WM_DELETE_WINDOW;      /* "close-window" protocol atom */
slouken@1662
    69
    WMcursor *BlankCursor;      /* The invisible cursor */
slouken@1662
    70
    XIM X11_IM;                 /* Used to communicate with the input method (IM) server */
slouken@1662
    71
    XIC X11_IC;                 /* Used for retaining the state, properties, and semantics of communication with                                                  the input method (IM) server */
slouken@0
    72
slouken@1662
    73
    char *SDL_windowid;         /* Flag: true if we have been passed a window */
slouken@0
    74
slouken@0
    75
    /* Direct Graphics Access extension information */
slouken@0
    76
    int using_dga;
slouken@0
    77
slouken@0
    78
#ifndef NO_SHARED_MEMORY
slouken@0
    79
    /* MIT shared memory extension information */
slouken@0
    80
    int use_mitshm;
slouken@0
    81
    XShmSegmentInfo shminfo;
slouken@0
    82
#endif
slouken@0
    83
slouken@0
    84
    /* The variables used for displaying graphics */
slouken@1662
    85
    XImage *Ximage;             /* The X image for our window */
slouken@1662
    86
    GC gc;                      /* The graphic context for drawing */
slouken@0
    87
slouken@0
    88
    /* The current width and height of the fullscreen mode */
slouken@1545
    89
    int window_w;
slouken@1545
    90
    int window_h;
slouken@0
    91
slouken@0
    92
    /* Support for internal mouse warping */
slouken@1662
    93
    struct
slouken@1662
    94
    {
slouken@0
    95
        int x;
slouken@0
    96
        int y;
slouken@0
    97
    } mouse_last;
slouken@1662
    98
    struct
slouken@1662
    99
    {
slouken@0
   100
        int numerator;
slouken@0
   101
        int denominator;
slouken@0
   102
        int threshold;
slouken@0
   103
    } mouse_accel;
slouken@0
   104
    int mouse_relative;
slouken@0
   105
slouken@0
   106
    /* available visuals of interest to us, sorted deepest first */
slouken@1662
   107
    struct
slouken@1662
   108
    {
slouken@1662
   109
        Visual *visual;
slouken@1662
   110
        int depth;              /* number of significant bits/pixel */
slouken@1662
   111
        int bpp;                /* pixel quantum in bits */
slouken@1662
   112
    } visuals[2 * 5];           /* at most 2 entries for 8, 15, 16, 24, 32 */
slouken@0
   113
    int nvisuals;
slouken@0
   114
slouken@1662
   115
    Visual *vis;                /* current visual in use */
slouken@1662
   116
    int depth;                  /* current visual depth (not bpp) */
slouken@0
   117
slouken@0
   118
    /* Variables used by the X11 video mode code */
slouken@1659
   119
#if SDL_VIDEO_DRIVER_X11_XINERAMA
slouken@1668
   120
      SDL_NAME(XineramaScreenInfo) * xinerama;
slouken@1659
   121
#endif
slouken@1659
   122
#if SDL_VIDEO_DRIVER_X11_XRANDR
slouken@1662
   123
    XRRScreenConfiguration *screen_config;
slouken@1659
   124
    int saved_size_id;
slouken@1659
   125
    Rotation saved_rotation;
slouken@1659
   126
#endif
slouken@1361
   127
#if SDL_VIDEO_DRIVER_X11_VIDMODE
slouken@1668
   128
      SDL_NAME(XF86VidModeModeInfo) saved_mode;
slouken@1662
   129
    struct
slouken@1662
   130
    {
slouken@0
   131
        int x, y;
slouken@0
   132
    } saved_view;
slouken@0
   133
#endif
slouken@1662
   134
#if SDL_VIDEO_DRIVER_X11_XME    /* XiG XME fullscreen */
slouken@242
   135
    XiGMiscResolutionInfo saved_res;
slouken@242
   136
#endif
slouken@242
   137
slouken@1659
   138
    int use_xinerama;
slouken@1659
   139
    int use_xrandr;
slouken@0
   140
    int use_vidmode;
slouken@1659
   141
    int use_xme;
slouken@0
   142
    int currently_fullscreen;
slouken@0
   143
slouken@0
   144
    /* Automatic mode switching support (entering/leaving fullscreen) */
slouken@0
   145
    Uint32 switch_waiting;
slouken@0
   146
    Uint32 switch_time;
slouken@0
   147
slouken@0
   148
    /* Prevent too many XSync() calls */
slouken@0
   149
    int blit_queued;
slouken@0
   150
slouken@0
   151
    /* Colormap handling */
slouken@1662
   152
    Colormap DisplayColormap;   /* The default display colormap */
slouken@1662
   153
    Colormap XColorMap;         /* The current window colormap */
slouken@1662
   154
    int *XPixels;               /* pixels value allocation counts */
slouken@1662
   155
    float gamma_saved[3];       /* Saved gamma values for VidMode gamma */
slouken@1662
   156
    int gamma_changed;          /* flag: has VidMode gamma been modified? */
slouken@0
   157
slouken@1662
   158
    short *iconcolors;          /* List of colors used by the icon */
slouken@1659
   159
slouken@1659
   160
    /* Screensaver settings */
slouken@1659
   161
    int screensaver_timeout;
slouken@1659
   162
    BOOL dpms_enabled;
slouken@0
   163
};
slouken@0
   164
slouken@0
   165
/* Old variable names */
slouken@0
   166
#define local_X11		(this->hidden->local_X11)
slouken@0
   167
#define SDL_Display		(this->hidden->X11_Display)
slouken@0
   168
#define GFX_Display		(this->hidden->GFX_Display)
slouken@0
   169
#define SDL_Screen		DefaultScreen(this->hidden->X11_Display)
slouken@0
   170
#define SDL_Visual		(this->hidden->vis)
slouken@0
   171
#define SDL_Root		RootWindow(SDL_Display, SDL_Screen)
slouken@0
   172
#define WMwindow		(this->hidden->WMwindow)
slouken@0
   173
#define FSwindow		(this->hidden->FSwindow)
slouken@0
   174
#define SDL_Window		(this->hidden->SDL_Window)
slouken@0
   175
#define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
slouken@0
   176
#define SDL_BlankCursor		(this->hidden->BlankCursor)
slouken@1327
   177
#define SDL_IM			(this->hidden->X11_IM)
slouken@1327
   178
#define SDL_IC			(this->hidden->X11_IC)
slouken@0
   179
#define SDL_windowid		(this->hidden->SDL_windowid)
slouken@0
   180
#define using_dga		(this->hidden->using_dga)
slouken@0
   181
#define use_mitshm		(this->hidden->use_mitshm)
slouken@0
   182
#define shminfo			(this->hidden->shminfo)
slouken@0
   183
#define SDL_Ximage		(this->hidden->Ximage)
slouken@0
   184
#define SDL_GC			(this->hidden->gc)
slouken@1545
   185
#define window_w		(this->hidden->window_w)
slouken@1545
   186
#define window_h		(this->hidden->window_h)
slouken@0
   187
#define mouse_last		(this->hidden->mouse_last)
slouken@0
   188
#define mouse_accel		(this->hidden->mouse_accel)
slouken@0
   189
#define mouse_relative		(this->hidden->mouse_relative)
slouken@0
   190
#define SDL_modelist		(this->hidden->modelist)
slouken@1662
   191
#define xinerama		(this->hidden->xinerama)
slouken@0
   192
#define saved_mode		(this->hidden->saved_mode)
slouken@0
   193
#define saved_view		(this->hidden->saved_view)
slouken@242
   194
#define saved_res		(this->hidden->saved_res)
icculus@1589
   195
#define screen_config		(this->hidden->screen_config)
icculus@1589
   196
#define saved_size_id		(this->hidden->saved_size_id)
icculus@1589
   197
#define saved_rotation		(this->hidden->saved_rotation)
slouken@1659
   198
#define use_xinerama		(this->hidden->use_xinerama)
slouken@0
   199
#define use_vidmode		(this->hidden->use_vidmode)
slouken@1659
   200
#define use_xrandr		(this->hidden->use_xrandr)
slouken@1659
   201
#define use_xme			(this->hidden->use_xme)
slouken@0
   202
#define currently_fullscreen	(this->hidden->currently_fullscreen)
slouken@0
   203
#define switch_waiting		(this->hidden->switch_waiting)
slouken@0
   204
#define switch_time		(this->hidden->switch_time)
slouken@0
   205
#define blit_queued		(this->hidden->blit_queued)
slouken@0
   206
#define SDL_DisplayColormap	(this->hidden->DisplayColormap)
slouken@0
   207
#define SDL_PrivateColormap	(this->hidden->PrivateColormap)
slouken@0
   208
#define SDL_XColorMap		(this->hidden->XColorMap)
slouken@0
   209
#define SDL_XPixels		(this->hidden->XPixels)
slouken@0
   210
#define gamma_saved		(this->hidden->gamma_saved)
slouken@0
   211
#define gamma_changed		(this->hidden->gamma_changed)
slouken@0
   212
#define SDL_iconcolors		(this->hidden->iconcolors)
slouken@1659
   213
#define screensaver_timeout	(this->hidden->screensaver_timeout)
slouken@1659
   214
#define dpms_enabled		(this->hidden->dpms_enabled)
slouken@0
   215
/* Some versions of XFree86 have bugs - detect if this is one of them */
slouken@0
   216
#define BUGGY_XFREE86(condition, buggy_version) \
slouken@1336
   217
((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
slouken@0
   218
 (VendorRelease(SDL_Display) condition buggy_version))
slouken@0
   219
slouken@0
   220
#endif /* _SDL_x11video_h */
slouken@1662
   221
/* vi: set ts=4 sw=4 expandtab: */