src/video/x11/SDL_x11video.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 22 Nov 2001 04:55:38 +0000
changeset 242 4bcb29d3769c
parent 227 24878c14b391
child 252 e8157fcb3114
permissions -rw-r--r--
Added support for Xi Graphics XME fullscreen extension
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@0
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 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@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@0
    20
    slouken@devolution.com
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
#ifndef _SDL_x11video_h
slouken@0
    29
#define _SDL_x11video_h
slouken@0
    30
slouken@0
    31
#include <X11/Xlib.h>
slouken@0
    32
#include <X11/Xutil.h>
slouken@0
    33
#include <X11/Xatom.h>
slouken@0
    34
#ifndef NO_SHARED_MEMORY
slouken@0
    35
#include <sys/ipc.h>
slouken@0
    36
#include <sys/shm.h>
slouken@0
    37
#include <X11/extensions/XShm.h>
slouken@0
    38
#endif
slouken@0
    39
#ifdef XFREE86_DGAMOUSE
slouken@0
    40
#include <X11/extensions/xf86dga.h>
slouken@0
    41
#endif
slouken@0
    42
#ifdef XFREE86_VM
slouken@0
    43
#include <X11/extensions/xf86vmode.h>
slouken@0
    44
#ifdef XFREE86_VM_DYNAMIC_HACK
slouken@0
    45
#define XVidMode(func, args)	XF40VidMode##func args
slouken@0
    46
#else
slouken@0
    47
#define XVidMode(func, args)	XF86VidMode##func args
slouken@0
    48
#endif
slouken@0
    49
#endif /* XFREE86_VM */
slouken@242
    50
#ifdef HAVE_XIGXME
slouken@242
    51
#include <X11/extensions/xme.h>
slouken@242
    52
#endif
slouken@227
    53
slouken@0
    54
#include <string.h>
slouken@0
    55
slouken@0
    56
#include "SDL_mouse.h"
slouken@0
    57
#include "SDL_sysvideo.h"
slouken@0
    58
slouken@0
    59
/* Hidden "this" pointer for the video functions */
slouken@0
    60
#define _THIS	SDL_VideoDevice *this
slouken@0
    61
slouken@0
    62
/* Private display data */
slouken@0
    63
struct SDL_PrivateVideoData {
slouken@0
    64
    int local_X11;		/* Flag: true if local display */
slouken@0
    65
    Display *X11_Display;	/* Used for events and window management */
slouken@0
    66
    Display *GFX_Display;	/* Used for graphics and colormap stuff */
slouken@0
    67
    Visual *SDL_Visual;		/* The visual used by our window */
slouken@0
    68
    Window WMwindow;		/* Input window, managed by window manager */
slouken@0
    69
    Window FSwindow;		/* Fullscreen window, completely unmanaged */
slouken@0
    70
    Window SDL_Window;		/* Shared by both displays (no X security?) */
slouken@0
    71
    Atom WM_DELETE_WINDOW;	/* "close-window" protocol atom */
slouken@0
    72
    WMcursor *BlankCursor;	/* The invisible cursor */
slouken@0
    73
slouken@0
    74
    char *SDL_windowid;		/* Flag: true if we have been passed a window */
slouken@0
    75
slouken@0
    76
    /* Direct Graphics Access extension information */
slouken@0
    77
    int using_dga;
slouken@0
    78
slouken@0
    79
#ifndef NO_SHARED_MEMORY
slouken@0
    80
    /* MIT shared memory extension information */
slouken@0
    81
    int use_mitshm;
slouken@0
    82
    XShmSegmentInfo shminfo;
slouken@0
    83
#endif
slouken@0
    84
slouken@0
    85
    /* The variables used for displaying graphics */
slouken@0
    86
    XImage *Ximage;		/* The X image for our window */
slouken@0
    87
    GC	gc;			/* The graphic context for drawing */
slouken@0
    88
    int swap_pixels;		/* Flag: true if display is swapped endian */
slouken@0
    89
slouken@0
    90
    /* The current width and height of the fullscreen mode */
slouken@0
    91
    int current_w;
slouken@0
    92
    int current_h;
slouken@0
    93
slouken@0
    94
    /* Support for internal mouse warping */
slouken@0
    95
    struct {
slouken@0
    96
        int x;
slouken@0
    97
        int y;
slouken@0
    98
    } mouse_last;
slouken@0
    99
    struct {
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
    /* The current list of available video modes */
slouken@0
   107
    SDL_Rect **modelist;
slouken@0
   108
slouken@0
   109
    /* available visuals of interest to us, sorted deepest first */
slouken@0
   110
    struct {
slouken@0
   111
	Visual *visual;
slouken@0
   112
	int depth;		/* number of significant bits/pixel */
slouken@0
   113
	int bpp;		/* pixel quantum in bits */
slouken@0
   114
    } visuals[2*5];		/* at most 2 entries for 8, 15, 16, 24, 32 */
slouken@0
   115
    int nvisuals;
slouken@0
   116
slouken@0
   117
    Visual *vis;		/* current visual in use */
slouken@0
   118
    int depth;			/* current visual depth (not bpp) */
slouken@0
   119
slouken@0
   120
    /* Variables used by the X11 video mode code */
slouken@0
   121
#ifdef XFREE86_VM
slouken@0
   122
    XF86VidModeModeInfo saved_mode;
slouken@0
   123
    struct {
slouken@0
   124
        int x, y;
slouken@0
   125
    } saved_view;
slouken@0
   126
#endif
slouken@242
   127
#ifdef HAVE_XIGXME /* XiG XME fullscreen */
slouken@242
   128
    int use_xme;
slouken@242
   129
    XiGMiscResolutionInfo saved_res;
slouken@242
   130
#endif
slouken@242
   131
slouken@227
   132
    int xinerama_x;
slouken@227
   133
    int xinerama_y;
slouken@0
   134
    int use_vidmode;
slouken@0
   135
    int currently_fullscreen;
slouken@0
   136
slouken@0
   137
    /* Automatic mode switching support (entering/leaving fullscreen) */
slouken@0
   138
    Uint32 switch_waiting;
slouken@0
   139
    Uint32 switch_time;
slouken@0
   140
slouken@0
   141
    /* Prevent too many XSync() calls */
slouken@0
   142
    int blit_queued;
slouken@0
   143
slouken@0
   144
    /* Colormap handling */
slouken@0
   145
    Colormap DisplayColormap;	/* The default display colormap */
slouken@0
   146
    Colormap XColorMap;		/* The current window colormap */
slouken@0
   147
    int *XPixels;		/* pixels value allocation counts */
slouken@0
   148
    float gamma_saved[3];	/* Saved gamma values for VidMode gamma */
slouken@0
   149
    int gamma_changed;		/* flag: has VidMode gamma been modified? */
slouken@0
   150
slouken@0
   151
    short *iconcolors;		/* List of colors used by the icon */
slouken@0
   152
};
slouken@0
   153
slouken@0
   154
/* Old variable names */
slouken@0
   155
#define local_X11		(this->hidden->local_X11)
slouken@0
   156
#define SDL_Display		(this->hidden->X11_Display)
slouken@0
   157
#define GFX_Display		(this->hidden->GFX_Display)
slouken@0
   158
#define SDL_Screen		DefaultScreen(this->hidden->X11_Display)
slouken@0
   159
slouken@0
   160
#define SDL_Visual		(this->hidden->vis)
slouken@0
   161
slouken@0
   162
#define SDL_Root		RootWindow(SDL_Display, SDL_Screen)
slouken@0
   163
#define WMwindow		(this->hidden->WMwindow)
slouken@0
   164
#define FSwindow		(this->hidden->FSwindow)
slouken@0
   165
#define SDL_Window		(this->hidden->SDL_Window)
slouken@0
   166
#define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
slouken@0
   167
#define SDL_BlankCursor		(this->hidden->BlankCursor)
slouken@0
   168
#define SDL_windowid		(this->hidden->SDL_windowid)
slouken@0
   169
#define using_dga		(this->hidden->using_dga)
slouken@0
   170
#define use_mitshm		(this->hidden->use_mitshm)
slouken@0
   171
#define shminfo			(this->hidden->shminfo)
slouken@0
   172
#define SDL_Ximage		(this->hidden->Ximage)
slouken@0
   173
#define SDL_GC			(this->hidden->gc)
slouken@0
   174
#define swap_pixels		(this->hidden->swap_pixels)
slouken@0
   175
#define current_w		(this->hidden->current_w)
slouken@0
   176
#define current_h		(this->hidden->current_h)
slouken@0
   177
#define mouse_last		(this->hidden->mouse_last)
slouken@0
   178
#define mouse_accel		(this->hidden->mouse_accel)
slouken@0
   179
#define mouse_relative		(this->hidden->mouse_relative)
slouken@0
   180
#define SDL_modelist		(this->hidden->modelist)
slouken@0
   181
#define saved_mode		(this->hidden->saved_mode)
slouken@0
   182
#define saved_view		(this->hidden->saved_view)
slouken@242
   183
#define use_xme			(this->hidden->use_xme)
slouken@242
   184
#define saved_res		(this->hidden->saved_res)
slouken@227
   185
#define xinerama_x		(this->hidden->xinerama_x)
slouken@227
   186
#define xinerama_y		(this->hidden->xinerama_y)
slouken@0
   187
#define use_vidmode		(this->hidden->use_vidmode)
slouken@0
   188
#define currently_fullscreen	(this->hidden->currently_fullscreen)
slouken@0
   189
#define switch_waiting		(this->hidden->switch_waiting)
slouken@0
   190
#define switch_time		(this->hidden->switch_time)
slouken@0
   191
#define blit_queued		(this->hidden->blit_queued)
slouken@0
   192
#define SDL_DisplayColormap	(this->hidden->DisplayColormap)
slouken@0
   193
#define SDL_PrivateColormap	(this->hidden->PrivateColormap)
slouken@0
   194
#define SDL_XColorMap		(this->hidden->XColorMap)
slouken@0
   195
#define SDL_XPixels		(this->hidden->XPixels)
slouken@0
   196
#define gamma_saved		(this->hidden->gamma_saved)
slouken@0
   197
#define gamma_changed		(this->hidden->gamma_changed)
slouken@0
   198
#define SDL_iconcolors		(this->hidden->iconcolors)
slouken@0
   199
slouken@0
   200
/* Some versions of XFree86 have bugs - detect if this is one of them */
slouken@0
   201
#define BUGGY_XFREE86(condition, buggy_version) \
slouken@0
   202
((strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
slouken@0
   203
 (VendorRelease(SDL_Display) condition buggy_version))
slouken@0
   204
slouken@0
   205
#endif /* _SDL_x11video_h */