src/video/x11/SDL_x11image.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 31 Aug 2001 21:08:30 +0000
changeset 161 eb6b76a95f2d
parent 0 74212992fb08
child 166 39877400bd1e
permissions -rw-r--r--
An expose event is now sent when using XVideo output.
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
#include <stdlib.h>
slouken@0
    29
slouken@0
    30
#include "SDL_error.h"
slouken@0
    31
#include "SDL_endian.h"
slouken@161
    32
#include "SDL_events_c.h"
slouken@0
    33
#include "SDL_x11image_c.h"
slouken@0
    34
slouken@0
    35
#if defined(__USLC__)
slouken@0
    36
#ifdef HAVE_KSTAT
slouken@0
    37
#undef HAVE_KSTAT
slouken@0
    38
#endif
slouken@0
    39
#include <unistd.h>
slouken@0
    40
#endif
slouken@0
    41
slouken@0
    42
#ifdef HAVE_KSTAT
slouken@0
    43
#include <kstat.h>
slouken@0
    44
#endif
slouken@0
    45
slouken@0
    46
#ifndef NO_SHARED_MEMORY
slouken@0
    47
slouken@0
    48
/* Shared memory information */
slouken@0
    49
extern int XShmQueryExtension(Display *dpy);	/* Not in X11 headers */
slouken@0
    50
slouken@0
    51
/* Shared memory error handler routine */
slouken@0
    52
static int shm_error;
slouken@0
    53
static int (*X_handler)(Display *, XErrorEvent *) = NULL;
slouken@0
    54
static int shm_errhandler(Display *d, XErrorEvent *e)
slouken@0
    55
{
slouken@0
    56
        if ( e->error_code == BadAccess ) {
slouken@0
    57
        	++shm_error;
slouken@0
    58
        	return(0);
slouken@0
    59
        } else
slouken@0
    60
		return(X_handler(d,e));
slouken@0
    61
}
slouken@0
    62
#endif /* ! NO_SHARED_MEMORY */
slouken@0
    63
slouken@0
    64
/* Various screen update functions available */
slouken@0
    65
static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
slouken@0
    66
static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects);
slouken@0
    67
slouken@0
    68
int X11_SetupImage(_THIS, SDL_Surface *screen)
slouken@0
    69
{
slouken@0
    70
#ifdef NO_SHARED_MEMORY
slouken@0
    71
	screen->pixels = malloc(screen->h*screen->pitch);
slouken@0
    72
#else
slouken@0
    73
	/* Allocate shared memory if possible */
slouken@0
    74
	if ( use_mitshm ) {
slouken@0
    75
		shminfo.shmid = shmget(IPC_PRIVATE, screen->h*screen->pitch,
slouken@0
    76
								IPC_CREAT|0777);
slouken@0
    77
		if ( shminfo.shmid >= 0 ) {
slouken@0
    78
			shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
slouken@0
    79
			shminfo.readOnly = False;
slouken@0
    80
			if ( shminfo.shmaddr != (char *)-1 ) {
slouken@0
    81
				shm_error = False;
slouken@0
    82
				X_handler = XSetErrorHandler(shm_errhandler);
slouken@0
    83
				XShmAttach(SDL_Display, &shminfo);
slouken@0
    84
				XSync(SDL_Display, True);
slouken@0
    85
				XSetErrorHandler(X_handler);
slouken@0
    86
				if ( shm_error == True )
slouken@0
    87
					shmdt(shminfo.shmaddr);
slouken@0
    88
			} else {
slouken@0
    89
				shm_error = True;
slouken@0
    90
			}
slouken@0
    91
			shmctl(shminfo.shmid, IPC_RMID, NULL);
slouken@0
    92
		} else {
slouken@0
    93
			shm_error = True;
slouken@0
    94
		}
slouken@0
    95
		if ( shm_error == True )
slouken@0
    96
			use_mitshm = 0;
slouken@0
    97
	}
slouken@0
    98
	if ( use_mitshm ) {
slouken@0
    99
		screen->pixels = shminfo.shmaddr;
slouken@0
   100
	} else {
slouken@0
   101
		screen->pixels = malloc(screen->h*screen->pitch);
slouken@0
   102
	}
slouken@0
   103
#endif /* NO_SHARED_MEMORY */
slouken@0
   104
	if ( screen->pixels == NULL ) {
slouken@0
   105
		SDL_OutOfMemory();
slouken@0
   106
		return(-1);
slouken@0
   107
	}
slouken@0
   108
slouken@0
   109
#ifdef NO_SHARED_MEMORY
slouken@0
   110
	{
slouken@0
   111
 	        int bpp = screen->format->BytesPerPixel;
slouken@0
   112
		SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
slouken@0
   113
					  this->hidden->depth, ZPixmap, 0,
slouken@0
   114
					  (char *)screen->pixels, 
slouken@0
   115
					  screen->w, screen->h,
slouken@0
   116
					  (bpp == 3) ? 32 : bpp * 8,
slouken@0
   117
					  0);
slouken@0
   118
	}
slouken@0
   119
#else
slouken@0
   120
	if ( use_mitshm ) {
slouken@0
   121
		SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual,
slouken@0
   122
					     this->hidden->depth, ZPixmap,
slouken@0
   123
					     shminfo.shmaddr, &shminfo, 
slouken@0
   124
					     screen->w, screen->h);
slouken@0
   125
	} else {
slouken@0
   126
 	        int bpp = screen->format->BytesPerPixel;
slouken@0
   127
		SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
slouken@0
   128
					  this->hidden->depth, ZPixmap, 0,
slouken@0
   129
					  (char *)screen->pixels, 
slouken@0
   130
					  screen->w, screen->h,
slouken@0
   131
					  (bpp == 3) ? 32 : bpp * 8,
slouken@0
   132
					  0);
slouken@0
   133
	}
slouken@0
   134
#endif /* NO_SHARED_MEMORY */
slouken@0
   135
	if ( SDL_Ximage == NULL ) {
slouken@0
   136
		SDL_SetError("Couldn't create XImage");
slouken@0
   137
#ifndef NO_SHARED_MEMORY
slouken@0
   138
		if ( use_mitshm ) {
slouken@0
   139
			XShmDetach(SDL_Display, &shminfo);
slouken@0
   140
			XSync(SDL_Display, False);
slouken@0
   141
			shmdt(shminfo.shmaddr);
slouken@0
   142
			screen->pixels = NULL;
slouken@0
   143
		}
slouken@0
   144
#endif /* ! NO_SHARED_MEMORY */
slouken@0
   145
		return(-1);
slouken@0
   146
	}
slouken@0
   147
	screen->pitch = SDL_Ximage->bytes_per_line;
slouken@0
   148
slouken@0
   149
	/* Determine what blit function to use */
slouken@0
   150
#ifdef NO_SHARED_MEMORY
slouken@0
   151
	this->UpdateRects = X11_NormalUpdate;
slouken@0
   152
#else
slouken@0
   153
	if ( use_mitshm ) {
slouken@0
   154
		this->UpdateRects = X11_MITSHMUpdate;
slouken@0
   155
	} else {
slouken@0
   156
		this->UpdateRects = X11_NormalUpdate;
slouken@0
   157
	}
slouken@0
   158
#endif
slouken@0
   159
	return(0);
slouken@0
   160
}
slouken@0
   161
slouken@0
   162
void X11_DestroyImage(_THIS, SDL_Surface *screen)
slouken@0
   163
{
slouken@0
   164
	if ( SDL_Ximage ) {
slouken@0
   165
		XDestroyImage(SDL_Ximage);
slouken@0
   166
#ifndef NO_SHARED_MEMORY
slouken@0
   167
		if ( use_mitshm ) {
slouken@0
   168
			XShmDetach(SDL_Display, &shminfo);
slouken@0
   169
			XSync(SDL_Display, False);
slouken@0
   170
			shmdt(shminfo.shmaddr);
slouken@0
   171
		}
slouken@0
   172
#endif /* ! NO_SHARED_MEMORY */
slouken@0
   173
		SDL_Ximage = NULL;
slouken@0
   174
	}
slouken@0
   175
	if ( screen ) {
slouken@0
   176
		screen->pixels = NULL;
slouken@0
   177
	}
slouken@0
   178
}
slouken@0
   179
slouken@0
   180
/* This is a hack to see whether this system has more than 1 CPU */
slouken@0
   181
static int num_CPU(void)
slouken@0
   182
{
slouken@0
   183
       static int num_cpus = 0;
slouken@0
   184
slouken@0
   185
       if(!num_cpus) {
slouken@0
   186
#ifdef linux
slouken@0
   187
           char line[BUFSIZ];
slouken@0
   188
           FILE *pstat = fopen("/proc/stat", "r");
slouken@0
   189
           if ( pstat ) {
slouken@0
   190
               while ( fgets(line, sizeof(line), pstat) ) {
slouken@0
   191
                   if (memcmp(line, "cpu", 3) == 0 && line[3] != ' ') {
slouken@0
   192
                       ++num_cpus;
slouken@0
   193
                   }
slouken@0
   194
               }
slouken@0
   195
               fclose(pstat);
slouken@0
   196
           }
slouken@0
   197
#elif defined(HAVE_KSTAT)
slouken@0
   198
           kstat_ctl_t *kc = kstat_open();
slouken@0
   199
           kstat_t *ks;
slouken@0
   200
           kstat_named_t *kn;
slouken@0
   201
           if(kc) {
slouken@0
   202
               if((ks = kstat_lookup(kc, "unix", -1, "system_misc"))
slouken@0
   203
                  && kstat_read(kc, ks, NULL) != -1
slouken@0
   204
                  && (kn = kstat_data_lookup(ks, "ncpus")))
slouken@0
   205
#ifdef KSTAT_DATA_UINT32
slouken@0
   206
                   num_cpus = kn->value.ui32;
slouken@0
   207
#else
slouken@0
   208
                   num_cpus = kn->value.ul; /* needed in solaris <2.6 */
slouken@0
   209
#endif
slouken@0
   210
               kstat_close(kc);
slouken@0
   211
           }
slouken@0
   212
#elif defined(__USLC__)
slouken@0
   213
           num_cpus = (int)sysconf(_SC_NPROCESSORS_CONF);
slouken@0
   214
#endif
slouken@0
   215
           if ( num_cpus <= 0 ) {
slouken@0
   216
               num_cpus = 1;
slouken@0
   217
           }
slouken@0
   218
       }
slouken@0
   219
       return num_cpus;
slouken@0
   220
}
slouken@0
   221
slouken@0
   222
int X11_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
slouken@0
   223
{
slouken@0
   224
	int retval;
slouken@0
   225
slouken@0
   226
	X11_DestroyImage(this, screen);
slouken@0
   227
        if ( flags & SDL_OPENGL ) {  /* No image when using GL */
slouken@0
   228
        	retval = 0;
slouken@0
   229
        } else {
slouken@0
   230
		retval = X11_SetupImage(this, screen);
slouken@0
   231
		/* We support asynchronous blitting on the display */
slouken@0
   232
		if ( flags & SDL_ASYNCBLIT ) {
slouken@0
   233
			/* This is actually slower on single-CPU systems,
slouken@0
   234
			   probably because of CPU contention between the
slouken@0
   235
			   X server and the application.
slouken@0
   236
			   Note: Is this still true with XFree86 4.0?
slouken@0
   237
			*/
slouken@0
   238
			if ( num_CPU() > 1 ) {
slouken@0
   239
				screen->flags |= SDL_ASYNCBLIT;
slouken@0
   240
			}
slouken@0
   241
		}
slouken@0
   242
	}
slouken@0
   243
	return(retval);
slouken@0
   244
}
slouken@0
   245
slouken@0
   246
/* We don't actually allow hardware surfaces other than the main one */
slouken@0
   247
int X11_AllocHWSurface(_THIS, SDL_Surface *surface)
slouken@0
   248
{
slouken@0
   249
	return(-1);
slouken@0
   250
}
slouken@0
   251
void X11_FreeHWSurface(_THIS, SDL_Surface *surface)
slouken@0
   252
{
slouken@0
   253
	return;
slouken@0
   254
}
slouken@0
   255
slouken@0
   256
int X11_LockHWSurface(_THIS, SDL_Surface *surface)
slouken@0
   257
{
slouken@0
   258
	if ( (surface == SDL_VideoSurface) && blit_queued ) {
slouken@0
   259
		XSync(GFX_Display, False);
slouken@0
   260
		blit_queued = 0;
slouken@0
   261
	}
slouken@0
   262
	return(0);
slouken@0
   263
}
slouken@0
   264
void X11_UnlockHWSurface(_THIS, SDL_Surface *surface)
slouken@0
   265
{
slouken@0
   266
	return;
slouken@0
   267
}
slouken@0
   268
slouken@0
   269
int X11_FlipHWSurface(_THIS, SDL_Surface *surface)
slouken@0
   270
{
slouken@0
   271
	return(0);
slouken@0
   272
}
slouken@0
   273
slouken@0
   274
/* Byte-swap the pixels in the display image */
slouken@0
   275
static void X11_SwapAllPixels(SDL_Surface *screen)
slouken@0
   276
{
slouken@0
   277
	int x, y;
slouken@0
   278
slouken@0
   279
	switch (screen->format->BytesPerPixel) {
slouken@0
   280
	    case 2: {
slouken@0
   281
		Uint16 *spot;
slouken@0
   282
		for ( y=0; y<screen->h; ++y ) {
slouken@0
   283
			spot = (Uint16 *) ((Uint8 *)screen->pixels +
slouken@0
   284
						y * screen->pitch);
slouken@0
   285
			for ( x=0; x<screen->w; ++x, ++spot ) {
slouken@0
   286
				*spot = SDL_Swap16(*spot);
slouken@0
   287
			}
slouken@0
   288
		}
slouken@0
   289
	    }
slouken@0
   290
	    break;
slouken@0
   291
slouken@0
   292
	    case 4: {
slouken@0
   293
		Uint32 *spot;
slouken@0
   294
		for ( y=0; y<screen->h; ++y ) {
slouken@0
   295
			spot = (Uint32 *) ((Uint8 *)screen->pixels +
slouken@0
   296
						y * screen->pitch);
slouken@0
   297
			for ( x=0; x<screen->w; ++x, ++spot ) {
slouken@0
   298
				*spot = SDL_Swap32(*spot);
slouken@0
   299
			}
slouken@0
   300
		}
slouken@0
   301
	    }
slouken@0
   302
	    break;
slouken@0
   303
slouken@0
   304
	    default:
slouken@0
   305
		/* should never get here */
slouken@0
   306
		break;
slouken@0
   307
	}
slouken@0
   308
}
slouken@0
   309
static void X11_SwapPixels(SDL_Surface *screen, SDL_Rect *rect)
slouken@0
   310
{
slouken@0
   311
	int x, minx, maxx;
slouken@0
   312
	int y, miny, maxy;
slouken@0
   313
slouken@0
   314
	switch (screen->format->BytesPerPixel) {
slouken@0
   315
	    case 2: {
slouken@0
   316
		Uint16 *spot;
slouken@0
   317
		minx = rect->x;
slouken@0
   318
		maxx = rect->x + rect->w;
slouken@0
   319
		miny = rect->y;
slouken@0
   320
		maxy = rect->y + rect->h;
slouken@0
   321
		for ( y=miny; y<maxy; ++y ) {
slouken@0
   322
		    spot = (Uint16 *) ((Uint8 *)screen->pixels +
slouken@0
   323
				       y * screen->pitch + minx * 2);
slouken@0
   324
		    for ( x=minx; x<maxx; ++x, ++spot ) {
slouken@0
   325
			*spot = SDL_Swap16(*spot);
slouken@0
   326
		    }
slouken@0
   327
		}
slouken@0
   328
	    }
slouken@0
   329
	    break;
slouken@0
   330
slouken@0
   331
	    case 4: {
slouken@0
   332
		Uint32 *spot;
slouken@0
   333
		minx = rect->x;
slouken@0
   334
		maxx = rect->x + rect->w;
slouken@0
   335
		miny = rect->y;
slouken@0
   336
		maxy = rect->y + rect->h;
slouken@0
   337
		for ( y=miny; y<maxy; ++y ) {
slouken@0
   338
		    spot = (Uint32 *) ((Uint8 *)screen->pixels +
slouken@0
   339
				       y * screen->pitch + minx * 4);
slouken@0
   340
		    for ( x=minx; x<maxx; ++x, ++spot ) {
slouken@0
   341
			*spot = SDL_Swap32(*spot);
slouken@0
   342
		    }
slouken@0
   343
		}
slouken@0
   344
	    }
slouken@0
   345
	    break;
slouken@0
   346
slouken@0
   347
	    default:
slouken@0
   348
		/* should never get here */
slouken@0
   349
		break;
slouken@0
   350
	}
slouken@0
   351
}
slouken@0
   352
slouken@0
   353
static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
slouken@0
   354
{
slouken@0
   355
	int i;
slouken@0
   356
slouken@0
   357
	/* Check for endian-swapped X server, swap if necessary (VERY slow!) */
slouken@0
   358
	if ( swap_pixels &&
slouken@0
   359
	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
slouken@0
   360
		for ( i=0; i<numrects; ++i ) {
slouken@0
   361
			if ( ! rects[i].w ) { /* Clipped? */
slouken@0
   362
				continue;
slouken@0
   363
			}
slouken@0
   364
		        X11_SwapPixels(this->screen, rects + i);
slouken@0
   365
			XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
slouken@0
   366
				rects[i].x, rects[i].y,
slouken@0
   367
				rects[i].x, rects[i].y, rects[i].w, rects[i].h);
slouken@0
   368
			X11_SwapPixels(this->screen, rects + i);
slouken@0
   369
		}
slouken@0
   370
	} else {
slouken@0
   371
		for ( i=0; i<numrects; ++i ) {
slouken@0
   372
			if ( ! rects[i].w ) { /* Clipped? */
slouken@0
   373
				continue;
slouken@0
   374
			}
slouken@0
   375
			XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
slouken@0
   376
				rects[i].x, rects[i].y,
slouken@0
   377
				rects[i].x, rects[i].y, rects[i].w, rects[i].h);
slouken@0
   378
		}
slouken@0
   379
	}
slouken@0
   380
	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
slouken@0
   381
		XFlush(GFX_Display);
slouken@0
   382
		++blit_queued;
slouken@0
   383
	} else {
slouken@0
   384
		XSync(GFX_Display, False);
slouken@0
   385
	}
slouken@0
   386
}
slouken@0
   387
slouken@0
   388
static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects)
slouken@0
   389
{
slouken@0
   390
#ifndef NO_SHARED_MEMORY
slouken@0
   391
	int i;
slouken@0
   392
slouken@0
   393
	for ( i=0; i<numrects; ++i ) {
slouken@0
   394
		if ( ! rects[i].w ) { /* Clipped? */
slouken@0
   395
			continue;
slouken@0
   396
		}
slouken@0
   397
		XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
slouken@0
   398
				rects[i].x, rects[i].y,
slouken@0
   399
				rects[i].x, rects[i].y, rects[i].w, rects[i].h,
slouken@0
   400
									False);
slouken@0
   401
	}
slouken@0
   402
	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
slouken@0
   403
		XFlush(GFX_Display);
slouken@0
   404
		++blit_queued;
slouken@0
   405
	} else {
slouken@0
   406
		XSync(GFX_Display, False);
slouken@0
   407
	}
slouken@0
   408
#endif /* ! NO_SHARED_MEMORY */
slouken@0
   409
}
slouken@0
   410
slouken@0
   411
/* There's a problem with the automatic refreshing of the display.
slouken@0
   412
   Even though the XVideo code uses the GFX_Display to update the
slouken@0
   413
   video memory, it appears that updating the window asynchronously
slouken@0
   414
   from a different thread will cause "blackouts" of the window.
slouken@0
   415
   This is a sort of a hacked workaround for the problem.
slouken@0
   416
*/
slouken@0
   417
static int enable_autorefresh = 1;
slouken@0
   418
slouken@0
   419
void X11_DisableAutoRefresh(_THIS)
slouken@0
   420
{
slouken@0
   421
	--enable_autorefresh;
slouken@0
   422
}
slouken@0
   423
slouken@0
   424
void X11_EnableAutoRefresh(_THIS)
slouken@0
   425
{
slouken@0
   426
	++enable_autorefresh;
slouken@0
   427
}
slouken@0
   428
slouken@0
   429
void X11_RefreshDisplay(_THIS)
slouken@0
   430
{
slouken@161
   431
	/* Don't refresh a display that doesn't have an image (like GL)
slouken@161
   432
	   Instead, post an expose event so the application can refresh.
slouken@161
   433
	 */
slouken@0
   434
	if ( ! SDL_Ximage || (enable_autorefresh <= 0) ) {
slouken@161
   435
		SDL_PrivateExpose();
slouken@0
   436
		return;
slouken@0
   437
	}
slouken@0
   438
#ifndef NO_SHARED_MEMORY
slouken@0
   439
	if ( this->UpdateRects == X11_MITSHMUpdate ) {
slouken@0
   440
		XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
slouken@0
   441
				0, 0, 0, 0, this->screen->w, this->screen->h,
slouken@0
   442
				False);
slouken@0
   443
	} else {
slouken@0
   444
#else
slouken@0
   445
	{
slouken@0
   446
#endif /* ! NO_SHARED_MEMORY */
slouken@0
   447
		/* Check for endian-swapped X server, swap if necessary */
slouken@0
   448
		if ( swap_pixels &&
slouken@0
   449
		     ((this->screen->format->BytesPerPixel%2) == 0) ) {
slouken@0
   450
			X11_SwapAllPixels(this->screen);
slouken@0
   451
			XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
slouken@0
   452
				0, 0, 0, 0, this->screen->w, this->screen->h);
slouken@0
   453
			X11_SwapAllPixels(this->screen);
slouken@0
   454
		} else {
slouken@0
   455
			XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
slouken@0
   456
				0, 0, 0, 0, this->screen->w, this->screen->h);
slouken@0
   457
		}
slouken@0
   458
	}
slouken@0
   459
	XSync(SDL_Display, False);
slouken@0
   460
}