mirror of https://github.com/PCSX2/pcsx2.git
Added preliminary screensaver disable feature. Cleaned up Vista/Win7 DWM code a bit. Consolidated various win32 specific code into MSWstuff.cpp
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2370 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
d36ba78392
commit
a3edb9798c
|
@ -361,6 +361,8 @@
|
|||
<Unit filename="../gui/IniInterface.h" />
|
||||
<Unit filename="../gui/IsoDropTarget.cpp" />
|
||||
<Unit filename="../gui/IsoDropTarget.h" />
|
||||
<Unit filename="../gui/MSWstuff.cpp" />
|
||||
<Unit filename="../gui/MSWstuff.h" />
|
||||
<Unit filename="../gui/MainFrame.cpp" />
|
||||
<Unit filename="../gui/MainFrame.h" />
|
||||
<Unit filename="../gui/MainMenuClicks.cpp" />
|
||||
|
|
|
@ -548,6 +548,7 @@ AppConfig::GSWindowOptions::GSWindowOptions()
|
|||
DefaultToFullscreen = false;
|
||||
AlwaysHideMouse = false;
|
||||
DisableResizeBorders = false;
|
||||
DisableScreenSaver = true;
|
||||
|
||||
AspectRatio = AspectRatio_4_3;
|
||||
|
||||
|
@ -591,6 +592,7 @@ void AppConfig::GSWindowOptions::LoadSave( IniInterface& ini )
|
|||
IniEntry( DefaultToFullscreen );
|
||||
IniEntry( AlwaysHideMouse );
|
||||
IniEntry( DisableResizeBorders );
|
||||
IniEntry( DisableScreenSaver );
|
||||
|
||||
IniEntry( WindowSize );
|
||||
IniEntry( WindowPos );
|
||||
|
|
|
@ -127,6 +127,7 @@ public:
|
|||
bool DefaultToFullscreen;
|
||||
bool AlwaysHideMouse;
|
||||
bool DisableResizeBorders;
|
||||
bool DisableScreenSaver;
|
||||
|
||||
AspectRatioType AspectRatio;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "IniInterface.h"
|
||||
#include "MainFrame.h"
|
||||
#include "ConsoleLogger.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include "DebugTools/Debug.h"
|
||||
#include "Dialogs/ModalPopups.h"
|
||||
|
||||
|
@ -347,8 +349,7 @@ bool Pcsx2App::OnInit()
|
|||
AppApplySettings();
|
||||
|
||||
#ifdef __WXMSW__
|
||||
extern void SetupDwmStuff(WXHWND hMainWindow);
|
||||
SetupDwmStuff(m_MainFrame->GetHWND());
|
||||
pxDwm_Load();
|
||||
#endif
|
||||
|
||||
m_CoreAllocs = new SysCoreAllocations();
|
||||
|
@ -481,6 +482,8 @@ void Pcsx2App::CleanupMess()
|
|||
Console.Indent().Error( ex.FormatDiagnosticMessage() );
|
||||
}
|
||||
|
||||
pxDwm_Unload();
|
||||
|
||||
// Notice: deleting the plugin manager (unloading plugins) here causes Lilypad to crash,
|
||||
// likely due to some pending message in the queue that references lilypad procs.
|
||||
// We don't need to unload plugins anyway tho -- shutdown is plenty safe enough for
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "Utilities/HashMap.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
# include <wx/msw/wrapwin.h>
|
||||
# include <wx/msw/wrapwin.h> // needed to implement the app!
|
||||
#endif
|
||||
|
||||
IMPLEMENT_APP(Pcsx2App)
|
||||
|
|
|
@ -17,15 +17,13 @@
|
|||
#include "App.h"
|
||||
#include "MainFrame.h"
|
||||
#include "ConsoleLogger.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include "Utilities/Console.h"
|
||||
#include "DebugTools/Debug.h"
|
||||
|
||||
#include <wx/textfile.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
# include <wx/msw/wrapwin.h> // needed for OutputDebugString
|
||||
#endif
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE(wxEVT_LOG_Write, -1)
|
||||
DECLARE_EVENT_TYPE(wxEVT_LOG_Newline, -1)
|
||||
|
@ -54,21 +52,7 @@ void pxLogConsole::DoLog( wxLogLevel level, const wxChar *szString, time_t t )
|
|||
{
|
||||
wxString str;
|
||||
TimeStamp( &str );
|
||||
str += szString;
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
// don't prepend debug/trace here: it goes to the
|
||||
// debug window anyhow
|
||||
str += wxT("\r\n");
|
||||
OutputDebugString(str);
|
||||
#else
|
||||
// send them to stderr
|
||||
wxFprintf(stderr, wxT("[%s] %s\n"),
|
||||
level == wxLOG_Trace ? wxT("Trace")
|
||||
: wxT("Debug"),
|
||||
str.c_str());
|
||||
fflush(stderr);
|
||||
#endif
|
||||
MSW_OutputDebugString( str + szString );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -87,15 +71,15 @@ void pxLogConsole::DoLog( wxLogLevel level, const wxChar *szString, time_t t )
|
|||
// fallthrough!
|
||||
|
||||
case wxLOG_Message:
|
||||
Console.WriteLn( wxString(L"wx > ") + szString );
|
||||
Console.WriteLn( L"[wx] %s", szString );
|
||||
break;
|
||||
|
||||
case wxLOG_Error:
|
||||
Console.Error( wxString(L"wx > ") + szString );
|
||||
Console.Error( L"[wx] %s", szString );
|
||||
break;
|
||||
|
||||
case wxLOG_Warning:
|
||||
Console.Warning( wxString(L"wx > ") + szString );
|
||||
Console.Warning( L"[wx] %s", szString );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -490,10 +474,9 @@ void ConsoleLogFrame::OnActivate( wxActivateEvent& evt )
|
|||
// Special implementation to "connect" the console log window with the main frame
|
||||
// window. When one is clicked, the other is assured to be brought to the foreground
|
||||
// with it. (wxWidgets appears to have no equivalent to this)
|
||||
#ifdef __WXMSW__
|
||||
|
||||
if( MainEmuFrame* mainframe = GetMainFramePtr() )
|
||||
SetWindowPos( (HWND)mainframe->GetHWND(), (HWND)GetHWND(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE );
|
||||
#endif
|
||||
MSW_SetWindowAfter( mainframe->GetHWND(), GetHWND() );
|
||||
|
||||
evt.Skip();
|
||||
}
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "MainFrame.h"
|
||||
#include "GS.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include "wx/utils.h"
|
||||
#include <wx/utils.h>
|
||||
|
||||
|
||||
void GSPanel::InitDefaultAccelerators()
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 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 PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "MainFrame.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
# include <wx/msw/wrapwin.h> // needed for OutputDebugString
|
||||
#endif
|
||||
|
||||
void MSW_SetWindowAfter( WXHWND hwnd, WXHWND hwndAfter )
|
||||
{
|
||||
#ifndef __WXMSW__
|
||||
SetWindowPos( (HWND)hwnd, (HWND)hwndAfter, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Writes text to the Visual Studio Output window (Microsoft Windows only).
|
||||
// On all other platforms this pipes to StdErr instead.
|
||||
void MSW_OutputDebugString( const wxString& text )
|
||||
{
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
// don't prepend debug/trace here: it goes to the
|
||||
// debug window anyhow
|
||||
OutputDebugString( text + L"\r\n" );
|
||||
#else
|
||||
// send them to stderr
|
||||
wxFprintf(stderr, L"%s\n", text.c_str());
|
||||
fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
WXLRESULT GSPanel::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case SC_SCREENSAVE:
|
||||
case SC_MONITORPOWER:
|
||||
if( m_HasFocus && g_Conf->GSWindow.DisableScreenSaver)
|
||||
{
|
||||
DevCon.WriteLn("Omg Screensaver adverted!");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return _parent::MSWWindowProc(message, wParam, lParam);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,23 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 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 PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern void MSW_SetWindowAfter( WXWidget hwnd, WXWidget hwndAfter );
|
||||
extern void MSW_OutputDebugString( const wxString& text );
|
||||
|
||||
extern void pxDwm_Load();
|
||||
extern void pxDwm_Unload();
|
||||
extern void pxDwm_SetPresentParams( WXWidget wnd );
|
|
@ -16,16 +16,13 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "MainFrame.h"
|
||||
#include "ConsoleLogger.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include "Dialogs/ModalPopups.h"
|
||||
#include "IsoDropTarget.h"
|
||||
|
||||
#include <wx/iconbndl.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
# include <wx/msw/wrapwin.h> // needed for SetWindowPos (OnActivate)
|
||||
#endif
|
||||
|
||||
#if _MSC_VER
|
||||
# include "svnrev.h"
|
||||
#endif
|
||||
|
@ -458,10 +455,8 @@ void MainEmuFrame::OnActivate( wxActivateEvent& evt )
|
|||
// Special implementation to "connect" the console log window with the main frame
|
||||
// window. When one is clicked, the other is assured to be brought to the foreground
|
||||
// with it. (wxWidgets appears to have no equivalent to this)
|
||||
#ifdef __WXMSW__
|
||||
if( ConsoleLogFrame* logframe = wxGetApp().GetProgramLog() )
|
||||
SetWindowPos( (HWND)logframe->GetHWND(), (HWND)GetHWND(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE );
|
||||
#endif
|
||||
MSW_SetWindowAfter( logframe->GetHWND(), GetHWND() );
|
||||
|
||||
evt.Skip();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
// --------------------------------------------------------------------------------------
|
||||
class GSPanel : public wxWindow
|
||||
{
|
||||
typedef wxWindow _parent;
|
||||
|
||||
protected:
|
||||
AcceleratorDictionary m_Accels;
|
||||
EventListenerBinding<int> m_Listener_SettingsApplied;
|
||||
|
@ -43,6 +45,10 @@ public:
|
|||
protected:
|
||||
static void __evt_fastcall OnSettingsApplied( void* obj, int& evt );
|
||||
|
||||
#ifdef __WXMSW__
|
||||
virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
#endif
|
||||
|
||||
void InitDefaultAccelerators();
|
||||
|
||||
void OnCloseWindow( wxCloseEvent& evt );
|
||||
|
|
|
@ -242,9 +242,12 @@ void __evt_fastcall Panels::PluginSelectorPanel::OnCorePluginStatusChanged( void
|
|||
const PluginInfo* pi = tbl_PluginInfo; do
|
||||
{
|
||||
wxComboBox& box( panel.m_ComponentBoxes->Get(pi->id) );
|
||||
int sel = box.GetSelection();
|
||||
if( sel == wxNOT_FOUND ) continue;
|
||||
|
||||
panel.m_ComponentBoxes->GetConfigButton(pi->id).Enable(
|
||||
(panel.m_FileList==NULL || panel.m_FileList->Count() == 0) ? false :
|
||||
g_Conf->FullpathMatchTest( pi->id,(*panel.m_FileList)[((int)box.GetClientData(box.GetSelection()))] )
|
||||
g_Conf->FullpathMatchTest( pi->id,(*panel.m_FileList)[((int)box.GetClientData(sel))] )
|
||||
);
|
||||
} while( ++pi, pi->shortname != NULL );
|
||||
|
||||
|
|
|
@ -1,15 +1,28 @@
|
|||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include <windows.h>
|
||||
#include "Utilities/Console.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include <wx/msw/wrapwin.h>
|
||||
#include <wx/dynlib.h>
|
||||
|
||||
#include <dwmapi.h>
|
||||
|
||||
typedef HRESULT WINAPI Fntype_DwmEnableMMCSS(DWORD enable);
|
||||
typedef HRESULT WINAPI Fntype_DwmSetPresentParameters( HWND hwnd, DWM_PRESENT_PARAMETERS *pPresentParams );
|
||||
|
||||
static wxDynamicLibrary lib_dwmapi;
|
||||
|
||||
// This could potentially reduce lag while running in Aero,
|
||||
// by telling the DWM the application requires
|
||||
// multimedia-class scheduling for smooth display.
|
||||
void SetupDwmStuff(WXHWND hMainWindow)
|
||||
void pxDwm_Load()
|
||||
{
|
||||
HRESULT (WINAPI * pDwmEnableMMCSS)(DWORD);
|
||||
wxDoNotLogInThisScope please;
|
||||
|
||||
OSVERSIONINFOEX info = {0};
|
||||
// Version test is not needed since we're using LoadLibrary. --air
|
||||
|
||||
/*OSVERSIONINFOEX info = {0};
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
info.dwMajorVersion = 6;
|
||||
|
||||
|
@ -22,27 +35,43 @@ void SetupDwmStuff(WXHWND hMainWindow)
|
|||
//info
|
||||
if(VerifyVersionInfo(&info,
|
||||
VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR,
|
||||
mask))
|
||||
{
|
||||
HMODULE hDwmapi = LoadLibrary(wxT("dwmapi.dll"));
|
||||
if(hDwmapi)
|
||||
{
|
||||
pDwmEnableMMCSS = (HRESULT (WINAPI *)(DWORD))GetProcAddress(hDwmapi,"DwmEnableMMCSS");
|
||||
if(pDwmEnableMMCSS)
|
||||
mask))*/
|
||||
|
||||
lib_dwmapi.Load( L"dwmapi.dll" );
|
||||
if( !lib_dwmapi.IsLoaded() ) return;
|
||||
|
||||
if( Fntype_DwmEnableMMCSS* pDwmEnableMMCSS = (Fntype_DwmEnableMMCSS*)lib_dwmapi.GetSymbol(L"DwmEnableMMCSS") )
|
||||
{
|
||||
Console.WriteLn( "[Dwm] Desktop Window Manager detected." );
|
||||
|
||||
if(FAILED(pDwmEnableMMCSS(TRUE)))
|
||||
{
|
||||
Console.WriteLn("Warning: DwmEnableMMCSS returned a failure code (not an error).");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLn("DwmEnableMMCSS successful.");
|
||||
}
|
||||
}
|
||||
|
||||
//DwmSetDxFrameDuration(hMainWindow,1);
|
||||
|
||||
FreeLibrary(hDwmapi);
|
||||
}
|
||||
Console.WriteLn("[Dwm] DwmEnableMMCSS returned a failure code.");
|
||||
}
|
||||
}
|
||||
|
||||
// wnd - this parameter should be the GS display panel or the top level frame that holds it (not
|
||||
// sure if it's supposed to be the actual gsPanel or the top level window/frame that the
|
||||
// panel belongs to)
|
||||
//
|
||||
void pxDwm_SetPresentParams( WXWidget wnd )
|
||||
{
|
||||
if( !lib_dwmapi.IsLoaded() ) return;
|
||||
Fntype_DwmSetPresentParameters* pDwmSetPresentParameters = (Fntype_DwmSetPresentParameters*)lib_dwmapi.GetSymbol(L"DwmSetPresentParameters");
|
||||
|
||||
if( pDwmSetPresentParameters == NULL ) return;
|
||||
|
||||
DWM_PRESENT_PARAMETERS params;
|
||||
|
||||
params.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
|
||||
params.fQueue = FALSE;
|
||||
|
||||
if(FAILED(pDwmSetPresentParameters( (HWND)wnd, ¶ms )))
|
||||
Console.WriteLn("[Dwm] DwmSetPresentParameters returned a failure code.");
|
||||
|
||||
//DwmSetDxFrameDuration(hMainWindow,1);
|
||||
}
|
||||
|
||||
void pxDwm_Unload()
|
||||
{
|
||||
lib_dwmapi.Unload();
|
||||
}
|
|
@ -1880,6 +1880,10 @@
|
|||
RelativePath="..\..\gui\MessageBoxes.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\MSWstuff.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\Plugins.cpp"
|
||||
>
|
||||
|
@ -1951,6 +1955,10 @@
|
|||
RelativePath="..\..\gui\Dialogs\ModalPopups.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\MSWstuff.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\gui\Dialogs\PickUserModeDialog.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue