From 3f90bb215ce88634cb8772d93dd03c6129fdef3b Mon Sep 17 00:00:00 2001 From: luisr142004 Date: Mon, 8 Feb 2010 09:57:52 +0000 Subject: [PATCH] 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 --- Source/Core/Common/Src/FileUtil.cpp | 4 +-- Source/Core/Core/Src/ConfigManager.cpp | 2 +- Source/Core/DolphinWX/Src/Frame.cpp | 21 +++++++---- .../Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp | 35 ++++++++----------- .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 15 ++------ .../Plugin_VideoSoftware/Src/Win32.cpp | 29 +++++++-------- 6 files changed, 46 insertions(+), 60 deletions(-) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 34c93d82cf..6ddd6cdee7 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -80,11 +80,11 @@ bool Exists(const char *filename) // Returns true if filename is a directory bool IsDirectory(const char *filename) { - struct stat file_info; + struct stat64 file_info; char *copy = StripTailDirSlashes(__strdup(filename)); - int result = stat(copy, &file_info); + int result = stat64(copy, &file_info); free(copy); if (result < 0) { diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 60de785186..54477a0f62 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -30,7 +30,7 @@ SConfig::SConfig() { // Make sure we have log manager LoadSettings(); - //Mkae sure we load settings + //Make sure we load settings LoadSettingsHLE(); } diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 84cba281e3..e8f478b794 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -148,7 +148,7 @@ CPanel::CPanel( // Stop case WM_USER_STOP: main_frame->DoStop(); - return 0; + break; case WM_USER_CREATE: // 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; else main_frame->bRenderToMain = true; - return 0; + break; case WIIMOTE_DISCONNECT: if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) @@ -183,13 +183,13 @@ CPanel::CPanel( dlg->Destroy(); } } - return 0; } break; + default: + // By default let wxWidgets do what it normally does with this event + return wxPanel::MSWWindowProc(nMsg, wParam, lParam); } - - // By default let wxWidgets do what it normally does with this event - return wxPanel::MSWWindowProc(nMsg, wParam, lParam); + return 0; } #endif @@ -730,13 +730,17 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event)) void CFrame::OnKeyDown(wxKeyEvent& event) { // 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()); // We do that to avoid the event to be double processed (which would cause the window to be stuck in fullscreen) event.StopPropagation(); } + else if(event.GetKeyCode() == WXK_ESCAPE) + { + main_frame->DoStop(); + } // event.Skip() allows the event to propagate to the gamelist for example else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this)) event.Skip(); @@ -927,7 +931,10 @@ void CFrame::DoFullscreen(bool bF) } #ifdef _WIN32 else // Post the message to the separate rendering window which will then handle it. + { PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0); + BringWindowToTop((HWND)Core::GetWindowHandle()); + } #endif } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp index 043f1e3ee4..1fc63db440 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp @@ -80,7 +80,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); } - return 0; + break; case WM_ENTERSIZEMOVE: s_sizing = true; @@ -94,22 +94,16 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) switch (LOWORD(wParam)) { case VK_ESCAPE: - ToggleFullscreen(hWnd); - return 0; -/* - if (g_Config.bFullscreen) - { - // Pressing Esc switches to Windowed in Fullscreen mode - ToggleFullscreen(hWnd); - return 0; - } - else + if(!g_Config.RenderToMainframe) { + if (g_Config.bFullscreen) + { + // Pressing Esc switches to Windowed mode from Fullscreen mode + ToggleFullscreen(hWnd); + } // And stops the emulation when already in Windowed mode PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); - return 0; } -*/ break; case '3': // OSD keys case '4': @@ -125,18 +119,17 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) break; case WM_SYSKEYDOWN: - switch( LOWORD( wParam )) + switch (LOWORD( wParam )) { case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed if (m_hParent == NULL && !g_Config.RenderToMainframe) { ToggleFullscreen(hWnd); - return 0; } break; case VK_F5: case VK_F6: case VK_F7: case VK_F8: PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); - return 0; + break; } break; @@ -146,7 +139,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: PostMessage(GetParentWnd(), iMsg, wParam, lParam); - break; + break; case WM_CLOSE: // 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) { PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); - return 0; } break; @@ -178,12 +170,13 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) { case SC_SCREENSAVE: case SC_MONITORPOWER: - return 0; + break; } break; + default: + return DefWindowProc(hWnd, iMsg, wParam, lParam); } - - return DefWindowProc(hWnd, iMsg, wParam, lParam); + return 0; } // --------------------------------------------------------------------- diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index e1ba4d9d81..58e527e0f8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -243,25 +243,16 @@ void OnKeyDown(WPARAM wParam) switch (LOWORD( wParam )) { case VK_ESCAPE: - ToggleFullscreen(m_hWnd); - return; -/* if (!g_Config.RenderToMainframe) { if (g_Config.bFullscreen) { - // Pressing Esc switches to Windowed in Fullscreen mode + // Pressing Esc switches to Windowed mode from Fullscreen mode 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; case '3': // OSD keys case '4': diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp index 6c9ab4ac20..5b374f8ca1 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp @@ -23,7 +23,7 @@ #include #include -#include "../VideoConfig.h" +#include "VideoConfig.h" #include "main.h" #include "Win32.h" @@ -135,7 +135,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) case WM_PAINT: hdc = BeginPaint( hWnd, &ps ); EndPaint( hWnd, &ps ); - return 0; + break; case WM_SYSKEYDOWN: 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) { ToggleFullscreen(hWnd); - return 0; } break; case VK_F5: case VK_F6: case VK_F7: case VK_F8: PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); - return 0; + break; } break; case WM_KEYDOWN: - switch( LOWORD( wParam )) + switch (LOWORD( wParam )) { case VK_ESCAPE: if (g_Config.bFullscreen) { - // Pressing Esc switch to Windowed in Fullscreen mode + // Pressing Esc switches to Windowed mode from Fullscreen mode 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; } 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. ExitProcess(0); - return 0; } + break; case WM_DESTROY: //Shutdown(); @@ -228,12 +222,13 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) { case SC_SCREENSAVE: case SC_MONITORPOWER: - return 0; + break; } break; + default: + return DefWindowProc(hWnd, iMsg, wParam, lParam); } - - return DefWindowProc(hWnd, iMsg, wParam, lParam); + return 0; }