reapply the changes from rev 4532 (without the resizing issues) and the changes from rev 4555 -- fixes issue 1660

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4578 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2009-11-15 07:46:43 +00:00
parent 70068a288a
commit 14c3878543
6 changed files with 61 additions and 49 deletions

View File

@ -145,11 +145,11 @@ int abc = 0;
switch(wParam) switch(wParam)
{ {
// Stop // Stop
case OPENGL_WM_USER_STOP: case WM_USER_STOP:
main_frame->DoStop(); main_frame->DoStop();
return 0; return 0;
case OPENGL_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
//PanicAlert("main call %i %i %i %i", lParam, (HWND)Core::GetWindowHandle(), MSWGetParent_((HWND)Core::GetWindowHandle()), (HWND)this->GetHWND()); //PanicAlert("main call %i %i %i %i", lParam, (HWND)Core::GetWindowHandle(), MSWGetParent_((HWND)Core::GetWindowHandle()), (HWND)this->GetHWND());
if (lParam == NULL) if (lParam == NULL)
@ -302,7 +302,7 @@ CFrame::CFrame(wxFrame* parent,
, m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL) , m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL)
, m_pStatusBar(NULL), m_GameListCtrl(NULL), m_Panel(NULL) , m_pStatusBar(NULL), m_GameListCtrl(NULL), m_Panel(NULL)
, UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false) , UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
, bRenderToMain(true), bFloatLogWindow(false), bFloatConsoleWindow(false) , bRenderToMain(false), bFloatLogWindow(false), bFloatConsoleWindow(false)
, HaveLeds(false), HaveSpeakers(false) , HaveLeds(false), HaveSpeakers(false)
, m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0) , m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0)
#if wxUSE_TIMER #if wxUSE_TIMER
@ -671,7 +671,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
#ifdef _WIN32 #ifdef _WIN32
if(event.GetKeyCode() == 'M', '3', '4', '5', '6', '7') // Send this to the video plugin WndProc if(event.GetKeyCode() == 'M', '3', '4', '5', '6', '7') // Send this to the video plugin WndProc
{ {
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, OPENGL_WM_USER_KEYDOWN, event.GetKeyCode()); PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
} }
#endif #endif

View File

@ -23,10 +23,10 @@
enum PLUGIN_COMM enum PLUGIN_COMM
{ {
// Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on // Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on
OPENGL_WM_USER_STOP = 10, WM_USER_STOP = 10,
OPENGL_WM_USER_CREATE, WM_USER_CREATE,
OPENGL_WM_USER_KEYDOWN, WM_USER_KEYDOWN,
OPENGL_VIDEO_STOP, WM_USER_VIDEO_STOP,
TOGGLE_FULLSCREEN, TOGGLE_FULLSCREEN,
VIDEO_DESTROY, // The video debugging window was destroyed VIDEO_DESTROY, // The video debugging window was destroyed
AUDIO_DESTROY, // The audio debugging window was destroyed AUDIO_DESTROY, // The audio debugging window was destroyed

View File

@ -10,6 +10,7 @@
namespace EmuWindow namespace EmuWindow
{ {
HWND m_hWnd = NULL; HWND m_hWnd = NULL;
HWND m_hMain = NULL;
HWND m_hParent = NULL; HWND m_hParent = NULL;
HINSTANCE m_hInstance = NULL; HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass; WNDCLASSEX wndClass;
@ -36,6 +37,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{ {
switch( iMsg ) switch( iMsg )
{ {
case WM_CREATE:
PostMessage( m_hMain, WM_USER, WM_USER_CREATE, g_Config.RenderToMainframe );
break;
case WM_PAINT: case WM_PAINT:
{ {
HDC hdc; HDC hdc;
@ -54,9 +58,18 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
switch (LOWORD(wParam))
{
case VK_ESCAPE:
SendMessage(m_hWnd, WM_CLOSE, 0, 0);
break;
}
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
break;
case WM_SYSKEYDOWN:
switch( LOWORD( wParam )) switch( LOWORD( wParam ))
{ {
case VK_ESCAPE: // Pressing Esc switch FullScreen/Windowed case VK_RETURN: // Pressing Esc switch FullScreen/Windowed
if (g_ActiveConfig.bFullscreen) if (g_ActiveConfig.bFullscreen)
{ {
DestroyWindow(hWnd); DestroyWindow(hWnd);
@ -118,7 +131,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
}*/ }*/
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);
break; break;
/* Post thes mouse events to the main window, it's nessesary because in difference to the /* Post thes mouse events to the main window, it's nessesary because in difference to the
@ -130,9 +143,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
break; break;
case WM_CLOSE: case WM_CLOSE:
//Fifo_ExitLoopNonBlocking(); Fifo_ExitLoopNonBlocking();
//Shutdown(); //Shutdown();
PostMessage( m_hParent, WM_USER, OPENGL_WM_USER_STOP, 0 ); PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
// 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; return 0;
@ -187,17 +200,19 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
if (g_Config.RenderToMainframe) if (g_Config.RenderToMainframe)
{ {
m_hParent = parent; m_hParent = m_hMain = parent;
m_hWnd = CreateWindowEx(0, m_szClassName, title, WS_CHILD, m_hWnd = CreateWindowEx(0, m_szClassName, title, WS_CHILD,
0, 0, width, height, 0, 0, width, height,
m_hParent, NULL, hInstance, NULL); m_hParent, NULL, hInstance, NULL);
if( !g_Config.bFullscreen ) /*if( !g_Config.bFullscreen )
SetWindowPos( GetParent(m_hParent), NULL, 0, 0, width, height, SWP_NOMOVE|SWP_NOZORDER ); SetWindowPos( GetParent(m_hParent), NULL, 0, 0, width, height, SWP_NOMOVE|SWP_NOZORDER );*/
} }
else else
{ {
m_hMain = parent;
DWORD style = g_Config.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW; DWORD style = g_Config.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW;
RECT rc = {0, 0, width, height}; RECT rc = {0, 0, width, height};
@ -213,7 +228,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
m_hWnd = CreateWindowEx(0, m_szClassName, title, style, m_hWnd = CreateWindowEx(0, m_szClassName, title, style,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
NULL, NULL, hInstance, NULL ); NULL, NULL, hInstance, NULL);
} }
return m_hWnd; return m_hWnd;

View File

@ -192,10 +192,10 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
#elif defined(_WIN32) #elif defined(_WIN32)
// Create rendering window in Windows // Create rendering window in Windows
// Create a separate window // Create a separate window
if (!g_Config.RenderToMainframe || g_VideoInitialize.pWindowHandle == NULL) /*if (!g_Config.RenderToMainframe || g_VideoInitialize.pWindowHandle == NULL)
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, _T("Please wait...")); g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, _T("Please wait..."));
// Create a child window // Create a child window
else else*/
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait...")); g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait..."));
// Show the window // Show the window

View File

@ -146,7 +146,8 @@ namespace EmuWindow
{ {
HWND m_hWnd = NULL; // The new window that is created here HWND m_hWnd = NULL; // The new window that is created here
HWND m_hParent = NULL; // The main CPanel HWND m_hParent = NULL;
HWND m_hMain = NULL; // The main CPanel
HINSTANCE m_hInstance = NULL; HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass; WNDCLASSEX wndClass;
@ -243,16 +244,10 @@ void OnKeyDown(WPARAM wParam)
switch (LOWORD( wParam )) switch (LOWORD( wParam ))
{ {
case VK_ESCAPE: case VK_ESCAPE:
if (g_Config.bFullscreen && !g_Config.RenderToMainframe) if (!g_Config.RenderToMainframe)
{ {
// Pressing Esc switch to Windowed in Fullscreen mode // Pressing Esc stops the emulation
ToggleFullscreen(m_hWnd); SendMessage( m_hWnd, WM_CLOSE, 0, 0 );
return;
}
else if (!g_Config.RenderToMainframe)
{
// And stops the emulation when already in Windowed mode
PostMessage(m_hParent, WM_USER, OPENGL_WM_USER_STOP, 0);
} }
break; break;
case '3': // OSD keys case '3': // OSD keys
@ -275,7 +270,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
switch (iMsg) switch (iMsg)
{ {
case WM_CREATE: case WM_CREATE:
PostMessage((HWND)g_VideoInitialize.pWindowHandle, WM_USER, OPENGL_WM_USER_CREATE, (int)m_hParent); PostMessage(m_hMain, WM_USER, WM_USER_CREATE, g_Config.RenderToMainframe);
break; break;
case WM_PAINT: case WM_PAINT:
@ -325,7 +320,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
it's nessesary for both the child window and separate rendering window because it's nessesary for both the child window and separate rendering window because
moves over the rendering window do not reach the main program then. */ moves over the rendering window do not reach the main program then. */
if (GetParentWnd() == NULL) { // Separate rendering window if (GetParentWnd() == NULL) { // Separate rendering window
PostMessage(m_hParent, iMsg, wParam, -1); PostMessage(m_hMain, iMsg, wParam, -1);
SetCursor(hCursor); SetCursor(hCursor);
} }
else else
@ -336,14 +331,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
only let it pass through Dolphin > Frame.cpp to determine if it should be on or off only let it pass through Dolphin > Frame.cpp to determine if it should be on or off
and coordinate it with the other settings if nessesary */ and coordinate it with the other settings if nessesary */
case WM_USER: case WM_USER:
if (wParam == OPENGL_WM_USER_STOP) if (wParam == WM_USER_STOP)
{ {
if (lParam) if (lParam)
SetCursor(hCursor); SetCursor(hCursor);
else else
SetCursor(hCursorBlank); SetCursor(hCursorBlank);
} }
if (wParam == OPENGL_WM_USER_KEYDOWN) if (wParam == WM_USER_KEYDOWN)
OnKeyDown(lParam); OnKeyDown(lParam);
if (wParam == TOGGLE_FULLSCREEN) if (wParam == TOGGLE_FULLSCREEN)
ToggleFullscreen(m_hWnd); ToggleFullscreen(m_hWnd);
@ -353,8 +348,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_CLOSE: case WM_CLOSE:
if (m_hParent == NULL) if (m_hParent == NULL)
{ {
// Simple hack to easily exit without stopping. Hope to fix the stopping errors soon. // Take it out of fullscreen and stop the game
ExitProcess(0); if( g_Config.bFullscreen )
ToggleFullscreen(m_hParent);
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
return 0; return 0;
} }
@ -405,16 +402,16 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
CreateCursors(m_hInstance); CreateCursors(m_hInstance);
// Create child window // Create child window
if (parent) if (g_Config.RenderToMainframe)
{ {
m_hParent = parent; m_hParent = m_hMain = parent;
m_hWnd = CreateWindow(m_szClassName, title, m_hWnd = CreateWindowEx(0, m_szClassName, title, WS_CHILD,
WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
parent, NULL, hInstance, NULL); parent, NULL, hInstance, NULL);
ShowWindow(m_hWnd, SW_SHOWMAXIMIZED); /*if( !g_Config.bFullscreen )
SetWindowPos( GetParent(m_hParent), NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER );*/
} }
// Create new separate window // Create new separate window
@ -424,6 +421,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
// render to main, stop, then render to separate window, as the GUI will still // render to main, stop, then render to separate window, as the GUI will still
// think we're rendering to main because m_hParent will still contain the old HWND... // think we're rendering to main because m_hParent will still contain the old HWND...
m_hParent = NULL; m_hParent = NULL;
m_hMain = parent;
DWORD style = g_Config.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW; DWORD style = g_Config.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW;
@ -438,13 +436,9 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
rc.top = (1024 - h)/2; rc.top = (1024 - h)/2;
rc.bottom = rc.top + h; rc.bottom = rc.top + h;
m_hWnd = CreateWindow(m_szClassName, title, m_hWnd = CreateWindowEx(0, m_szClassName, title, style,
style,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
parent, NULL, hInstance, NULL ); NULL, NULL, hInstance, NULL);
g_winstyle = GetWindowLong( m_hWnd, GWL_STYLE );
g_winstyle &= ~WS_MAXIMIZE & ~WS_MINIMIZE; // remove minimize/maximize style
} }
return m_hWnd; return m_hWnd;
@ -539,7 +533,9 @@ void Show()
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title) HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
{ {
return OpenWindow(hParent, hInstance, 640, 480, title); int width=640, height=480;
sscanf( g_Config.bFullscreen ? g_Config.cFSResolution : g_Config.cInternalRes, "%dx%d", &width, &height );
return OpenWindow(hParent, hInstance, width, height, title);
} }
void Close() void Close()
@ -554,7 +550,8 @@ void Close()
void SetSize(int width, int height) void SetSize(int width, int height)
{ {
RECT rc = {0, 0, width, height}; RECT rc = {0, 0, width, height};
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false); DWORD dwStyle = GetWindowLong(m_hWnd, GWL_STYLE);
AdjustWindowRect(&rc, dwStyle, false);
int w = rc.right - rc.left; int w = rc.right - rc.left;
int h = rc.bottom - rc.top; int h = rc.bottom - rc.top;

View File

@ -129,7 +129,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
switch( iMsg ) switch( iMsg )
{ {
case WM_CREATE: case WM_CREATE:
PostMessage(m_hMain, WM_USER, OPENGL_WM_USER_CREATE, (int)m_hParent); PostMessage(m_hMain, WM_USER, WM_USER_CREATE, (int)m_hParent);
break; break;
case WM_PAINT: case WM_PAINT:
@ -164,7 +164,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
else if (!g_Config.renderToMainframe) else if (!g_Config.renderToMainframe)
{ {
// And stops the emulation when already in Windowed mode // And stops the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, OPENGL_WM_USER_STOP, 0); PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
} }
break; break;
} }