diff --git a/Makefile.common b/Makefile.common index dc0e7abdd3..8defec2bfa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -712,7 +712,6 @@ ifneq ($(findstring Win32,$(OS)),) OBJ += media/rarch.o \ input/drivers_keyboard/keyboard_event_win32.o \ gfx/common/win32_common.o \ - gfx/drivers_wm/win32_dwm_common.o \ frontend/drivers/platform_win32.o endif diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 380542f2fc..e227295fcf 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -26,6 +26,76 @@ #include #include +#if defined(_WIN32) && !defined(_XBOX) +/* We only load this library once, so we let it be + * unloaded at application shutdown, since unloading + * it early seems to cause issues on some systems. + */ + +static dylib_t dwmlib; + +static bool dwm_composition_disabled; + +static void gfx_dwm_shutdown(void) +{ + if (dwmlib) + dylib_close(dwmlib); + dwmlib = NULL; +} + +static bool gfx_init_dwm(void) +{ + static bool inited = false; + + if (inited) + return true; + + dwmlib = dylib_load("dwmapi.dll"); + if (!dwmlib) + { + RARCH_LOG("Did not find dwmapi.dll.\n"); + return false; + } + atexit(gfx_dwm_shutdown); + + HRESULT (WINAPI *mmcss)(BOOL) = + (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); + if (mmcss) + { + RARCH_LOG("Setting multimedia scheduling for DWM.\n"); + mmcss(TRUE); + } + + inited = true; + return true; +} + +static void gfx_set_dwm(void) +{ + HRESULT ret; + settings_t *settings = config_get_ptr(); + + if (!gfx_init_dwm()) + return; + + if (settings->video.disable_composition == dwm_composition_disabled) + return; + + HRESULT (WINAPI *composition_enable)(UINT) = + (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); + if (!composition_enable) + { + RARCH_ERR("Did not find DwmEnableComposition ...\n"); + return; + } + + ret = composition_enable(!settings->video.disable_composition); + if (FAILED(ret)) + RARCH_ERR("Failed to set composition state ...\n"); + dwm_composition_disabled = settings->video.disable_composition; +} +#endif + static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, int *minor) { uint32_t version = GetVersion(); @@ -50,6 +120,8 @@ static void frontend_win32_init(void *data) setDPIAwareProc(); } } + + gfx_set_dwm(); } const frontend_ctx_driver_t frontend_ctx_win32 = { diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 76a9e76f2c..23e1530104 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -446,9 +446,6 @@ static bool d3d_construct(d3d_video_t *d3d, const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); d3d->should_resize = false; -#ifndef _XBOX - gfx_set_dwm(); -#endif #if defined(HAVE_MENU) if (d3d->menu) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 22a45d7a39..c081fb40e8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2230,9 +2230,6 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); driver_t *driver = driver_get_ptr(); -#ifdef _WIN32 - gfx_set_dwm(); -#endif gl = (gl_t*)calloc(1, sizeof(gl_t)); if (!gl) diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 5472725e3d..7fd168f4c4 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -376,10 +376,6 @@ static void *sdl2_gfx_init(const video_info_t *video, const input_driver_t **inp unsigned flags; settings_t *settings = config_get_ptr(); -#ifdef _WIN32 - gfx_set_dwm(); -#endif - #ifdef HAVE_X11 XInitThreads(); #endif diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 16e42a2c50..2522048803 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -250,10 +250,6 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu sdl_video_t *vid = NULL; settings_t *settings = config_get_ptr(); -#ifdef _WIN32 - gfx_set_dwm(); -#endif - #ifdef HAVE_X11 XInitThreads(); #endif diff --git a/gfx/drivers_wm/win32_dwm_common.c b/gfx/drivers_wm/win32_dwm_common.c deleted file mode 100644 index 4246a7b85d..0000000000 --- a/gfx/drivers_wm/win32_dwm_common.c +++ /dev/null @@ -1,90 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#include "win32_dwm_common.h" -#include "../../general.h" - -#if defined(_WIN32) && !defined(_XBOX) -#include -#include "../../dynamic.h" - -/* We only load this library once, so we let it be - * unloaded at application shutdown, since unloading - * it early seems to cause issues on some systems. - */ - -static dylib_t dwmlib; -static bool dwm_composition_disabled; - -static void gfx_dwm_shutdown(void) -{ - if (dwmlib) - dylib_close(dwmlib); - dwmlib = NULL; -} - -static bool gfx_init_dwm(void) -{ - static bool inited = false; - - if (inited) - return true; - - dwmlib = dylib_load("dwmapi.dll"); - if (!dwmlib) - { - RARCH_LOG("Did not find dwmapi.dll.\n"); - return false; - } - atexit(gfx_dwm_shutdown); - - HRESULT (WINAPI *mmcss)(BOOL) = - (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); - if (mmcss) - { - RARCH_LOG("Setting multimedia scheduling for DWM.\n"); - mmcss(TRUE); - } - - inited = true; - return true; -} - -void gfx_set_dwm(void) -{ - HRESULT ret; - settings_t *settings = config_get_ptr(); - - if (!gfx_init_dwm()) - return; - - if (settings->video.disable_composition == dwm_composition_disabled) - return; - - HRESULT (WINAPI *composition_enable)(UINT) = - (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); - if (!composition_enable) - { - RARCH_ERR("Did not find DwmEnableComposition ...\n"); - return; - } - - ret = composition_enable(!settings->video.disable_composition); - if (FAILED(ret)) - RARCH_ERR("Failed to set composition state ...\n"); - dwm_composition_disabled = settings->video.disable_composition; -} -#endif diff --git a/gfx/drivers_wm/win32_dwm_common.h b/gfx/drivers_wm/win32_dwm_common.h deleted file mode 100644 index 3b3c713ceb..0000000000 --- a/gfx/drivers_wm/win32_dwm_common.h +++ /dev/null @@ -1,36 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef __WIN32_DWM_COMMON_H -#define __WIN32_DWM_COMMON_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#ifdef _WIN32 -void gfx_set_dwm(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/griffin/griffin.c b/griffin/griffin.c index d38d511451..66e40b7be1 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -88,11 +88,6 @@ UI COMMON CONTEXT ============================================================ */ #if defined(_WIN32) #include "../gfx/common/win32_common.c" - -#ifndef _XBOX -#include "../gfx/drivers_wm/win32_dwm_common.c" -#endif - #endif /*============================================================