make ESC quit the game instead of toggling out of/into full screen mode (fixes issue 2246),

implement proper window handling (d3d/sw) which i believe fixes a hang that occurs when a game is stopped (plz test this :)) + some minor stuff

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5030 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-02-08 09:57:52 +00:00
parent 3915f0fbca
commit 3f90bb215c
6 changed files with 46 additions and 60 deletions

View file

@ -80,11 +80,11 @@ bool Exists(const char *filename)
// Returns true if filename is a directory // Returns true if filename is a directory
bool IsDirectory(const char *filename) bool IsDirectory(const char *filename)
{ {
struct stat file_info; struct stat64 file_info;
char *copy = StripTailDirSlashes(__strdup(filename)); char *copy = StripTailDirSlashes(__strdup(filename));
int result = stat(copy, &file_info); int result = stat64(copy, &file_info);
free(copy); free(copy);
if (result < 0) { if (result < 0) {

View file

@ -30,7 +30,7 @@ SConfig::SConfig()
{ {
// Make sure we have log manager // Make sure we have log manager
LoadSettings(); LoadSettings();
//Mkae sure we load settings //Make sure we load settings
LoadSettingsHLE(); LoadSettingsHLE();
} }

View file

@ -148,7 +148,7 @@ CPanel::CPanel(
// Stop // Stop
case WM_USER_STOP: case WM_USER_STOP:
main_frame->DoStop(); main_frame->DoStop();
return 0; break;
case WM_USER_CREATE: case WM_USER_CREATE:
// We don't have a local setting for bRenderToMain but we can detect it this way instead // We don't have a local setting for bRenderToMain but we can detect it this way instead
@ -157,7 +157,7 @@ CPanel::CPanel(
main_frame->bRenderToMain = false; main_frame->bRenderToMain = false;
else else
main_frame->bRenderToMain = true; main_frame->bRenderToMain = true;
return 0; break;
case WIIMOTE_DISCONNECT: case WIIMOTE_DISCONNECT:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
@ -183,13 +183,13 @@ CPanel::CPanel(
dlg->Destroy(); dlg->Destroy();
} }
} }
return 0;
} }
break; break;
default:
// By default let wxWidgets do what it normally does with this event
return wxPanel::MSWWindowProc(nMsg, wParam, lParam);
} }
return 0;
// By default let wxWidgets do what it normally does with this event
return wxPanel::MSWWindowProc(nMsg, wParam, lParam);
} }
#endif #endif
@ -730,13 +730,17 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
void CFrame::OnKeyDown(wxKeyEvent& event) void CFrame::OnKeyDown(wxKeyEvent& event)
{ {
// Toggle fullscreen // Toggle fullscreen
if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == WXK_RETURN && event.GetModifiers() == wxMOD_ALT)) if (event.GetKeyCode() == WXK_RETURN && event.GetModifiers() == wxMOD_ALT)
{ {
DoFullscreen(!IsFullScreen()); DoFullscreen(!IsFullScreen());
// We do that to avoid the event to be double processed (which would cause the window to be stuck in fullscreen) // We do that to avoid the event to be double processed (which would cause the window to be stuck in fullscreen)
event.StopPropagation(); event.StopPropagation();
} }
else if(event.GetKeyCode() == WXK_ESCAPE)
{
main_frame->DoStop();
}
// event.Skip() allows the event to propagate to the gamelist for example // event.Skip() allows the event to propagate to the gamelist for example
else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this)) else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this))
event.Skip(); event.Skip();
@ -927,7 +931,10 @@ void CFrame::DoFullscreen(bool bF)
} }
#ifdef _WIN32 #ifdef _WIN32
else // Post the message to the separate rendering window which will then handle it. else // Post the message to the separate rendering window which will then handle it.
{
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0); PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0);
BringWindowToTop((HWND)Core::GetWindowHandle());
}
#endif #endif
} }

View file

@ -80,7 +80,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
hdc = BeginPaint(hWnd, &ps); hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
return 0; break;
case WM_ENTERSIZEMOVE: case WM_ENTERSIZEMOVE:
s_sizing = true; s_sizing = true;
@ -94,22 +94,16 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case VK_ESCAPE: case VK_ESCAPE:
ToggleFullscreen(hWnd); if(!g_Config.RenderToMainframe)
return 0;
/*
if (g_Config.bFullscreen)
{
// Pressing Esc switches to Windowed in Fullscreen mode
ToggleFullscreen(hWnd);
return 0;
}
else
{ {
if (g_Config.bFullscreen)
{
// Pressing Esc switches to Windowed mode from Fullscreen mode
ToggleFullscreen(hWnd);
}
// And stops the emulation when already in Windowed mode // And stops the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
return 0;
} }
*/
break; break;
case '3': // OSD keys case '3': // OSD keys
case '4': case '4':
@ -125,18 +119,17 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
break; break;
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
switch( LOWORD( wParam )) switch (LOWORD( wParam ))
{ {
case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed
if (m_hParent == NULL && !g_Config.RenderToMainframe) if (m_hParent == NULL && !g_Config.RenderToMainframe)
{ {
ToggleFullscreen(hWnd); ToggleFullscreen(hWnd);
return 0;
} }
break; break;
case VK_F5: case VK_F6: case VK_F7: case VK_F8: case VK_F5: case VK_F6: case VK_F7: case VK_F8:
PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam);
return 0; break;
} }
break; break;
@ -146,7 +139,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
PostMessage(GetParentWnd(), iMsg, wParam, lParam); PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break; break;
case WM_CLOSE: case WM_CLOSE:
// When the user closes the window, we post an event to the main window to call Stop() // When the user closes the window, we post an event to the main window to call Stop()
@ -154,7 +147,6 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
if (m_hParent == NULL) if (m_hParent == NULL)
{ {
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
return 0;
} }
break; break;
@ -178,12 +170,13 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{ {
case SC_SCREENSAVE: case SC_SCREENSAVE:
case SC_MONITORPOWER: case SC_MONITORPOWER:
return 0; break;
} }
break; break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
} }
return 0;
return DefWindowProc(hWnd, iMsg, wParam, lParam);
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------

View file

@ -243,25 +243,16 @@ void OnKeyDown(WPARAM wParam)
switch (LOWORD( wParam )) switch (LOWORD( wParam ))
{ {
case VK_ESCAPE: case VK_ESCAPE:
ToggleFullscreen(m_hWnd);
return;
/*
if (!g_Config.RenderToMainframe) if (!g_Config.RenderToMainframe)
{ {
if (g_Config.bFullscreen) if (g_Config.bFullscreen)
{ {
// Pressing Esc switches to Windowed in Fullscreen mode // Pressing Esc switches to Windowed mode from Fullscreen mode
ToggleFullscreen(m_hWnd); ToggleFullscreen(m_hWnd);
return;
}
else
{
// Pressing Esc stops the emulation
SendMessage( m_hWnd, WM_CLOSE, 0, 0 );
return;
} }
// then stops the emulation if already Windowed
SendMessage(m_hWnd, WM_CLOSE, 0, 0);
} }
*/
break; break;
case '3': // OSD keys case '3': // OSD keys
case '4': case '4':

View file

@ -23,7 +23,7 @@
#include <wx/dialog.h> #include <wx/dialog.h>
#include <wx/aboutdlg.h> #include <wx/aboutdlg.h>
#include "../VideoConfig.h" #include "VideoConfig.h"
#include "main.h" #include "main.h"
#include "Win32.h" #include "Win32.h"
@ -135,7 +135,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
case WM_PAINT: case WM_PAINT:
hdc = BeginPaint( hWnd, &ps ); hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps ); EndPaint( hWnd, &ps );
return 0; break;
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
switch( LOWORD( wParam )) switch( LOWORD( wParam ))
@ -145,31 +145,25 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
if (m_hParent == NULL && !g_Config.renderToMainframe) if (m_hParent == NULL && !g_Config.renderToMainframe)
{ {
ToggleFullscreen(hWnd); ToggleFullscreen(hWnd);
return 0;
} }
break; break;
case VK_F5: case VK_F6: case VK_F7: case VK_F8: case VK_F5: case VK_F6: case VK_F7: case VK_F8:
PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam);
return 0; break;
} }
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
switch( LOWORD( wParam )) switch (LOWORD( wParam ))
{ {
case VK_ESCAPE: case VK_ESCAPE:
if (g_Config.bFullscreen) if (g_Config.bFullscreen)
{ {
// Pressing Esc switch to Windowed in Fullscreen mode // Pressing Esc switches to Windowed mode from Fullscreen mode
ToggleFullscreen(hWnd); ToggleFullscreen(hWnd);
return 0;
}
else if (!g_Config.renderToMainframe)
{
// And stops the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
return 0;
} }
// And stops the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
break; break;
} }
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0); g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
@ -214,8 +208,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{ {
// Simple hack to easily exit without stopping. Hope to fix the stopping errors soon. // Simple hack to easily exit without stopping. Hope to fix the stopping errors soon.
ExitProcess(0); ExitProcess(0);
return 0;
} }
break;
case WM_DESTROY: case WM_DESTROY:
//Shutdown(); //Shutdown();
@ -228,12 +222,13 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{ {
case SC_SCREENSAVE: case SC_SCREENSAVE:
case SC_MONITORPOWER: case SC_MONITORPOWER:
return 0; break;
} }
break; break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
} }
return 0;
return DefWindowProc(hWnd, iMsg, wParam, lParam);
} }