From: Mark Harmstone Subject: [PATCH 3/5] user32: Call uxtheme theming hook. Message-Id: <55109FB3.6040504@burntcomma.com> Date: Mon, 23 Mar 2015 23:20:19 +0000 --- dlls/user32/driver.c | 39 ++++++++++++++++++++++++++++++++++++++- dlls/user32/user_private.h | 13 +++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index e0bc38c..01a7a50 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -38,6 +38,8 @@ static USER_DRIVER null_driver, lazy_load_driver; const USER_DRIVER *USER_Driver = &lazy_load_driver; static char driver_load_error[80]; +THEMINGHOOKS theming_hooks; + static HMODULE load_desktop_driver( HWND hwnd ) { static const WCHAR display_device_guid_propW[] = { @@ -85,6 +87,37 @@ static HMODULE load_desktop_driver( HWND hwnd ) return ret; } +static void theming_hooks_init(void) +{ + static WCHAR theming_dll[] = {'u','x','t','h','e','m','e','.','d','l','l',0}; + static char theming_func[] = "WINE_ThemeInitApiHook"; + + memset(&theming_hooks, 0, sizeof(theming_hooks)); + + theming_hooks.module = LoadLibraryW(theming_dll); + if (!theming_hooks.module) { + WARN("Could not load module %s\n", debugstr_w(theming_dll)); + return; + } + + theming_hooks.func = (WINETHEMINGHOOKPROC)GetProcAddress(theming_hooks.module, theming_func); + if (!theming_hooks.func) { + WARN("Could not find function %s\n", theming_func); + return; + } + + theming_hooks.func(FALSE, &theming_hooks.hooks); +} + +static void theming_hooks_free(void) +{ + if (theming_hooks.func) + theming_hooks.func(TRUE, &theming_hooks.hooks); + + if (theming_hooks.module) + FreeLibrary(theming_hooks.module); +} + /* load the graphics driver */ static const USER_DRIVER *load_driver(void) { @@ -169,6 +202,8 @@ static const USER_DRIVER *load_driver(void) __wine_set_display_driver( graphics_driver ); register_builtin_classes(); + theming_hooks_init(); + return driver; } @@ -178,8 +213,10 @@ void USER_unload_driver(void) USER_DRIVER *prev; /* make sure we don't try to call the driver after it has been detached */ prev = InterlockedExchangePointer( (void **)&USER_Driver, &null_driver ); - if (prev != &lazy_load_driver && prev != &null_driver) + if (prev != &lazy_load_driver && prev != &null_driver) { + theming_hooks_free(); HeapFree( GetProcessHeap(), 0, prev ); + } } diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index adf3f7d..ee29410 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -313,6 +313,19 @@ typedef struct extern BOOL get_icon_size( HICON handle, SIZE *size ) DECLSPEC_HIDDEN; +/* theming hooks */ + +typedef BOOL(CALLBACK *WINETHEMINGHOOKPROC)(BOOL, WINEUSERAPIHOOK*); + +typedef struct +{ + HMODULE module; + WINETHEMINGHOOKPROC func; + WINEUSERAPIHOOK hooks; +} THEMINGHOOKS; + +extern THEMINGHOOKS theming_hooks; + /* Mingw's assert() imports MessageBoxA and gets confused by user32 exporting it */ #ifdef __MINGW32__ #undef assert