diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-24 13:54:14 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-24 13:54:14 (GMT) |
| commit | eafcdf8ec94b058707f1a6b8a2b9b5076c6275ca (patch) | |
| tree | e255f2ebfc0d1935209c0de52271e6d5da79df9d /src/graphics.c | |
| parent | 128e8c1ff8a27ae96b414bed4cc8f5a294063136 (diff) | |
| download | powder-eafcdf8ec94b058707f1a6b8a2b9b5076c6275ca.zip powder-eafcdf8ec94b058707f1a6b8a2b9b5076c6275ca.tar.gz | |
Improve error handling on display initialisation
Diffstat (limited to 'src/graphics.c')
| -rw-r--r-- | src/graphics.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/graphics.c b/src/graphics.c index fdaa6d3..863507b 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3824,12 +3824,12 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) } } -void sdl_open(void) +int sdl_open(void) { if (SDL_Init(SDL_INIT_VIDEO)<0) { fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError()); - exit(1); + return 0; } atexit(SDL_Quit); #ifdef OpenGL @@ -3861,12 +3861,22 @@ void sdl_open(void) if (!sdl_scrn) { fprintf(stderr, "Creating window: %s\n", SDL_GetError()); - exit(1); + return 0; } SDL_WM_SetCaption("The Powder Toy", "Powder Toy"); sdl_seticon(); SDL_EnableUNICODE(1); //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); +#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11) + SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); + SDL_VERSION(&sdl_wminfo.version); + SDL_GetWMInfo(&sdl_wminfo); + sdl_wminfo.info.x11.lock_func(); + XA_CLIPBOARD = XInternAtom(sdl_wminfo.info.x11.display, "CLIPBOARD", 1); + XA_TARGETS = XInternAtom(sdl_wminfo.info.x11.display, "TARGETS", 1); + sdl_wminfo.info.x11.unlock_func(); +#endif + return 1; } #ifdef OpenGL |
