From e74be9c4920194cc5292922b85e48ade2bba6b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 3 Mar 2019 09:18:11 +0100 Subject: [PATCH] DPI fixes in the old Win32 debugger. Fixes #11856. Also some general cleanup of it but decided it wasn't worth it to continue. --- Windows/Debugger/CtrlDisAsmView.cpp | 23 +++++--- Windows/Debugger/CtrlMemView.cpp | 34 ++++++----- Windows/Debugger/CtrlRegisterList.cpp | 85 +++++++++++---------------- Windows/Debugger/CtrlRegisterList.h | 28 ++++----- 4 files changed, 80 insertions(+), 90 deletions(-) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 93d4ed6178..fdf4de758c 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -21,6 +21,7 @@ #include "Common/CommonWindows.h" #include "util/text/utf8.h" #include "ext/xxhash.h" +#include "base/display.h" #include #include @@ -154,17 +155,21 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) wnd=_wnd; SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)this); SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd,GWL_STYLE) | WS_VSCROLL); - SetScrollRange(wnd, SB_VERT, -1,1,TRUE); + SetScrollRange(wnd, SB_VERT, -1, 1, TRUE); - charWidth = g_Config.iFontWidth; - rowHeight = g_Config.iFontHeight+2; + const float fontScale = 1.0f / g_dpi_scale_real_y; + charWidth = g_Config.iFontWidth * fontScale; + rowHeight = (g_Config.iFontHeight + 2) * fontScale; + int scaledFontHeight = g_Config.iFontHeight * fontScale; + font = CreateFont(scaledFontHeight, charWidth, 0, 0, + FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, + L"Lucida Console"); + boldfont = CreateFont(scaledFontHeight, charWidth, 0, 0, + FW_DEMIBOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, + L"Lucida Console"); - font = CreateFont(rowHeight-2,charWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, - L"Lucida Console"); - boldfont = CreateFont(rowHeight-2,charWidth,0,0,FW_DEMIBOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, - L"Lucida Console"); - curAddress=0; - showHex=false; + curAddress = 0; + showHex = false; hasFocus = false; dontRedraw = false; keyTaken = false; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index ff28e1b99d..331126a00e 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -4,12 +4,13 @@ #include #include "Core/Config.h" -#include "../resource.h" -#include "../../Core/MemMap.h" -#include "../W32Util/Misc.h" +#include "Windows/resource.h" +#include "Core/MemMap.h" +#include "Windows/W32Util/Misc.h" #include "Windows/InputBox.h" -#include "../Main.h" -#include "../../Core/Debugger/SymbolMap.h" +#include "Windows/main.h" +#include "Core/Debugger/SymbolMap.h" +#include "base/display.h" #include "Debugger_Disasm.h" #include "DebuggerShared.h" @@ -26,19 +27,20 @@ CtrlMemView::CtrlMemView(HWND _wnd) SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd,GWL_STYLE) | WS_VSCROLL); SetScrollRange(wnd, SB_VERT, -1,1,TRUE); - rowHeight = g_Config.iFontHeight; - charWidth = g_Config.iFontWidth; - offsetPositionY = offsetLine*rowHeight; + const float fontScale = 1.0f / g_dpi_scale_real_y; + rowHeight = g_Config.iFontHeight * fontScale; + charWidth = g_Config.iFontWidth * fontScale; + offsetPositionY = offsetLine * rowHeight; - font = - CreateFont(rowHeight,charWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Lucida Console"); - underlineFont = - CreateFont(rowHeight,charWidth,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Lucida Console"); - curAddress=0; + font = CreateFont(rowHeight, charWidth, 0, 0, + FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, + L"Lucida Console"); + underlineFont = CreateFont(rowHeight, charWidth, 0, 0, + FW_DONTCARE, FALSE, TRUE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, + L"Lucida Console"); + curAddress = 0; debugger = 0; - + searchQuery = ""; matchAddress = -1; searching = false; diff --git a/Windows/Debugger/CtrlRegisterList.cpp b/Windows/Debugger/CtrlRegisterList.cpp index 6a9241be81..563a2b47f1 100644 --- a/Windows/Debugger/CtrlRegisterList.cpp +++ b/Windows/Debugger/CtrlRegisterList.cpp @@ -3,11 +3,12 @@ #include #include +#include "base/display.h" #include "util/text/utf8.h" -#include "../resource.h" +#include "Windows/resource.h" #include "Core/MemMap.h" -#include "../W32Util/Misc.h" -#include "../InputBox.h" +#include "Windows/W32Util/Misc.h" +#include "Windows/InputBox.h" #include "CtrlRegisterList.h" #include "Debugger_MemoryDlg.h" @@ -16,11 +17,10 @@ #include "Debugger_Disasm.h" #include "DebuggerShared.h" -#include "../main.h" +#include "Windows/main.h" static const int numCPUs = 1; -//#include "DbgHelp.h" extern HMENU g_hPopupMenus; enum { REGISTER_PC = 32, REGISTER_HI, REGISTER_LO, REGISTERS_END }; @@ -29,23 +29,22 @@ TCHAR CtrlRegisterList::szClassName[] = _T("CtrlRegisterList"); void CtrlRegisterList::init() { - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = szClassName; - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = CtrlRegisterList::wndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); - wc.style = CS_DBLCLKS; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof( CtrlRegisterList * ); - wc.hIconSm = 0; - - - RegisterClassEx(&wc); + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + wc.lpszClassName = szClassName; + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = CtrlRegisterList::wndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); + wc.style = CS_DBLCLKS; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(CtrlRegisterList *); + wc.hIconSm = 0; + + RegisterClassEx(&wc); } void CtrlRegisterList::deinit() @@ -53,8 +52,6 @@ void CtrlRegisterList::deinit() //UnregisterClass(szClassName, hInst) } - - LRESULT CALLBACK CtrlRegisterList::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { CtrlRegisterList *ccp = CtrlRegisterList::getFrom(hwnd); @@ -109,44 +106,30 @@ LRESULT CALLBACK CtrlRegisterList::wndProc(HWND hwnd, UINT msg, WPARAM wParam, L break; case WM_GETDLGCODE: // want chars so that we can return 0 on key press and supress the beeping sound return DLGC_WANTARROWS|DLGC_WANTCHARS; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} + default: + break; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} CtrlRegisterList *CtrlRegisterList::getFrom(HWND hwnd) { - return (CtrlRegisterList *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + return (CtrlRegisterList *)GetWindowLongPtr(hwnd, GWLP_USERDATA); } - - - CtrlRegisterList::CtrlRegisterList(HWND _wnd) -{ - wnd=_wnd; + : wnd(_wnd) { SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)this); - //SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd,GWL_STYLE) | WS_VSCROLL); - //SetScrollRange(wnd, SB_VERT, -1,1,TRUE); - - rowHeight=g_Config.iFontHeight; - font = CreateFont(rowHeight,g_Config.iFontWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY,DEFAULT_PITCH,L"Lucida Console"); - selecting=false; - selection=0; - category=0; - showHex=false; - cpu=0; - lastPC = 0; - lastCat0Values = NULL; - changedCat0Regs = NULL; + const float fontScale = 1.0f / g_dpi_scale_real_y; + rowHeight = g_Config.iFontHeight * fontScale; + int charWidth = g_Config.iFontWidth * fontScale; + font = CreateFont(rowHeight, charWidth, 0, 0, + FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, + L"Lucida Console"); } - CtrlRegisterList::~CtrlRegisterList() { DeleteObject(font); diff --git a/Windows/Debugger/CtrlRegisterList.h b/Windows/Debugger/CtrlRegisterList.h index fcaa78967e..123e8e0713 100644 --- a/Windows/Debugger/CtrlRegisterList.h +++ b/Windows/Debugger/CtrlRegisterList.h @@ -27,23 +27,23 @@ class CtrlRegisterList RECT rect; int rowHeight; - int selection; - int marker; - int category; + int selection = 0; + int marker = 0; + int category = 0; - int oldSelection; + int oldSelection = 0; - bool selectionChanged; - bool selecting; - bool hasFocus; - bool showHex; - DebugInterface *cpu; + bool selectionChanged = false; + bool selecting = false; + bool hasFocus = false; + bool showHex = false; + DebugInterface *cpu = nullptr; static TCHAR szClassName[]; - u32 lastPC; - u32 *lastCat0Values; - bool *changedCat0Regs; - bool ctrlDown; + u32 lastPC = 0; + u32 *lastCat0Values = nullptr; + bool *changedCat0Regs = nullptr; + bool ctrlDown = false; u32 getSelectedRegValue(char *out, size_t size); void copyRegisterValue(); @@ -79,4 +79,4 @@ public: { return cpu; } -}; \ No newline at end of file +};