Revert "Windows: Get rid of that silly inner "display" window. Should be zero functional change."

Should help #6295.

This reverts commit 281ff6ce2a.

Conflicts:
	Windows/WindowsHost.cpp
	Windows/WndMainWindow.cpp
This commit is contained in:
Henrik Rydgard 2014-06-29 22:13:53 +02:00
parent 56cee3c00e
commit f127bb715b
5 changed files with 121 additions and 65 deletions

View file

@ -68,8 +68,10 @@ static BOOL PostDialogMessage(Dialog *dialog, UINT message, WPARAM wParam = 0, L
return PostMessage(dialog->GetDlgHandle(), message, wParam, lParam); return PostMessage(dialog->GetDlgHandle(), message, wParam, lParam);
} }
WindowsHost::WindowsHost(HWND mainWindow) { WindowsHost::WindowsHost(HWND mainWindow, HWND displayWindow)
window_ = mainWindow; {
mainWindow_ = mainWindow;
displayWindow_ = displayWindow;
mouseDeltaX = 0; mouseDeltaX = 0;
mouseDeltaY = 0; mouseDeltaY = 0;
@ -88,13 +90,13 @@ WindowsHost::WindowsHost(HWND mainWindow) {
bool WindowsHost::InitGL(std::string *error_message) bool WindowsHost::InitGL(std::string *error_message)
{ {
return GL_Init(window_, error_message); return GL_Init(displayWindow_, error_message);
} }
void WindowsHost::ShutdownGL() void WindowsHost::ShutdownGL()
{ {
GL_Shutdown(); GL_Shutdown();
PostMessage(window_, WM_CLOSE, 0, 0); PostMessage(mainWindow_, WM_CLOSE, 0, 0);
} }
void WindowsHost::SetWindowTitle(const char *message) void WindowsHost::SetWindowTitle(const char *message)
@ -106,7 +108,7 @@ void WindowsHost::SetWindowTitle(const char *message)
} }
MainWindow::SetWindowTitle(winTitle.c_str()); MainWindow::SetWindowTitle(winTitle.c_str());
PostMessage(window_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0); PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
} }
void WindowsHost::InitSound(PMixer *mixer) void WindowsHost::InitSound(PMixer *mixer)
@ -128,12 +130,12 @@ void WindowsHost::ShutdownSound()
void WindowsHost::UpdateUI() void WindowsHost::UpdateUI()
{ {
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0); PostMessage(mainWindow_, MainWindow::WM_USER_UPDATE_UI, 0, 0);
} }
void WindowsHost::UpdateScreen() void WindowsHost::UpdateScreen()
{ {
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_SCREEN, 0, 0); PostMessage(mainWindow_, MainWindow::WM_USER_UPDATE_SCREEN, 0, 0);
} }
void WindowsHost::UpdateMemView() void WindowsHost::UpdateMemView()
@ -191,7 +193,7 @@ void WindowsHost::PollControllers(InputState &input_state)
void WindowsHost::BootDone() void WindowsHost::BootDone()
{ {
symbolMap.SortSymbols(); symbolMap.SortSymbols();
SendMessage(MainWindow::GetHWND(), WM_USER+1, 0,0); SendMessage(mainWindow_, WM_USER + 1, 0, 0);
SetDebugMode(!g_Config.bAutoRun); SetDebugMode(!g_Config.bAutoRun);
Core_EnableStepping(!g_Config.bAutoRun); Core_EnableStepping(!g_Config.bAutoRun);
@ -335,9 +337,9 @@ bool WindowsHost::CreateDesktopShortcut(std::string argumentPath, std::string ga
void WindowsHost::GoFullscreen(bool viewFullscreen) { void WindowsHost::GoFullscreen(bool viewFullscreen) {
if (viewFullscreen) if (viewFullscreen)
MainWindow::SwitchToFullscreen(MainWindow::GetHWND()); MainWindow::SwitchToFullscreen(mainWindow_);
else else
MainWindow::SwitchToWindowed(MainWindow::GetHWND()); MainWindow::SwitchToWindowed(mainWindow_);
} }
void WindowsHost::ToggleDebugConsoleVisibility() { void WindowsHost::ToggleDebugConsoleVisibility() {

View file

@ -24,17 +24,20 @@
extern float mouseDeltaX; extern float mouseDeltaX;
extern float mouseDeltaY; extern float mouseDeltaY;
class WindowsHost : public Host { class WindowsHost : public Host
{
public: public:
WindowsHost(HWND mainWindow); WindowsHost(HWND mainWindow, HWND displayWindow);
virtual ~WindowsHost() {
~WindowsHost()
{
UpdateConsolePosition(); UpdateConsolePosition();
} }
void UpdateMemView(); void UpdateMemView();
void UpdateDisassembly(); void UpdateDisassembly();
void UpdateUI(); void UpdateUI();
virtual void UpdateScreen() override; virtual void UpdateScreen();
void SetDebugMode(bool mode); void SetDebugMode(bool mode);
bool InitGL(std::string *error_message); bool InitGL(std::string *error_message);
@ -51,18 +54,18 @@ public:
void SaveSymbolMap(); void SaveSymbolMap();
void SetWindowTitle(const char *message); void SetWindowTitle(const char *message);
virtual bool GPUDebuggingActive() override; virtual bool GPUDebuggingActive();
virtual void GPUNotifyCommand(u32 pc) override; virtual void GPUNotifyCommand(u32 pc);
virtual void GPUNotifyDisplay(u32 framebuf, u32 stride, int format) override; virtual void GPUNotifyDisplay(u32 framebuf, u32 stride, int format);
virtual void GPUNotifyDraw() override; virtual void GPUNotifyDraw();
virtual void GPUNotifyTextureAttachment(u32 addr) override; virtual void GPUNotifyTextureAttachment(u32 addr);
virtual bool GPUAllowTextureCache(u32 addr) override; virtual bool GPUAllowTextureCache(u32 addr);
virtual void ToggleDebugConsoleVisibility() override; virtual void ToggleDebugConsoleVisibility();
virtual bool CanCreateShortcut() override { return false; } // Turn on when fixed virtual bool CanCreateShortcut() {return false;} // Turn on when fixed
virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) override; virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title);
virtual void GoFullscreen(bool) override; virtual void GoFullscreen(bool);
std::shared_ptr<KeyboardDevice> keyboard; std::shared_ptr<KeyboardDevice> keyboard;
@ -70,7 +73,8 @@ private:
void SetConsolePosition(); void SetConsolePosition();
void UpdateConsolePosition(); void UpdateConsolePosition();
HWND window_; HWND displayWindow_;
HWND mainWindow_;
std::list<std::shared_ptr<InputDevice>> input; std::list<std::shared_ptr<InputDevice>> input;
}; };

View file

@ -86,8 +86,6 @@
static const int numCPUs = 1; static const int numCPUs = 1;
// These are for Unknown's modified "Very Sleepy" profiler with JIT support.
int verysleepy__useSendMessage = 1; int verysleepy__useSendMessage = 1;
const UINT WM_VERYSLEEPY_MSG = WM_APP + 0x3117; const UINT WM_VERYSLEEPY_MSG = WM_APP + 0x3117;
@ -96,7 +94,8 @@ const WPARAM VERYSLEEPY_WPARAM_SUPPORTED = 0;
// Respond TRUE to a message wit this param value after filling in the addr name. // Respond TRUE to a message wit this param value after filling in the addr name.
const WPARAM VERYSLEEPY_WPARAM_GETADDRINFO = 1; const WPARAM VERYSLEEPY_WPARAM_GETADDRINFO = 1;
struct VerySleepy_AddrInfo { struct VerySleepy_AddrInfo
{
// Always zero for now. // Always zero for now.
int flags; int flags;
// This is the pointer (always passed as 64 bits.) // This is the pointer (always passed as 64 bits.)
@ -116,8 +115,11 @@ extern InputState input_state;
#define CURSORUPDATE_INTERVAL_MS 1000 #define CURSORUPDATE_INTERVAL_MS 1000
#define CURSORUPDATE_MOVE_TIMESPAN_MS 500 #define CURSORUPDATE_MOVE_TIMESPAN_MS 500
namespace MainWindow { namespace MainWindow
{
HWND hwndMain; HWND hwndMain;
HWND hwndDisplay;
HWND hwndGameList;
TouchInputHandler touchHandler; TouchInputHandler touchHandler;
static HMENU menu; static HMENU menu;
@ -141,12 +143,17 @@ namespace MainWindow {
// Forward declarations of functions included in this code module: // Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
HWND GetHWND() { HWND GetHWND() {
return hwndMain; return hwndMain;
} }
HWND GetDisplayHWND() {
return hwndDisplay;
}
void Init(HINSTANCE hInstance) { void Init(HINSTANCE hInstance) {
#ifdef THEMES #ifdef THEMES
WTL::CTheme::IsThemingSupported(); WTL::CTheme::IsThemingSupported();
@ -166,6 +173,15 @@ namespace MainWindow {
wcex.lpszClassName = szWindowClass; wcex.lpszClassName = szWindowClass;
wcex.hIconSm = (HICON)LoadImage(hInstance, (LPCTSTR)IDI_PPSSPP, IMAGE_ICON, 16, 16, LR_SHARED); wcex.hIconSm = (HICON)LoadImage(hInstance, (LPCTSTR)IDI_PPSSPP, IMAGE_ICON, 16, 16, LR_SHARED);
RegisterClassEx(&wcex); RegisterClassEx(&wcex);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)DisplayProc;
wcex.hIcon = 0;
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = 0;
wcex.lpszClassName = szDisplayClass;
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
} }
void SavePosition() { void SavePosition() {
@ -231,6 +247,8 @@ namespace MainWindow {
if (!noWindowMovement) { if (!noWindowMovement) {
width = rc.right - rc.left; width = rc.right - rc.left;
height = rc.bottom - rc.top; height = rc.bottom - rc.top;
// Moves the internal window, not the frame. TODO: Get rid of the internal window.
MoveWindow(hwndDisplay, 0, 0, width, height, TRUE);
// This is taken care of anyway later, but makes sure that ShowScreenResolution gets the right numbers. // This is taken care of anyway later, but makes sure that ShowScreenResolution gets the right numbers.
// Need to clean all of this up... // Need to clean all of this up...
PSP_CoreParameter().pixelWidth = width; PSP_CoreParameter().pixelWidth = width;
@ -782,6 +800,11 @@ namespace MainWindow {
RECT rcClient; RECT rcClient;
GetClientRect(hwndMain, &rcClient); GetClientRect(hwndMain, &rcClient);
hwndDisplay = CreateWindowEx(0, szDisplayClass, L"", WS_CHILD | WS_VISIBLE,
0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hwndMain, 0, hInstance, 0);
if (!hwndDisplay)
return FALSE;
menu = GetMenu(hwndMain); menu = GetMenu(hwndMain);
#ifdef FINAL #ifdef FINAL
@ -809,7 +832,7 @@ namespace MainWindow {
W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);
touchHandler.registerTouchWindow(hwndMain); touchHandler.registerTouchWindow(hwndDisplay);
WindowsRawInput::Init(); WindowsRawInput::Init();
@ -920,44 +943,21 @@ namespace MainWindow {
} }
} }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
// Only apply a factor > 1 in windowed mode. // Only apply a factor > 1 in windowed mode.
int factor = !IsZoomed(GetHWND()) && !g_Config.bFullScreen && g_Config.iWindowWidth < (480 + 80) ? 2 : 1; int factor = !IsZoomed(GetHWND()) && !g_Config.bFullScreen && g_Config.iWindowWidth < (480 + 80) ? 2 : 1;
int wmId, wmEvent;
std::string fn;
static bool noFocusPause = false; // TOGGLE_PAUSE state to override pause on lost focus
static bool firstErase = true; static bool firstErase = true;
switch (message) { switch (message) {
case WM_SIZE: case WM_ACTIVATE:
if (!g_inModeSwitch) { if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
switch (wParam) { g_activeWindow = WINDOW_MAINWINDOW;
case SIZE_MAXIMIZED:
case SIZE_RESTORED:
Core_NotifyWindowHidden(false);
SavePosition();
ResizeDisplay();
break;
case SIZE_MINIMIZED:
Core_NotifyWindowHidden(true);
break;
default:
break;
}
} }
break; break;
case WM_GETMINMAXINFO: case WM_SETFOCUS:
{ break;
MINMAXINFO *minmax = reinterpret_cast<MINMAXINFO *>(lParam);
RECT rc = { 0 };
rc.right = 480;
rc.bottom = 272;
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, TRUE);
minmax->ptMinTrackSize.x = rc.right - rc.left;
minmax->ptMinTrackSize.y = rc.bottom - rc.top;
}
return 0;
case WM_ERASEBKGND: case WM_ERASEBKGND:
if (firstErase) { if (firstErase) {
@ -1056,6 +1056,33 @@ namespace MainWindow {
return 0; return 0;
} }
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
int wmId, wmEvent;
std::string fn;
static bool noFocusPause = false; // TOGGLE_PAUSE state to override pause on lost focus
switch (message) {
case WM_CREATE:
break;
case WM_GETMINMAXINFO:
{
MINMAXINFO *minmax = reinterpret_cast<MINMAXINFO *>(lParam);
RECT rc = { 0 };
rc.right = 480;
rc.bottom = 272;
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, TRUE);
minmax->ptMinTrackSize.x = rc.right - rc.left;
minmax->ptMinTrackSize.y = rc.bottom - rc.top;
}
return 0;
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
bool pause = true; bool pause = true;
@ -1078,11 +1105,32 @@ namespace MainWindow {
} }
break; break;
case WM_ERASEBKGND:
// This window is always covered by DisplayWindow. No reason to erase.
return 1;
case WM_MOVE: case WM_MOVE:
SavePosition(); SavePosition();
break; break;
case WM_TIMER: case WM_SIZE:
if (!g_inModeSwitch) {
switch (wParam) {
case SIZE_MAXIMIZED:
case SIZE_RESTORED:
Core_NotifyWindowHidden(false);
SavePosition();
ResizeDisplay();
break;
case SIZE_MINIMIZED:
Core_NotifyWindowHidden(true);
break;
default:
break;
}
}
case WM_TIMER:
// Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode. // Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode.
switch (wParam) { switch (wParam) {
case TIMER_CURSORUPDATE: case TIMER_CURSORUPDATE:
@ -1898,13 +1946,13 @@ namespace MainWindow {
} }
void Update() { void Update() {
InvalidateRect(hwndMain,0,0); InvalidateRect(hwndDisplay,0,0);
UpdateWindow(hwndMain); UpdateWindow(hwndDisplay);
SendMessage(hwndMain,WM_SIZE,0,0); SendMessage(hwndMain,WM_SIZE,0,0);
} }
void Redraw() { void Redraw() {
InvalidateRect(hwndMain, 0, 0); InvalidateRect(hwndDisplay,0,0);
} }
void SaveStateActionFinished(bool result, void *userdata) { void SaveStateActionFinished(bool result, void *userdata) {

View file

@ -60,6 +60,7 @@ namespace MainWindow
void Redraw(); void Redraw();
HWND GetHWND(); HWND GetHWND();
HINSTANCE GetHInstance(); HINSTANCE GetHInstance();
HWND GetDisplayHWND();
void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false); void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false);
void SaveStateActionFinished(bool result, void *userdata); void SaveStateActionFinished(bool result, void *userdata);
void SwitchToFullscreen(HWND hWnd); void SwitchToFullscreen(HWND hWnd);

View file

@ -377,6 +377,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
MainWindow::Show(_hInstance, iCmdShow); MainWindow::Show(_hInstance, iCmdShow);
HWND hwndMain = MainWindow::GetHWND(); HWND hwndMain = MainWindow::GetHWND();
HWND hwndDisplay = MainWindow::GetDisplayHWND();
//initialize custom controls //initialize custom controls
CtrlDisAsmView::init(); CtrlDisAsmView::init();
@ -386,7 +387,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS)); DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));
host = new WindowsHost(hwndMain); host = new WindowsHost(hwndMain, hwndDisplay);
host->SetWindowTitle(0); host->SetWindowTitle(0);
MainWindow::CreateDebugWindows(); MainWindow::CreateDebugWindows();