1 |
|
2 |
#include "PrecompiledHeader.h" |
3 |
#include "Utilities/Console.h" |
4 |
#include "MSWstuff.h" |
5 |
|
6 |
#include <wx/msw/wrapwin.h> |
7 |
#include <wx/dynlib.h> |
8 |
|
9 |
#include <dwmapi.h> |
10 |
|
11 |
typedef HRESULT WINAPI Fntype_DwmEnableMMCSS(DWORD enable); |
12 |
typedef HRESULT WINAPI Fntype_DwmSetPresentParameters( HWND hwnd, DWM_PRESENT_PARAMETERS *pPresentParams ); |
13 |
|
14 |
static wxDynamicLibrary lib_dwmapi; |
15 |
|
16 |
// This could potentially reduce lag while running in Aero, |
17 |
// by telling the DWM the application requires |
18 |
// multimedia-class scheduling for smooth display. |
19 |
void pxDwm_Load() |
20 |
{ |
21 |
wxDoNotLogInThisScope please; |
22 |
|
23 |
// Version test is not needed since we're using LoadLibrary. --air |
24 |
|
25 |
/*OSVERSIONINFOEX info = {0}; |
26 |
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
27 |
info.dwMajorVersion = 6; |
28 |
|
29 |
DWORDLONG mask=0; |
30 |
VER_SET_CONDITION(mask,VER_MAJORVERSION, VER_GREATER_EQUAL); |
31 |
VER_SET_CONDITION(mask,VER_MINORVERSION, VER_GREATER_EQUAL); |
32 |
VER_SET_CONDITION(mask,VER_SERVICEPACKMAJOR,VER_GREATER_EQUAL); |
33 |
VER_SET_CONDITION(mask,VER_SERVICEPACKMINOR,VER_GREATER_EQUAL); |
34 |
|
35 |
//info |
36 |
if(VerifyVersionInfo(&info, |
37 |
VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR, |
38 |
mask))*/ |
39 |
|
40 |
lib_dwmapi.Load( L"dwmapi.dll" ); |
41 |
if( !lib_dwmapi.IsLoaded() ) return; |
42 |
|
43 |
if( Fntype_DwmEnableMMCSS* pDwmEnableMMCSS = (Fntype_DwmEnableMMCSS*)lib_dwmapi.GetSymbol(L"DwmEnableMMCSS") ) |
44 |
{ |
45 |
Console.WriteLn( "[Dwm] Desktop Window Manager detected." ); |
46 |
|
47 |
if(FAILED(pDwmEnableMMCSS(TRUE))) |
48 |
Console.WriteLn("[Dwm] DwmEnableMMCSS returned a failure code."); |
49 |
} |
50 |
} |
51 |
|
52 |
// wnd - this parameter should be the GS display panel or the top level frame that holds it (not |
53 |
// sure if it's supposed to be the actual gsPanel or the top level window/frame that the |
54 |
// panel belongs to) |
55 |
// |
56 |
void pxDwm_SetPresentParams( WXWidget wnd ) |
57 |
{ |
58 |
if( !lib_dwmapi.IsLoaded() ) return; |
59 |
Fntype_DwmSetPresentParameters* pDwmSetPresentParameters = (Fntype_DwmSetPresentParameters*)lib_dwmapi.GetSymbol(L"DwmSetPresentParameters"); |
60 |
|
61 |
if( pDwmSetPresentParameters == NULL ) return; |
62 |
|
63 |
DWM_PRESENT_PARAMETERS params; |
64 |
|
65 |
params.cbSize = sizeof(DWM_PRESENT_PARAMETERS); |
66 |
params.fQueue = FALSE; |
67 |
|
68 |
if(FAILED(pDwmSetPresentParameters( (HWND)wnd, ¶ms ))) |
69 |
Console.WriteLn("[Dwm] DwmSetPresentParameters returned a failure code."); |
70 |
|
71 |
//DwmSetDxFrameDuration(hMainWindow,1); |
72 |
} |
73 |
|
74 |
void pxDwm_Unload() |
75 |
{ |
76 |
lib_dwmapi.Unload(); |
77 |
} |