From 97aaf9618abf37576570a56478a2fa2739f9440b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 26 Jun 2006 13:56:56 +0000 Subject: [PATCH] Started framework for Windows video driver --- configure.in | 22 +---- include/SDL_compat.h | 6 +- include/SDL_config.h.in | 3 +- include/SDL_syswm.h | 2 +- src/SDL.c | 5 ++ src/SDL_compat.c | 1 + src/video/SDL_sysvideo.h | 31 +------ src/video/SDL_video.c | 7 +- src/video/dummy/SDL_nullvideo.h | 4 +- src/video/win32/SDL_win32events.c | 31 +++++++ src/video/win32/SDL_win32events.h | 33 ++++++++ src/video/win32/SDL_win32video.c | 134 ++++++++++++++++++++++++++++++ src/video/win32/SDL_win32video.h | 43 ++++++++++ src/video/win32/SDL_win32window.c | 85 +++++++++++++++++++ src/video/win32/SDL_win32window.h | 47 +++++++++++ test/Makefile.in | 5 +- test/testsprite.c | 4 - test/testsprite2.c | 5 -- test/testwm2.c | 99 ++++++++++++++++++++++ test/threadwin.c | 2 +- 20 files changed, 499 insertions(+), 70 deletions(-) create mode 100644 src/video/win32/SDL_win32events.c create mode 100644 src/video/win32/SDL_win32events.h create mode 100644 src/video/win32/SDL_win32video.c create mode 100644 src/video/win32/SDL_win32video.h create mode 100644 src/video/win32/SDL_win32window.c create mode 100644 src/video/win32/SDL_win32window.h create mode 100644 test/testwm2.c diff --git a/configure.in b/configure.in index a96c1d2a2..f6a79bd89 100644 --- a/configure.in +++ b/configure.in @@ -1861,9 +1861,8 @@ AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[de fi if test x$enable_video = xyes; then - AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB) - SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c" - SOURCES="$SOURCES $srcdir/src/video/windib/*.c" + AC_DEFINE(SDL_VIDEO_DRIVER_WIN32) + SOURCES="$SOURCES $srcdir/src/video/win32/*.c" have_video=yes fi } @@ -1875,18 +1874,8 @@ CheckDIRECTX() AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]), , enable_directx=yes) if test x$enable_directx = xyes; then - have_directx=no - AC_CHECK_HEADER(ddraw.h, have_ddraw=yes) AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, use_dinput=yes) - if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then - have_directx=yes - fi - if test x$enable_video = xyes -a x$have_directx = xyes; then - AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW) - SOURCES="$SOURCES $srcdir/src/video/windx5/*.c" - have_video=yes - fi fi } @@ -2311,7 +2300,7 @@ case "$host" in if test x$enable_audio = xyes; then AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT) SOURCES="$SOURCES $srcdir/src/audio/windib/*.c" - if test x$have_directx = xyes; then + if test x$have_dsound = xyes; then AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND) SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c" fi @@ -2319,7 +2308,7 @@ case "$host" in fi # Set up files for the joystick library if test x$enable_joystick = xyes; then - if test x$have_directx = xyes; then + if test x$have_dinput = xyes; then AC_DEFINE(SDL_JOYSTICK_DINPUT) SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c" else @@ -2357,9 +2346,6 @@ case "$host" in fi # Set up the system libraries we need EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm" - if test x$have_directx = xyes; then - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldxguid" - fi # The Win32 platform requires special setup SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c" SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main" diff --git a/include/SDL_compat.h b/include/SDL_compat.h index a42a3e262..4de8457d9 100644 --- a/include/SDL_compat.h +++ b/include/SDL_compat.h @@ -26,7 +26,7 @@ #define _SDL_compat_h #include "SDL_video.h" -#include "SDL_syswm.h" +#include "SDL_version.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -117,6 +117,8 @@ typedef enum SDL_GRAB_ON = 1 } SDL_GrabMode; +struct SDL_SysWMinfo; + #define SDL_AllocSurface SDL_CreateRGBSurface extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void); @@ -151,7 +153,7 @@ extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface, int flags, extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface, const SDL_Color * colors, int firstcolor, int ncolors); -extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo * info); +extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo * info); extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width, diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 86d3d2d92..b7a3315e9 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -253,7 +253,6 @@ #undef SDL_VIDEO_DRIVER_BWINDOW #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS #undef SDL_VIDEO_DRIVER_DC -#undef SDL_VIDEO_DRIVER_DDRAW #undef SDL_VIDEO_DRIVER_DGA #undef SDL_VIDEO_DRIVER_DIRECTFB #undef SDL_VIDEO_DRIVER_DRAWSPROCKET @@ -276,7 +275,7 @@ #undef SDL_VIDEO_DRIVER_SVGALIB #undef SDL_VIDEO_DRIVER_TOOLBOX #undef SDL_VIDEO_DRIVER_VGL -#undef SDL_VIDEO_DRIVER_WINDIB +#undef SDL_VIDEO_DRIVER_WIN32 #undef SDL_VIDEO_DRIVER_WSCONS #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index e77777610..ee7b817e0 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -129,7 +129,7 @@ struct SDL_SysWMinfo GR_WINDOW_ID window; /* The display window */ }; -#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) +#elif defined(SDL_VIDEO_DRIVER_WIN32) #define WIN32_LEAN_AND_MEAN #include diff --git a/src/SDL.c b/src/SDL.c index 05076c924..ed44165ae 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -348,6 +348,11 @@ _DllMainCRTStartup(HANDLE hModule, } #endif /* building DLL with Watcom C */ +void SDL_SetModuleHandle(void *hInst) +{ + /* FIXME: Do we still need this? */ +} + #endif /* OS/2 elif __WIN32__ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/SDL_compat.c b/src/SDL_compat.c index 75f12e500..f3c375dc3 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -24,6 +24,7 @@ /* This file contains functions for backwards compatibility with SDL 1.2 */ #include "SDL.h" +#include "SDL_syswm.h" #include "video/SDL_pixels_c.h" diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 97db7c09f..941cdd244 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -29,14 +29,6 @@ #include "SDL_syswm.h" #undef SDL_PROTOTYPES_ONLY -/* This file prototypes the video driver implementation. - This is designed to be easily converted to C++ in the future. - */ - -#if SDL_VIDEO_OPENGL -#include "SDL_opengl.h" -#endif /* SDL_VIDEO_OPENGL */ - /* The SDL video driver */ typedef struct SDL_Window SDL_Window; @@ -256,21 +248,6 @@ struct SDL_VideoDevice /* Swap the current buffers in double buffer mode. */ void (*GL_SwapBuffers) (_THIS); - /* OpenGL functions for glSDL */ -#if SDL_VIDEO_OPENGL -#if !defined(__WIN32__) -#define WINAPI -#endif -#define SDL_PROC(ret,func,params) ret (WINAPI *func) params; -#include "SDL_glfuncs.h" -#undef SDL_PROC - - /* Texture id */ - GLuint texture; - - int is_32bit; -#endif - /* Determine whether the mouse should be in relative mode or not. This function is called when the input grab state or cursor visibility state changes. @@ -330,7 +307,6 @@ struct SDL_VideoDevice /* The function used to dispose of this structure */ void (*free) (_THIS); }; -#undef _THIS typedef struct VideoBootStrap { @@ -382,11 +358,8 @@ extern VideoBootStrap SVGALIB_bootstrap; #if SDL_VIDEO_DRIVER_GAPI extern VideoBootStrap GAPI_bootstrap; #endif -#if SDL_VIDEO_DRIVER_WINDIB -extern VideoBootStrap WINDIB_bootstrap; -#endif -#if SDL_VIDEO_DRIVER_DDRAW -extern VideoBootStrap DIRECTX_bootstrap; +#if SDL_VIDEO_DRIVER_WIN32 +extern VideoBootStrap WIN32_bootstrap; #endif #if SDL_VIDEO_DRIVER_BWINDOW extern VideoBootStrap BWINDOW_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index dab4043dc..fda52aa6e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -75,11 +75,8 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_GAPI &GAPI_bootstrap, #endif -#if SDL_VIDEO_DRIVER_WINDIB - &WINDIB_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_DDRAW - &DIRECTX_bootstrap, +#if SDL_VIDEO_DRIVER_WIN32 + &WIN32_bootstrap, #endif #if SDL_VIDEO_DRIVER_BWINDOW &BWINDOW_bootstrap, diff --git a/src/video/dummy/SDL_nullvideo.h b/src/video/dummy/SDL_nullvideo.h index 63eff7647..b597a5dc1 100644 --- a/src/video/dummy/SDL_nullvideo.h +++ b/src/video/dummy/SDL_nullvideo.h @@ -34,9 +34,9 @@ struct SDL_PrivateVideoData { - int w, h; - void *buffer; + int unused; }; #endif /* _SDL_nullvideo_h */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c new file mode 100644 index 000000000..b22494dc7 --- /dev/null +++ b/src/video/win32/SDL_win32events.c @@ -0,0 +1,31 @@ +/* + 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_win32video.h" + +void +WIN32_PumpEvents(_THIS) +{ +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32events.h b/src/video/win32/SDL_win32events.h new file mode 100644 index 000000000..fb9565178 --- /dev/null +++ b/src/video/win32/SDL_win32events.h @@ -0,0 +1,33 @@ +/* + 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_win32events_h +#define _SDL_win32events_h + +#include "../SDL_sysvideo.h" + +extern void WIN32_PumpEvents(_THIS); + +#endif /* _SDL_win32events_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32video.c b/src/video/win32/SDL_win32video.c new file mode 100644 index 000000000..91393c150 --- /dev/null +++ b/src/video/win32/SDL_win32video.c @@ -0,0 +1,134 @@ +/* + 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_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" + +#include "SDL_win32video.h" +#include "SDL_win32events.h" +#include "SDL_win32window.h" + +/* Initialization/Query functions */ +static int WIN32_VideoInit(_THIS); +static int WIN32_SetDisplayMode(_THIS, const SDL_DisplayMode * mode); +static void WIN32_VideoQuit(_THIS); + +/* WIN32 driver bootstrap functions */ + +static int +WIN32_Available(void) +{ + return (1); +} + +static void +WIN32_DeleteDevice(SDL_VideoDevice * device) +{ + SDL_free(device->hidden); + SDL_free(device); +} + +static SDL_VideoDevice * +WIN32_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); + if (device) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + SDL_malloc((sizeof *device->hidden)); + } + if ((device == NULL) || (device->hidden == NULL)) { + SDL_OutOfMemory(); + if (device) { + SDL_free(device); + } + return (0); + } + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + /* Set the function pointers */ + device->VideoInit = WIN32_VideoInit; + device->SetDisplayMode = WIN32_SetDisplayMode; + device->VideoQuit = WIN32_VideoQuit; + device->PumpEvents = WIN32_PumpEvents; + +#undef CreateWindow + device->CreateWindow = WIN32_CreateWindow; + device->CreateWindowFrom = WIN32_CreateWindowFrom; + device->SetWindowTitle = WIN32_SetWindowTitle; + device->SetWindowPosition = WIN32_SetWindowPosition; + device->SetWindowSize = WIN32_SetWindowSize; + device->ShowWindow = WIN32_ShowWindow; + device->HideWindow = WIN32_HideWindow; + device->RaiseWindow = WIN32_RaiseWindow; + device->MaximizeWindow = WIN32_MaximizeWindow; + device->MinimizeWindow = WIN32_MinimizeWindow; + device->RestoreWindow = WIN32_RestoreWindow; + device->SetWindowGrab = WIN32_SetWindowGrab; + device->DestroyWindow = WIN32_DestroyWindow; + device->GetWindowWMInfo = WIN32_GetWindowWMInfo; + + device->free = WIN32_DeleteDevice; + + return device; +} + +VideoBootStrap WIN32_bootstrap = { + "win32", "SDL Win32/64 video driver", + WIN32_Available, WIN32_CreateDevice +}; + + +int +WIN32_VideoInit(_THIS) +{ + SDL_DisplayMode mode; + + SDL_AddBasicVideoDisplay(NULL); + //SDL_AddRenderDriver(0, &SDL_WIN32_RenderDriver); + + SDL_zero(mode); + SDL_AddDisplayMode(0, &mode); + + /* We're done! */ + return 0; +} + +static int +WIN32_SetDisplayMode(_THIS, const SDL_DisplayMode * mode) +{ + SDL_CurrentDisplay.current_mode = *mode; + return 0; +} + +void +WIN32_VideoQuit(_THIS) +{ +} + +/* vim: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32video.h b/src/video/win32/SDL_win32video.h new file mode 100644 index 000000000..ce5518436 --- /dev/null +++ b/src/video/win32/SDL_win32video.h @@ -0,0 +1,43 @@ +/* + 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_win32video_h +#define _SDL_win32video_h + +#include "../SDL_sysvideo.h" + +#define WIN32_LEAN_AND_MEAN +#include + +#include "SDL_win32events.h" +#include "SDL_win32window.h" + +/* Private display data */ + +struct SDL_PrivateVideoData +{ +}; + +#endif /* _SDL_win32video_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c new file mode 100644 index 000000000..fd003deae --- /dev/null +++ b/src/video/win32/SDL_win32window.c @@ -0,0 +1,85 @@ +/* + 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_sysvideo.h" + +#include "SDL_win32video.h" + + +int WIN32_CreateWindow(_THIS, SDL_Window * window) +{ +} + +int WIN32_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +{ +} + +void WIN32_SetWindowTitle(_THIS, SDL_Window * window) +{ +} + +void WIN32_SetWindowPosition(_THIS, SDL_Window * window) +{ +} + +void WIN32_SetWindowSize(_THIS, SDL_Window * window) +{ +} + +void WIN32_ShowWindow(_THIS, SDL_Window * window) +{ +} + +void WIN32_HideWindow(_THIS, SDL_Window * window) +{ +} + +void WIN32_RaiseWindow(_THIS, SDL_Window * window) +{ +} + +void WIN32_MaximizeWindow(_THIS, SDL_Window * window) +{ +} + +void WIN32_MinimizeWindow(_THIS, SDL_Window * window) +{ +} + +void WIN32_RestoreWindow(_THIS, SDL_Window * window) +{ +} + +void WIN32_SetWindowGrab(_THIS, SDL_Window * window) +{ +} + +void WIN32_DestroyWindow(_THIS, SDL_Window * window) +{ +} + +SDL_bool WIN32_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +{ +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32window.h b/src/video/win32/SDL_win32window.h new file mode 100644 index 000000000..761d42672 --- /dev/null +++ b/src/video/win32/SDL_win32window.h @@ -0,0 +1,47 @@ +/* + 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_win32window_h +#define _SDL_win32window_h + +#include "../SDL_sysvideo.h" +#include "SDL_win32video.h" + +extern int WIN32_CreateWindow(_THIS, SDL_Window * window); +extern int WIN32_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +extern void WIN32_SetWindowTitle(_THIS, SDL_Window * window); +extern void WIN32_SetWindowPosition(_THIS, SDL_Window * window); +extern void WIN32_SetWindowSize(_THIS, SDL_Window * window); +extern void WIN32_ShowWindow(_THIS, SDL_Window * window); +extern void WIN32_HideWindow(_THIS, SDL_Window * window); +extern void WIN32_RaiseWindow(_THIS, SDL_Window * window); +extern void WIN32_MaximizeWindow(_THIS, SDL_Window * window); +extern void WIN32_MinimizeWindow(_THIS, SDL_Window * window); +extern void WIN32_RestoreWindow(_THIS, SDL_Window * window); +extern void WIN32_SetWindowGrab(_THIS, SDL_Window * window); +extern void WIN32_DestroyWindow(_THIS, SDL_Window * window); +extern SDL_bool WIN32_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); + +#endif /* _SDL_win32window_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/Makefile.in b/test/Makefile.in index a7ac4f1e0..b905a4140 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -7,7 +7,7 @@ EXE = @EXE@ CFLAGS = @CFLAGS@ LIBS = @LIBS@ -TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) threadwin$(EXE) torturethread$(EXE) +TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE) all: $(TARGETS) @@ -101,6 +101,9 @@ testwin$(EXE): $(srcdir)/testwin.c testwm$(EXE): $(srcdir)/testwm.c $(CC) -o $@ $? $(CFLAGS) $(LIBS) +testwm2$(EXE): $(srcdir)/testwm.c + $(CC) -o $@ $? $(CFLAGS) $(LIBS) + threadwin$(EXE): $(srcdir)/threadwin.c $(CC) -o $@ $? $(CFLAGS) $(LIBS) diff --git a/test/testsprite.c b/test/testsprite.c index 9608330da..76ee5de26 100644 --- a/test/testsprite.c +++ b/test/testsprite.c @@ -1,10 +1,6 @@ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include #include -#include -#include -#include #include #include "SDL.h" diff --git a/test/testsprite2.c b/test/testsprite2.c index 1dd457c9a..b83edd1dd 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -1,10 +1,6 @@ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include #include -#include -#include -#include #include #include "SDL.h" @@ -122,7 +118,6 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite) int main(int argc, char *argv[]) { - const SDL_DisplayMode *current_mode; int window_w, window_h; int i, done; SDL_Event event; diff --git a/test/testwm2.c b/test/testwm2.c new file mode 100644 index 000000000..a580357e7 --- /dev/null +++ b/test/testwm2.c @@ -0,0 +1,99 @@ +/* Simple program: Move N sprites around on the screen as fast as possible */ + +#include "SDL.h" + +#define NUM_WINDOWS 2 +#define WINDOW_W 640 +#define WINDOW_H 480 + +static int num_windows; +static SDL_WindowID *windows; + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + if (windows) { + SDL_free(windows); + } + SDL_Quit(); + exit(rc); +} + +int +main(int argc, char *argv[]) +{ + int window_w, window_h; + int i, done; + SDL_Event event; + + /* Initialize SDL */ + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + return (1); + } + + num_windows = NUM_WINDOWS; + window_w = WINDOW_W; + window_h = WINDOW_H; + while (argc > 1) { + --argc; + if (strcmp(argv[argc - 1], "-width") == 0) { + window_w = atoi(argv[argc]); + --argc; + } else if (strcmp(argv[argc - 1], "-height") == 0) { + window_h = atoi(argv[argc]); + --argc; + } else { + fprintf(stderr, + "Usage: %s [-width] [-height]\n", argv[0]); + quit(1); + } + } + + /* Set the desktop mode, we don't care what it is */ + if (SDL_SetDisplayMode(NULL) < 0) { + fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError()); + quit(2); + } + + /* Create the windows */ + windows = (SDL_WindowID *) SDL_malloc(num_windows * sizeof(*windows)); + if (!windows) { + fprintf(stderr, "Out of memory!\n"); + quit(2); + } + for (i = 0; i < num_windows; ++i) { + char title[32]; + + SDL_snprintf(title, sizeof(title), "testwm %d", i + 1); + windows[i] = + SDL_CreateWindow(title, -1, -1, window_w, window_h, + SDL_WINDOW_SHOWN); + if (!windows[i]) { + fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); + quit(2); + } + } + + /* Loop, blitting sprites and waiting for a keystroke */ + done = 0; + while (!done) { + /* Check for events */ + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } + + quit(0); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/threadwin.c b/test/threadwin.c index 3c4e19e8b..edfc10755 100644 --- a/test/threadwin.c +++ b/test/threadwin.c @@ -80,7 +80,7 @@ LoadIconSurface(char *file, Uint8 ** maskp) } int SDLCALL -FilterEvents(const SDL_Event * event) +FilterEvents(SDL_Event * event) { static int reallyquit = 0;