From 49b996faadf0fedcee25d4a8f96f4c4007c29f5f Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 15 Oct 2010 13:00:46 +0100 Subject: [PATCH] Cygwin/X: Make g_hmodDirectDraw static Add winReleaseDDProcAddresses() for releasing the direct draw module handle, so g_hmodDirectDraw can be made static Remove unneeded duplicate extern definitions of g_fpDirectDrawCreate and g_fpDirectDrawCreateClipper, and move the definition from winglobals.c to winengine.c Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/InitOutput.c | 12 +----------- hw/xwin/win.h | 4 +++- hw/xwin/winengine.c | 26 +++++++++++++++++++++----- hw/xwin/winglobals.c | 4 ---- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 5ed3e74e5..63fca3abb 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -90,10 +90,6 @@ extern HWND g_hwndClipboard; extern Bool g_fClipboard; #endif -extern HMODULE g_hmodDirectDraw; -extern FARPROC g_fpDirectDrawCreate; -extern FARPROC g_fpDirectDrawCreateClipper; - extern HMODULE g_hmodCommonControls; extern FARPROC g_fpTrackMouseEvent; extern Bool g_fNoHelpMessageBox; @@ -258,13 +254,7 @@ ddxGiveUp (void) * At this point we aren't creating any new screens, so * we are guaranteed to not need the DirectDraw functions. */ - if (g_hmodDirectDraw != NULL) - { - FreeLibrary (g_hmodDirectDraw); - g_hmodDirectDraw = NULL; - g_fpDirectDrawCreate = NULL; - g_fpDirectDrawCreateClipper = NULL; - } + winReleaseDDProcAddresses(); /* Unload our TrackMouseEvent function pointer */ if (g_hmodCommonControls != NULL) diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 1b1358cda..f197def56 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -653,7 +653,6 @@ extern DeviceIntPtr g_pwinKeyboard; * Extern declares for dynamically loaded libraries and function pointers */ -extern HMODULE g_hmodDirectDraw; extern FARPROC g_fpDirectDrawCreate; extern FARPROC g_fpDirectDrawCreateClipper; @@ -859,6 +858,9 @@ winSetEngine (ScreenPtr pScreen); Bool winGetDDProcAddresses (void); +void +winReleaseDDProcAddresses(void); + /* * winerror.c diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c index fb9aed8a0..e866e1ea1 100644 --- a/hw/xwin/winengine.c +++ b/hw/xwin/winengine.c @@ -34,13 +34,17 @@ #include "win.h" #include "winmsg.h" +/* + * Global variables for function pointers into + * dynamically loaded libraries + */ +FARPROC g_fpDirectDrawCreate = NULL; +FARPROC g_fpDirectDrawCreateClipper = NULL; /* - * External global variables - */ - -extern const GUID _IID_IDirectDraw4; - + module handle for dynamically loaded directdraw library +*/ +static HMODULE g_hmodDirectDraw = NULL; /* * Detect engines supported by current Windows version @@ -334,3 +338,15 @@ winGetDDProcAddresses (void) return fReturn; } + +void +winReleaseDDProcAddresses(void) +{ + if (g_hmodDirectDraw != NULL) + { + FreeLibrary (g_hmodDirectDraw); + g_hmodDirectDraw = NULL; + g_fpDirectDrawCreate = NULL; + g_fpDirectDrawCreateClipper = NULL; + } +} diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index 55b0f16d4..da1712988 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -84,10 +84,6 @@ Bool g_fNativeGl = FALSE; * their function pointers */ -HMODULE g_hmodDirectDraw = NULL; -FARPROC g_fpDirectDrawCreate = NULL; -FARPROC g_fpDirectDrawCreateClipper = NULL; - HMODULE g_hmodCommonControls = NULL; FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;