From 281ff6ce2abf5a5ecff44cb25d4397ae6bc15090 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 11 May 2014 18:04:07 +0200 Subject: [PATCH] Windows: Get rid of that silly inner "display" window. Should be zero functional change. --- Windows/WindowsHost.cpp | 8 ++--- Windows/WindowsHost.h | 34 +++++++++---------- Windows/WndMainWindow.cpp | 69 ++++++++------------------------------- Windows/WndMainWindow.h | 1 - Windows/main.cpp | 3 +- 5 files changed, 33 insertions(+), 82 deletions(-) diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 039d0f4ff5..b72c29085d 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -79,10 +79,8 @@ static BOOL PostDialogMessage(Dialog *dialog, UINT message, WPARAM wParam = 0, L return PostMessage(dialog->GetDlgHandle(), message, wParam, lParam); } -WindowsHost::WindowsHost(HWND mainWindow, HWND displayWindow) -{ - mainWindow_ = mainWindow; - displayWindow_ = displayWindow; +WindowsHost::WindowsHost(HWND mainWindow) { + window_ = mainWindow; mouseDeltaX = 0; mouseDeltaY = 0; @@ -98,7 +96,7 @@ WindowsHost::WindowsHost(HWND mainWindow, HWND displayWindow) bool WindowsHost::InitGL(std::string *error_message) { - return GL_Init(MainWindow::GetDisplayHWND(), error_message); + return GL_Init(MainWindow::GetHWND(), error_message); } void WindowsHost::ShutdownGL() diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index 7bfdae872b..b95c23e220 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -24,20 +24,17 @@ extern float mouseDeltaX; extern float mouseDeltaY; -class WindowsHost : public Host -{ +class WindowsHost : public Host { public: - WindowsHost(HWND mainWindow, HWND displayWindow); - - ~WindowsHost() - { + WindowsHost(HWND mainWindow); + virtual ~WindowsHost() { UpdateConsolePosition(); } void UpdateMemView(); void UpdateDisassembly(); void UpdateUI(); - virtual void UpdateScreen(); + virtual void UpdateScreen() override; void SetDebugMode(bool mode); bool InitGL(std::string *error_message); @@ -54,18 +51,18 @@ public: void SaveSymbolMap(); void SetWindowTitle(const char *message); - 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 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 CanCreateShortcut() {return false;} // Turn on when fixed - virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title); + virtual bool CanCreateShortcut() override { return false; } // Turn on when fixed + virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) override; - virtual void GoFullscreen(bool); + virtual void GoFullscreen(bool) override; std::shared_ptr keyboard; @@ -73,8 +70,7 @@ private: void SetConsolePosition(); void UpdateConsolePosition(); - HWND displayWindow_; - HWND mainWindow_; + HWND window_; std::list> input; }; diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index b209a71e08..b478499578 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -84,6 +84,8 @@ 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; @@ -92,8 +94,7 @@ 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.) @@ -113,11 +114,8 @@ 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; @@ -139,17 +137,12 @@ 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(); @@ -169,15 +162,6 @@ 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() { @@ -240,8 +224,6 @@ 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; @@ -778,11 +760,6 @@ 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 @@ -810,7 +787,7 @@ namespace MainWindow W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); - touchHandler.registerTouchWindow(hwndDisplay); + touchHandler.registerTouchWindow(hwndMain); WindowsRawInput::Init(); @@ -921,21 +898,20 @@ namespace MainWindow } } - LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + LRESULT CALLBACK WndProc(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 switch (message) { - case WM_ACTIVATE: - if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) { - g_activeWindow = WINDOW_MAINWINDOW; - } - break; - case WM_SETFOCUS: break; case WM_SIZE: + SavePosition(); + ResizeDisplay(); break; case WM_ERASEBKGND: @@ -1033,18 +1009,6 @@ namespace MainWindow case WM_PAINT: return DefWindowProc(hWnd, message, wParam, lParam); - 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; @@ -1074,11 +1038,6 @@ namespace MainWindow SavePosition(); break; - case WM_SIZE: - SavePosition(); - ResizeDisplay(); - break; - case WM_TIMER: // Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode. switch (wParam) { @@ -1862,13 +1821,13 @@ namespace MainWindow } void Update() { - InvalidateRect(hwndDisplay,0,0); - UpdateWindow(hwndDisplay); + InvalidateRect(hwndMain,0,0); + UpdateWindow(hwndMain); SendMessage(hwndMain,WM_SIZE,0,0); } void Redraw() { - InvalidateRect(hwndDisplay,0,0); + InvalidateRect(hwndMain, 0, 0); } void SaveStateActionFinished(bool result, void *userdata) { diff --git a/Windows/WndMainWindow.h b/Windows/WndMainWindow.h index 9b4473a4b9..942d3f3dde 100644 --- a/Windows/WndMainWindow.h +++ b/Windows/WndMainWindow.h @@ -60,7 +60,6 @@ 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 _ViewFullScreen(HWND hWnd); diff --git a/Windows/main.cpp b/Windows/main.cpp index b03a2eecf1..2c227b7794 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -374,7 +374,6 @@ 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(); @@ -384,7 +383,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS)); - host = new WindowsHost(hwndMain, hwndDisplay); + host = new WindowsHost(hwndMain); host->SetWindowTitle(0); MainWindow::CreateDebugWindows();