mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
Move gfx_set_dwm call to platform_win32.c
This commit is contained in:
parent
f91f543f74
commit
18801c8449
@ -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
|
||||
|
||||
|
@ -26,6 +26,76 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#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 = {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "win32_dwm_common.h"
|
||||
#include "../../general.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#include <windows.h>
|
||||
#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
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __WIN32_DWM_COMMON_H
|
||||
#define __WIN32_DWM_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
void gfx_set_dwm(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -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
|
||||
|
||||
/*============================================================
|
||||
|
Loading…
x
Reference in New Issue
Block a user