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);
}
WindowsHost::WindowsHost(HWND mainWindow) {
window_ = mainWindow;
WindowsHost::WindowsHost(HWND mainWindow, HWND displayWindow)
{
mainWindow_ = mainWindow;
displayWindow_ = displayWindow;
mouseDeltaX = 0;
mouseDeltaY = 0;
@ -88,13 +90,13 @@ WindowsHost::WindowsHost(HWND mainWindow) {
bool WindowsHost::InitGL(std::string *error_message)
{
return GL_Init(window_, error_message);
return GL_Init(displayWindow_, error_message);
}
void WindowsHost::ShutdownGL()
{
GL_Shutdown();
PostMessage(window_, WM_CLOSE, 0, 0);
PostMessage(mainWindow_, WM_CLOSE, 0, 0);
}
void WindowsHost::SetWindowTitle(const char *message)
@ -106,7 +108,7 @@ void WindowsHost::SetWindowTitle(const char *message)
}
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)
@ -128,12 +130,12 @@ void WindowsHost::ShutdownSound()
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()
{
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_SCREEN, 0, 0);
PostMessage(mainWindow_, MainWindow::WM_USER_UPDATE_SCREEN, 0, 0);
}
void WindowsHost::UpdateMemView()
@ -191,7 +193,7 @@ void WindowsHost::PollControllers(InputState &input_state)
void WindowsHost::BootDone()
{
symbolMap.SortSymbols();
SendMessage(MainWindow::GetHWND(), WM_USER+1, 0,0);
SendMessage(mainWindow_, WM_USER + 1, 0, 0);
SetDebugMode(!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) {
if (viewFullscreen)
MainWindow::SwitchToFullscreen(MainWindow::GetHWND());
MainWindow::SwitchToFullscreen(mainWindow_);
else
MainWindow::SwitchToWindowed(MainWindow::GetHWND());
MainWindow::SwitchToWindowed(mainWindow_);
}
void WindowsHost::ToggleDebugConsoleVisibility() {

View file

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

View file

@ -86,8 +86,6 @@
static const int numCPUs = 1;
// These are for Unknown's modified "Very Sleepy" profiler with JIT support.
int verysleepy__useSendMessage = 1;
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.
const WPARAM VERYSLEEPY_WPARAM_GETADDRINFO = 1;
struct VerySleepy_AddrInfo {
struct VerySleepy_AddrInfo
{
// Always zero for now.
int flags;
// This is the pointer (always passed as 64 bits.)
@ -116,8 +115,11 @@ extern InputState input_state;
#define CURSORUPDATE_INTERVAL_MS 1000
#define CURSORUPDATE_MOVE_TIMESPAN_MS 500
namespace MainWindow {
namespace MainWindow
{
HWND hwndMain;
HWND hwndDisplay;
HWND hwndGameList;
TouchInputHandler touchHandler;
static HMENU menu;
@ -141,12 +143,17 @@ namespace MainWindow {
// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
HWND GetHWND() {
return hwndMain;
}
HWND GetDisplayHWND() {
return hwndDisplay;
}
void Init(HINSTANCE hInstance) {
#ifdef THEMES
WTL::CTheme::IsThemingSupported();
@ -166,6 +173,15 @@ namespace MainWindow {
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = (HICON)LoadImage(hInstance, (LPCTSTR)IDI_PPSSPP, IMAGE_ICON, 16, 16, LR_SHARED);
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() {
@ -231,6 +247,8 @@ namespace MainWindow {
if (!noWindowMovement) {
width = rc.right - rc.left;
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.
// Need to clean all of this up...
PSP_CoreParameter().pixelWidth = width;
@ -782,6 +800,11 @@ namespace MainWindow {
RECT 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);
#ifdef FINAL
@ -809,7 +832,7 @@ namespace MainWindow {
W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);
touchHandler.registerTouchWindow(hwndMain);
touchHandler.registerTouchWindow(hwndDisplay);
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.
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;
switch (message) {
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_ACTIVATE:
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
g_activeWindow = WINDOW_MAINWINDOW;
}
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_SETFOCUS:
break;
case WM_ERASEBKGND:
if (firstErase) {
@ -1056,6 +1056,33 @@ namespace MainWindow {
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:
{
bool pause = true;
@ -1078,10 +1105,31 @@ namespace MainWindow {
}
break;
case WM_ERASEBKGND:
// This window is always covered by DisplayWindow. No reason to erase.
return 1;
case WM_MOVE:
SavePosition();
break;
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.
switch (wParam) {
@ -1898,13 +1946,13 @@ namespace MainWindow {
}
void Update() {
InvalidateRect(hwndMain,0,0);
UpdateWindow(hwndMain);
InvalidateRect(hwndDisplay,0,0);
UpdateWindow(hwndDisplay);
SendMessage(hwndMain,WM_SIZE,0,0);
}
void Redraw() {
InvalidateRect(hwndMain, 0, 0);
InvalidateRect(hwndDisplay,0,0);
}
void SaveStateActionFinished(bool result, void *userdata) {

View file

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

View file

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