Commit 532023bd authored by Sam Lantinga's avatar Sam Lantinga

Starting fresh with the X11 driver

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401994
parent fe52e82b
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#define DEBUG_DYNAMIC_X11 0
#include "SDL_x11dyn.h"
#if DEBUG_DYNAMIC_X11
#include <stdio.h>
#endif
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
#include "SDL_name.h"
#include "SDL_loadso.h"
typedef struct
{
void *lib;
const char *libname;
} x11dynlib;
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC
#define SDL_VIDEO_DRIVER_X11_DYNAMIC NULL
#endif
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT NULL
#endif
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER NULL
#endif
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR NULL
#endif
static x11dynlib x11libs[] = {
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC},
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT},
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER},
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR},
};
static void
X11_GetSym(const char *fnname, int *rc, void **fn)
{
int i;
for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
if (x11libs[i].lib != NULL) {
*fn = SDL_LoadFunction(x11libs[i].lib, fnname);
if (*fn != NULL)
break;
}
}
#if DEBUG_DYNAMIC_X11
if (*fn != NULL)
printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname,
*fn);
else
printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
#endif
if (*fn == NULL)
*rc = 0; /* kill this module. */
}
/* Define all the function pointers and wrappers... */
#define SDL_X11_MODULE(modname)
#define SDL_X11_SYM(rc,fn,params,args,ret) \
static rc (*p##fn) params = NULL; \
rc fn params { ret p##fn args ; }
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM
#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
/* Annoying varargs entry point... */
#ifdef X_HAVE_UTF8_STRING
XIC(*pXCreateIC) (XIM,...) = NULL;
#endif
/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
#define SDL_X11_MODULE(modname) int SDL_X11_HAVE_##modname = 1;
#define SDL_X11_SYM(rc,fn,params,args,ret)
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM
static int x11_load_refcount = 0;
void
SDL_X11_UnloadSymbols(void)
{
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
/* Don't actually unload if more than one module is using the libs... */
if (x11_load_refcount > 0) {
if (--x11_load_refcount == 0) {
int i;
/* set all the function pointers to NULL. */
#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1;
#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM
#ifdef X_HAVE_UTF8_STRING
pXCreateIC = NULL;
#endif
for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
if (x11libs[i].lib != NULL) {
SDL_UnloadObject(x11libs[i].lib);
x11libs[i].lib = NULL;
}
}
}
}
#endif
}
/* returns non-zero if all needed symbols were loaded. */
int
SDL_X11_LoadSymbols(void)
{
int rc = 1; /* always succeed if not using Dynamic X11 stuff. */
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
/* deal with multiple modules (dga, x11, etc) needing these symbols... */
if (x11_load_refcount++ == 0) {
int i;
int *thismod = NULL;
for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
if (x11libs[i].libname != NULL) {
x11libs[i].lib = SDL_LoadObject(x11libs[i].libname);
}
}
#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM
#ifdef X_HAVE_UTF8_STRING
X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC);
#endif
if (!SDL_X11_HAVE_BASEXLIB) { /* some required symbol didn't load. */
SDL_X11_UnloadSymbols(); /* in case something got loaded... */
rc = 0;
}
}
#else
#ifdef X_HAVE_UTF8_STRING
pXCreateIC = XCreateIC;
#endif
#endif
return rc;
}
/* end of SDL_x11dyn.c ... */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_x11dyn_h
#define _SDL_x11dyn_h
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xlibint.h>
#include <X11/Xproto.h>
#include "../Xext/extensions/Xext.h"
#include "../Xext/extensions/extutil.h"
#ifndef NO_SHARED_MEMORY
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif
#if SDL_VIDEO_DRIVER_X11_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
/*
* When using the "dynamic X11" functionality, we duplicate all the Xlib
* symbols that would be referenced by SDL inside of SDL itself.
* These duplicated symbols just serve as passthroughs to the functions
* in Xlib, that was dynamically loaded.
*
* This allows us to use Xlib as-is when linking against it directly, but
* also handles all the strange cases where there was code in the Xlib
* headers that may or may not exist or vary on a given platform.
*/
#ifdef __cplusplus
extern "C"
{
#endif
/* evil function signatures... */
typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *,
xEvent *);
typedef int (*SDL_X11_XSynchronizeRetType) (Display *);
typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *,
xEvent *);
int SDL_X11_LoadSymbols(void);
void SDL_X11_UnloadSymbols(void);
/* That's really annoying...make this a function pointer no matter what. */
#ifdef X_HAVE_UTF8_STRING
extern XIC(*pXCreateIC) (XIM, ...);
#endif
/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
#define SDL_X11_MODULE(modname) extern int SDL_X11_HAVE_##modname;
#define SDL_X11_SYM(rc,fn,params,args,ret)
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM
#ifdef __cplusplus
}
#endif
#endif /* !defined _SDL_x11dyn_h */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
/* Functions to be exported */
extern void X11_InitOSKeymap(_THIS);
extern void X11_PumpEvents(_THIS);
extern void X11_SetKeyboardState(Display * display, const char *key_vec);
extern void X11_SaveScreenSaver(Display * display, int *saved_timeout,
BOOL * dpms);
extern void X11_DisableScreenSaver(Display * display);
extern void X11_RestoreScreenSaver(Display * display, int saved_timeout,
BOOL dpms);
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL.h"
#include "SDL_events.h"
#include "../../events/SDL_events_c.h"
#include "SDL_x11video.h"
/* From the X server sources... */
#define MAX_GAMMA 10.0
#define MIN_GAMMA (1.0/MAX_GAMMA)
static int
X11_SetGammaNoLock(_THIS, float red, float green, float blue)
{
#if SDL_VIDEO_DRIVER_X11_VIDMODE
if (use_vidmode >= 200) {
SDL_NAME(XF86VidModeGamma) gamma;
Bool succeeded;
/* Clamp the gamma values */
if (red < MIN_GAMMA) {
gamma.red = MIN_GAMMA;
} else if (red > MAX_GAMMA) {
gamma.red = MAX_GAMMA;
} else {
gamma.red = red;
}
if (green < MIN_GAMMA) {
gamma.green = MIN_GAMMA;
} else if (green > MAX_GAMMA) {
gamma.green = MAX_GAMMA;
} else {
gamma.green = green;
}
if (blue < MIN_GAMMA) {
gamma.blue = MIN_GAMMA;
} else if (blue > MAX_GAMMA) {
gamma.blue = MAX_GAMMA;
} else {
gamma.blue = blue;
}
if (SDL_GetAppState() & SDL_APPACTIVE) {
succeeded =
SDL_NAME(XF86VidModeSetGamma) (SDL_Display, SDL_Screen,
&gamma);
XSync(SDL_Display, False);
} else {
gamma_saved[0] = gamma.red;
gamma_saved[1] = gamma.green;
gamma_saved[2] = gamma.blue;
succeeded = True;
}
if (succeeded) {
++gamma_changed;
}
return succeeded ? 0 : -1;
}
#endif
SDL_SetError("Gamma correction not supported");
return -1;
}
int
X11_SetVidModeGamma(_THIS, float red, float green, float blue)
{
int result;
SDL_Lock_EventThread();
result = X11_SetGammaNoLock(this, red, green, blue);
SDL_Unlock_EventThread();
return (result);
}
static int
X11_GetGammaNoLock(_THIS, float *red, float *green, float *blue)
{
#if SDL_VIDEO_DRIVER_X11_VIDMODE
if (use_vidmode >= 200) {
SDL_NAME(XF86VidModeGamma) gamma;
if (SDL_NAME(XF86VidModeGetGamma)
(SDL_Display, SDL_Screen, &gamma)) {
*red = gamma.red;
*green = gamma.green;
*blue = gamma.blue;
return 0;
}
return -1;
}
#endif
return -1;
}
int
X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue)
{
int result;
SDL_Lock_EventThread();
result = X11_GetGammaNoLock(this, red, green, blue);
SDL_Unlock_EventThread();
return (result);
}
void
X11_SaveVidModeGamma(_THIS)
{
/* Try to save the current gamma, otherwise disable gamma control */
if (X11_GetGammaNoLock(this,
&gamma_saved[0], &gamma_saved[1],
&gamma_saved[2]) < 0) {
this->SetGamma = 0;
this->GetGamma = 0;
}
gamma_changed = 0;
}
void
X11_SwapVidModeGamma(_THIS)
{
float new_gamma[3];
if (gamma_changed) {
new_gamma[0] = gamma_saved[0];
new_gamma[1] = gamma_saved[1];
new_gamma[2] = gamma_saved[2];
X11_GetGammaNoLock(this, &gamma_saved[0], &gamma_saved[1],
&gamma_saved[2]);
X11_SetGammaNoLock(this, new_gamma[0], new_gamma[1], new_gamma[2]);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_x11gamma_h
#define _SDL_x11gamma_h
extern int X11_SetVidModeGamma(_THIS, float red, float green, float blue);
extern int X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue);
extern void X11_SaveVidModeGamma(_THIS);
extern void X11_SwapVidModeGamma(_THIS);
#endif
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#if SDL_VIDEO_OPENGL_GLX
#include <GL/glx.h>
#include "SDL_loadso.h"
#endif
#include "../SDL_sysvideo.h"
struct SDL_PrivateGLData
{
int gl_active; /* to stop switching drivers while we have a valid context */
#if SDL_VIDEO_OPENGL_GLX
GLXContext glx_context; /* Current GL context */
XVisualInfo *glx_visualinfo; /* XVisualInfo* returned by glXChooseVisual */
void *(*glXGetProcAddress) (const GLubyte * procName);
XVisualInfo *(*glXChooseVisual)
(Display * dpy, int screen, int *attribList);
GLXContext(*glXCreateContext)
(Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool direct);
void (*glXDestroyContext) (Display * dpy, GLXContext ctx);
Bool(*glXMakeCurrent)
(Display * dpy, GLXDrawable drawable, GLXContext ctx);
void (*glXSwapBuffers) (Display * dpy, GLXDrawable drawable);
int (*glXGetConfig)
(Display * dpy, XVisualInfo * visual_info, int attrib, int *value);
const char *(*glXQueryExtensionsString) (Display * dpy, int screen);
int (*glXSwapIntervalSGI) (int interval);
GLint(*glXSwapIntervalMESA) (unsigned interval);
GLint(*glXGetSwapIntervalMESA) (void);
#endif /* SDL_VIDEO_OPENGL_GLX */
};
/* Old variable names */
#define gl_active (this->gl_data->gl_active)
#define glx_context (this->gl_data->glx_context)
#define glx_visualinfo (this->gl_data->glx_visualinfo)
/* OpenGL functions */
extern XVisualInfo *X11_GL_GetVisual(_THIS);
extern int X11_GL_CreateWindow(_THIS, int w, int h);
extern int X11_GL_CreateContext(_THIS);
extern void X11_GL_Shutdown(_THIS);
#if SDL_VIDEO_OPENGL_GLX
extern int X11_GL_MakeCurrent(_THIS);
extern int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
extern void X11_GL_SwapBuffers(_THIS);
extern int X11_GL_LoadLibrary(_THIS, const char *path);
extern void *X11_GL_GetProcAddress(_THIS, const char *proc);
#endif
extern void X11_GL_UnloadLibrary(_THIS);
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include <stdio.h>
#include <unistd.h>
#include "SDL_endian.h"
#include "../../events/SDL_events_c.h"
#include "SDL_x11image_c.h"
#ifndef NO_SHARED_MEMORY
/* Shared memory error handler routine */
static int shm_error;
static int (*X_handler) (Display *, XErrorEvent *) = NULL;
static int
shm_errhandler(Display * d, XErrorEvent * e)
{
if (e->error_code == BadAccess) {
shm_error = True;
return (0);
} else
return (X_handler(d, e));
}
static void
try_mitshm(_THIS, SDL_Surface * screen)
{
/* Dynamic X11 may not have SHM entry points on this box. */
if ((use_mitshm) && (!SDL_X11_HAVE_SHM))
use_mitshm = 0;
if (!use_mitshm)
return;
shminfo.shmid = shmget(IPC_PRIVATE, screen->h * screen->pitch,
IPC_CREAT | 0777);
if (shminfo.shmid >= 0) {
shminfo.shmaddr = (char *) shmat(shminfo.shmid, 0, 0);
shminfo.readOnly = False;
if (shminfo.shmaddr != (char *) -1) {
shm_error = False;
X_handler = XSetErrorHandler(shm_errhandler);
XShmAttach(SDL_Display, &shminfo);
XSync(SDL_Display, True);
XSetErrorHandler(X_handler);
if (shm_error)
shmdt(shminfo.shmaddr);
} else {
shm_error = True;
}
shmctl(shminfo.shmid, IPC_RMID, NULL);
} else {
shm_error = True;
}
if (shm_error)
use_mitshm = 0;
if (use_mitshm)
screen->pixels = shminfo.shmaddr;
}
#endif /* ! NO_SHARED_MEMORY */
/* Various screen update functions available */
static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect * rects);
static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect * rects);
int
X11_SetupImage(_THIS, SDL_Surface * screen)
{
#ifndef NO_SHARED_MEMORY
try_mitshm(this, screen);
if (use_mitshm) {
SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual,
this->hidden->depth, ZPixmap,
shminfo.shmaddr, &shminfo,
screen->w, screen->h);
if (!SDL_Ximage) {
XShmDetach(SDL_Display, &shminfo);
XSync(SDL_Display, False);
shmdt(shminfo.shmaddr);
screen->pixels = NULL;
goto error;
}
this->UpdateRects = X11_MITSHMUpdate;
}
if (!use_mitshm)
#endif /* not NO_SHARED_MEMORY */
{
int bpp;
screen->pixels = SDL_malloc(screen->h * screen->pitch);
if (screen->pixels == NULL) {
SDL_OutOfMemory();
return -1;
}
bpp = screen->format->BytesPerPixel;
SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
this->hidden->depth, ZPixmap, 0,
(char *) screen->pixels,
screen->w, screen->h, 32, 0);
if (SDL_Ximage == NULL)
goto error;
/* XPutImage will convert byte sex automatically */
SDL_Ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN)
? MSBFirst : LSBFirst;
this->UpdateRects = X11_NormalUpdate;
}
screen->pitch = SDL_Ximage->bytes_per_line;
return (0);
error:
SDL_SetError("Couldn't create XImage");
return 1;
}
void
X11_DestroyImage(_THIS, SDL_Surface * screen)
{
if (SDL_Ximage) {
XDestroyImage(SDL_Ximage);
#ifndef NO_SHARED_MEMORY
if (use_mitshm) {
XShmDetach(SDL_Display, &shminfo);
XSync(SDL_Display, False);
shmdt(shminfo.shmaddr);
}
#endif /* ! NO_SHARED_MEMORY */
SDL_Ximage = NULL;
}
if (screen) {
screen->pixels = NULL;
}
}
/* Determine the number of CPUs in the system */
static int
num_CPU(void)
{
static int num_cpus = 0;
if (!num_cpus) {
#if defined(__LINUX__)
char line[BUFSIZ];
FILE *pstat = fopen("/proc/stat", "r");
if (pstat) {
while (fgets(line, sizeof(line), pstat)) {
if (SDL_memcmp(line, "cpu", 3) == 0 && line[3] != ' ') {
++num_cpus;
}
}
fclose(pstat);
}
#elif defined(__IRIX__)
num_cpus = sysconf(_SC_NPROC_ONLN);
#elif defined(_SC_NPROCESSORS_ONLN)
/* number of processors online (SVR4.0MP compliant machines) */
num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(_SC_NPROCESSORS_CONF)
/* number of processors configured (SVR4.0MP compliant machines) */
num_cpus = sysconf(_SC_NPROCESSORS_CONF);
#endif
if (num_cpus <= 0) {
num_cpus = 1;
}
}
return num_cpus;
}
int
X11_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags)
{
int retval;
X11_DestroyImage(this, screen);
if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */
retval = 0;
} else {
retval = X11_SetupImage(this, screen);
/* We support asynchronous blitting on the display */
if (flags & SDL_ASYNCBLIT) {
/* This is actually slower on single-CPU systems,
probably because of CPU contention between the
X server and the application.
Note: Is this still true with XFree86 4.0?
*/
if (num_CPU() > 1) {
screen->flags |= SDL_ASYNCBLIT;
}
}
}
return (retval);
}
/* We don't actually allow hardware surfaces other than the main one */
int
X11_AllocHWSurface(_THIS, SDL_Surface * surface)
{
return (-1);
}
void
X11_FreeHWSurface(_THIS, SDL_Surface * surface)
{
return;
}
int
X11_LockHWSurface(_THIS, SDL_Surface * surface)
{
if ((surface == SDL_VideoSurface) && blit_queued) {
XSync(GFX_Display, False);
blit_queued = 0;
}
return (0);
}
void
X11_UnlockHWSurface(_THIS, SDL_Surface * surface)
{
return;
}
int
X11_FlipHWSurface(_THIS, SDL_Surface * surface)
{
return (0);
}
static void
X11_NormalUpdate(_THIS, int numrects, SDL_Rect * rects)
{
int i;
for (i = 0; i < numrects; ++i) {
if (rects[i].w == 0 || rects[i].h == 0) { /* Clipped? */
continue;
}
XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
rects[i].x, rects[i].y,
rects[i].x, rects[i].y, rects[i].w, rects[i].h);
}
if (SDL_VideoSurface->flags & SDL_ASYNCBLIT) {
XFlush(GFX_Display);
blit_queued = 1;
} else {
XSync(GFX_Display, False);
}
}
static void
X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect * rects)
{
#ifndef NO_SHARED_MEMORY
int i;
for (i = 0; i < numrects; ++i) {
if (rects[i].w == 0 || rects[i].h == 0) { /* Clipped? */
continue;
}
XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
rects[i].x, rects[i].y,
rects[i].x, rects[i].y, rects[i].w, rects[i].h, False);
}
if (SDL_VideoSurface->flags & SDL_ASYNCBLIT) {
XFlush(GFX_Display);
blit_queued = 1;
} else {
XSync(GFX_Display, False);
}
#endif /* ! NO_SHARED_MEMORY */
}
/* There's a problem with the automatic refreshing of the display.
Even though the XVideo code uses the GFX_Display to update the
video memory, it appears that updating the window asynchronously
from a different thread will cause "blackouts" of the window.
This is a sort of a hacked workaround for the problem.
*/
static int enable_autorefresh = 1;
void
X11_DisableAutoRefresh(_THIS)
{
--enable_autorefresh;
}
void
X11_EnableAutoRefresh(_THIS)
{
++enable_autorefresh;
}
void
X11_RefreshDisplay(_THIS)
{
/* Don't refresh a display that doesn't have an image (like GL)
Instead, post an expose event so the application can refresh.
*/
if (!SDL_Ximage || (enable_autorefresh <= 0)) {
SDL_PrivateExpose();
return;
}
#ifndef NO_SHARED_MEMORY
if (this->UpdateRects == X11_MITSHMUpdate) {
XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
0, 0, SDL_CurrentWindow.offset_x,
SDL_CurrentWindow.offset_y,
SDL_CurrentDisplay.current_mode.w,
SDL_CurrentDisplay.current_mode.h, False);
} else
#endif /* ! NO_SHARED_MEMORY */
{
XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
0, 0, SDL_CurrentWindow.offset_x,
SDL_CurrentWindow.offset_y,
SDL_CurrentDisplay.current_mode.w,
SDL_CurrentDisplay.current_mode.h);
}
XSync(SDL_Display, False);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
extern int X11_SetupImage(_THIS, SDL_Surface * screen);
extern void X11_DestroyImage(_THIS, SDL_Surface * screen);
extern int X11_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags);
extern int X11_AllocHWSurface(_THIS, SDL_Surface * surface);
extern void X11_FreeHWSurface(_THIS, SDL_Surface * surface);
extern int X11_LockHWSurface(_THIS, SDL_Surface * surface);
extern void X11_UnlockHWSurface(_THIS, SDL_Surface * surface);
extern int X11_FlipHWSurface(_THIS, SDL_Surface * surface);
extern void X11_DisableAutoRefresh(_THIS);
extern void X11_EnableAutoRefresh(_THIS);
extern void X11_RefreshDisplay(_THIS);
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Utilities for getting and setting the X display mode */
#include "SDL_x11video.h"
/* Define this if you want to grab the keyboard in fullscreen mode.
If you do not define this, SDL will return from SDL_SetVideoMode()
immediately, but will not actually go fullscreen until the window
manager is idle.
*/
#define GRAB_FULLSCREEN
extern int X11_GetVisuals(_THIS);
extern int X11_GetVideoModes(_THIS);
extern int X11_ResizeFullScreen(_THIS);
extern void X11_WaitMapped(_THIS, Window win);
extern void X11_WaitUnmapped(_THIS, Window win);
extern void X11_QueueEnterFullScreen(_THIS);
extern int X11_EnterFullScreen(_THIS);
extern int X11_LeaveFullScreen(_THIS);
extern Uint32 X11_VisualToFormat(const Visual * visual, int depth, int bpp);
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "SDL_mouse.h"
#include "../../events/SDL_events_c.h"
#include "../SDL_cursor_c.h"
#include "SDL_x11dga_c.h"
#include "SDL_x11mouse_c.h"
/* The implementation dependent data for the window manager cursor */
struct WMcursor
{
Cursor x_cursor;
};
void
X11_FreeWMCursor(_THIS, WMcursor * cursor)
{
if (SDL_Display != NULL) {
SDL_Lock_EventThread();
XFreeCursor(SDL_Display, cursor->x_cursor);
XSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
SDL_free(cursor);
}
WMcursor *
X11_CreateWMCursor(_THIS,
Uint8 * data, Uint8 * mask, int w, int h, int hot_x,
int hot_y)
{
WMcursor *cursor;
XGCValues GCvalues;
GC GCcursor;
XImage *data_image, *mask_image;
Pixmap data_pixmap, mask_pixmap;
int clen, i;
char *x_data, *x_mask;
static XColor black = { 0, 0, 0, 0 };
static XColor white = { 0xffff, 0xffff, 0xffff, 0xffff };
/* Allocate the cursor memory */
cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor));
if (cursor == NULL) {
SDL_OutOfMemory();
return (NULL);
}
/* Mix the mask and the data */
clen = (w / 8) * h;
x_data = (char *) SDL_malloc(clen);
if (x_data == NULL) {
SDL_free(cursor);
SDL_OutOfMemory();
return (NULL);
}
x_mask = (char *) SDL_malloc(clen);
if (x_mask == NULL) {
SDL_free(cursor);
SDL_free(x_data);
SDL_OutOfMemory();
return (NULL);
}
for (i = 0; i < clen; ++i) {
/* The mask is OR'd with the data to turn inverted color
pixels black since inverted color cursors aren't supported
under X11.
*/
x_mask[i] = data[i] | mask[i];
x_data[i] = data[i];
}
/* Prevent the event thread from running while we use the X server */
SDL_Lock_EventThread();
/* Create the data image */
data_image = XCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen),
1, XYBitmap, 0, x_data, w, h, 8, w / 8);
data_image->byte_order = MSBFirst;
data_image->bitmap_bit_order = MSBFirst;
data_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
/* Create the data mask */
mask_image = XCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen),
1, XYBitmap, 0, x_mask, w, h, 8, w / 8);
mask_image->byte_order = MSBFirst;
mask_image->bitmap_bit_order = MSBFirst;
mask_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
/* Create the graphics context */
GCvalues.function = GXcopy;
GCvalues.foreground = ~0;
GCvalues.background = 0;
GCvalues.plane_mask = AllPlanes;
GCcursor = XCreateGC(SDL_Display, data_pixmap,
(GCFunction | GCForeground | GCBackground |
GCPlaneMask), &GCvalues);
/* Blit the images to the pixmaps */
XPutImage(SDL_Display, data_pixmap, GCcursor, data_image,
0, 0, 0, 0, w, h);
XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
0, 0, 0, 0, w, h);
XFreeGC(SDL_Display, GCcursor);
/* These free the x_data and x_mask memory pointers */
XDestroyImage(data_image);
XDestroyImage(mask_image);
/* Create the cursor */
cursor->x_cursor = XCreatePixmapCursor(SDL_Display, data_pixmap,
mask_pixmap, &black, &white,
hot_x, hot_y);
XFreePixmap(SDL_Display, data_pixmap);
XFreePixmap(SDL_Display, mask_pixmap);
/* Release the event thread */
XSync(SDL_Display, False);
SDL_Unlock_EventThread();
return (cursor);
}
int
X11_ShowWMCursor(_THIS, WMcursor * cursor)
{
/* Don't do anything if the display is gone */
if (SDL_Display == NULL) {
return (0);
}
/* Set the X11 cursor cursor, or blank if cursor is NULL */
if (SDL_Window) {
SDL_Lock_EventThread();
if (cursor == NULL) {
if (SDL_BlankCursor != NULL) {
XDefineCursor(SDL_Display, SDL_Window,
SDL_BlankCursor->x_cursor);
}
} else {
XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
}
XSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
return (1);
}
void
X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
if (using_dga & DGA_MOUSE) {
SDL_PrivateMouseMotion(0, 0, x, y);
} else if (mouse_relative) {
/* RJR: March 28, 2000
leave physical cursor at center of screen if
mouse hidden and grabbed */
SDL_PrivateMouseMotion(0, 0, x, y);
} else {
SDL_Lock_EventThread();
XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
XSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
}
/* Sets the mouse acceleration from a string of the form:
2/1/0
The first number is the numerator, followed by the acceleration
denumenator and threshold.
*/
static void
SetMouseAccel(_THIS, const char *accel_param)
{
int i;
size_t len;
int accel_value[3];
char *mouse_param, *mouse_param_buf, *pin;
len = SDL_strlen(accel_param) + 1;
mouse_param_buf = SDL_stack_alloc(char, len);
if (!mouse_param_buf) {
return;
}
SDL_strlcpy(mouse_param_buf, accel_param, len);
mouse_param = mouse_param_buf;
for (i = 0; (i < 3) && mouse_param; ++i) {
pin = SDL_strchr(mouse_param, '/');
if (pin) {
*pin = '\0';
}
accel_value[i] = atoi(mouse_param);
if (pin) {
mouse_param = pin + 1;
} else {
mouse_param = NULL;
}
}
if (mouse_param_buf) {
XChangePointerControl(SDL_Display, True, True,
accel_value[0], accel_value[1], accel_value[2]);
SDL_free(mouse_param_buf);
}
}
/* Check to see if we need to enter or leave mouse relative mode */
void
X11_CheckMouseModeNoLock(_THIS)
{
const Uint8 full_focus =
(SDL_APPACTIVE | SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
char *env_override;
int enable_relative = 1;
/* Allow the user to override the relative mouse mode.
They almost never want to do this, as it seriously affects
applications that rely on continuous relative mouse motion.
*/
env_override = SDL_getenv("SDL_MOUSE_RELATIVE");
if (env_override) {
enable_relative = atoi(env_override);
}
/* If the mouse is hidden and input is grabbed, we use relative mode */
if (enable_relative &&
!(SDL_cursorstate & CURSOR_VISIBLE) &&
(SDL_CurrentWindow.input_grab != SDL_GRAB_OFF) &&
(SDL_GetAppState() & full_focus) == full_focus) {
if (!mouse_relative) {
X11_EnableDGAMouse(this);
if (!(using_dga & DGA_MOUSE)) {
char *xmouse_accel;
SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
/* Use as raw mouse mickeys as possible */
XGetPointerControl(SDL_Display,
&mouse_accel.numerator,
&mouse_accel.denominator,
&mouse_accel.threshold);
xmouse_accel = SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL");
if (xmouse_accel) {
SetMouseAccel(this, xmouse_accel);
}
}
mouse_relative = 1;
}
} else {
if (mouse_relative) {
if (using_dga & DGA_MOUSE) {
X11_DisableDGAMouse(this);
} else {
XChangePointerControl(SDL_Display, True, True,
mouse_accel.numerator,
mouse_accel.denominator,
mouse_accel.threshold);
}
mouse_relative = 0;
}
}
}
void
X11_CheckMouseMode(_THIS)
{
SDL_Lock_EventThread();
X11_CheckMouseModeNoLock(this);
SDL_Unlock_EventThread();
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
/* Functions to be exported */
extern void X11_FreeWMCursor(_THIS, WMcursor * cursor);
extern WMcursor *X11_CreateWMCursor(_THIS,
Uint8 * data, Uint8 * mask, int w, int h,
int hot_x, int hot_y);
extern int X11_ShowWMCursor(_THIS, WMcursor * cursor);
extern void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
extern void X11_CheckMouseModeNoLock(_THIS);
extern void X11_CheckMouseMode(_THIS);
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_x11video_h
#define _SDL_x11video_h
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#if SDL_VIDEO_DRIVER_X11_DGAMOUSE
#include "../Xext/extensions/xf86dga.h"
#endif
#if SDL_VIDEO_DRIVER_X11_XINERAMA
#include "../Xext/extensions/Xinerama.h"
#endif
#if SDL_VIDEO_DRIVER_X11_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
#if SDL_VIDEO_DRIVER_X11_VIDMODE
#include "../Xext/extensions/xf86vmode.h"
#endif
#if SDL_VIDEO_DRIVER_X11_XME
#include "../Xext/extensions/xme.h"
#endif
#if SDL_VIDEO_DRIVER_X11_DPMS
#include <X11/extensions/dpms.h>
#endif
#include "SDL_x11dyn.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
/* Private display data */
struct SDL_PrivateVideoData
{
int local_X11; /* Flag: true if local display */
Display *X11_Display; /* Used for events and window management */
Display *GFX_Display; /* Used for graphics and colormap stuff */
Visual *SDL_Visual; /* The visual used by our window */
Window WMwindow; /* Input window, managed by window manager */
Window FSwindow; /* Fullscreen window, completely unmanaged */
Window SDL_Window; /* Shared by both displays (no X security?) */
Atom WM_DELETE_WINDOW; /* "close-window" protocol atom */
WMcursor *BlankCursor; /* The invisible cursor */
XIM X11_IM; /* Used to communicate with the input method (IM) server */
XIC X11_IC; /* Used for retaining the state, properties, and semantics of communication with the input method (IM) server */
char *SDL_windowid; /* Flag: true if we have been passed a window */
/* Direct Graphics Access extension information */
int using_dga;
#ifndef NO_SHARED_MEMORY
/* MIT shared memory extension information */
int use_mitshm;
XShmSegmentInfo shminfo;
#endif
/* The variables used for displaying graphics */
XImage *Ximage; /* The X image for our window */
GC gc; /* The graphic context for drawing */
/* The current width and height of the fullscreen mode */
int window_w;
int window_h;
/* Support for internal mouse warping */
struct
{
int x;
int y;
} mouse_last;
struct
{
int numerator;
int denominator;
int threshold;
} mouse_accel;
int mouse_relative;
/* available visuals of interest to us, sorted deepest first */
struct
{
Visual *visual;
int depth; /* number of significant bits/pixel */
int bpp; /* pixel quantum in bits */
} visuals[2 * 5]; /* at most 2 entries for 8, 15, 16, 24, 32 */
int nvisuals;
Visual *vis; /* current visual in use */
int depth; /* current visual depth (not bpp) */
/* Variables used by the X11 video mode code */
#if SDL_VIDEO_DRIVER_X11_XINERAMA
SDL_NAME(XineramaScreenInfo) * xinerama;
#endif
#if SDL_VIDEO_DRIVER_X11_XRANDR
XRRScreenConfiguration *screen_config;
int saved_size_id;
Rotation saved_rotation;
#endif
#if SDL_VIDEO_DRIVER_X11_VIDMODE
SDL_NAME(XF86VidModeModeInfo) saved_mode;
struct
{
int x, y;
} saved_view;
#endif
#if SDL_VIDEO_DRIVER_X11_XME /* XiG XME fullscreen */
XiGMiscResolutionInfo saved_res;
#endif
int use_xinerama;
int use_xrandr;
int use_vidmode;
int use_xme;
int currently_fullscreen;
/* Automatic mode switching support (entering/leaving fullscreen) */
Uint32 switch_waiting;
Uint32 switch_time;
/* Prevent too many XSync() calls */
int blit_queued;
/* Colormap handling */
Colormap DisplayColormap; /* The default display colormap */
Colormap XColorMap; /* The current window colormap */
int *XPixels; /* pixels value allocation counts */
float gamma_saved[3]; /* Saved gamma values for VidMode gamma */
int gamma_changed; /* flag: has VidMode gamma been modified? */
short *iconcolors; /* List of colors used by the icon */
/* Screensaver settings */
int screensaver_timeout;
BOOL dpms_enabled;
};
/* Old variable names */
#define local_X11 (this->hidden->local_X11)
#define SDL_Display (this->hidden->X11_Display)
#define GFX_Display (this->hidden->GFX_Display)
#define SDL_Screen DefaultScreen(this->hidden->X11_Display)
#define SDL_Visual (this->hidden->vis)
#define SDL_Root RootWindow(SDL_Display, SDL_Screen)
#define WMwindow (this->hidden->WMwindow)
#define FSwindow (this->hidden->FSwindow)
#define SDL_Window (this->hidden->SDL_Window)
#define WM_DELETE_WINDOW (this->hidden->WM_DELETE_WINDOW)
#define SDL_BlankCursor (this->hidden->BlankCursor)
#define SDL_IM (this->hidden->X11_IM)
#define SDL_IC (this->hidden->X11_IC)
#define SDL_windowid (this->hidden->SDL_windowid)
#define using_dga (this->hidden->using_dga)
#define use_mitshm (this->hidden->use_mitshm)
#define shminfo (this->hidden->shminfo)
#define SDL_Ximage (this->hidden->Ximage)
#define SDL_GC (this->hidden->gc)
#define window_w (this->hidden->window_w)
#define window_h (this->hidden->window_h)
#define mouse_last (this->hidden->mouse_last)
#define mouse_accel (this->hidden->mouse_accel)
#define mouse_relative (this->hidden->mouse_relative)
#define SDL_modelist (this->hidden->modelist)
#define xinerama (this->hidden->xinerama)
#define saved_mode (this->hidden->saved_mode)
#define saved_view (this->hidden->saved_view)
#define saved_res (this->hidden->saved_res)
#define screen_config (this->hidden->screen_config)
#define saved_size_id (this->hidden->saved_size_id)
#define saved_rotation (this->hidden->saved_rotation)
#define use_xinerama (this->hidden->use_xinerama)
#define use_vidmode (this->hidden->use_vidmode)
#define use_xrandr (this->hidden->use_xrandr)
#define use_xme (this->hidden->use_xme)
#define currently_fullscreen (this->hidden->currently_fullscreen)
#define switch_waiting (this->hidden->switch_waiting)
#define switch_time (this->hidden->switch_time)
#define blit_queued (this->hidden->blit_queued)
#define SDL_DisplayColormap (this->hidden->DisplayColormap)
#define SDL_PrivateColormap (this->hidden->PrivateColormap)
#define SDL_XColorMap (this->hidden->XColorMap)
#define SDL_XPixels (this->hidden->XPixels)
#define gamma_saved (this->hidden->gamma_saved)
#define gamma_changed (this->hidden->gamma_changed)
#define SDL_iconcolors (this->hidden->iconcolors)
#define screensaver_timeout (this->hidden->screensaver_timeout)
#define dpms_enabled (this->hidden->dpms_enabled)
/* Some versions of XFree86 have bugs - detect if this is one of them */
#define BUGGY_XFREE86(condition, buggy_version) \
((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
(VendorRelease(SDL_Display) condition buggy_version))
#endif /* _SDL_x11video_h */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
/* Functions to be exported */
extern void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon);
extern void X11_SetCaption(_THIS, const char *title, const char *icon);
extern void X11_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask);
extern int X11_IconifyWindow(_THIS);
extern SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode);
extern SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode);
extern int X11_GetWMInfo(_THIS, SDL_SysWMinfo * info);
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* This is the XFree86 Xv extension implementation of YUV video overlays */
#include "SDL_video.h"
#include "SDL_x11video.h"
#if SDL_VIDEO_DRIVER_X11_XV
extern SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height,
Uint32 format,
SDL_Surface * display);
extern int X11_LockYUVOverlay(_THIS, SDL_Overlay * overlay);
extern void X11_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay);
extern int X11_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay,
SDL_Rect * src, SDL_Rect * dst);
extern void X11_FreeYUVOverlay(_THIS, SDL_Overlay * overlay);
#endif /* SDL_VIDEO_DRIVER_X11_XV */
/* vi: set ts=4 sw=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment