diff --git a/Windows/Debugger/DebuggerShared.h b/Windows/Debugger/DebuggerShared.h index be55ec8eb8..b0d1ba6b36 100644 --- a/Windows/Debugger/DebuggerShared.h +++ b/Windows/Debugger/DebuggerShared.h @@ -2,6 +2,8 @@ #include #include "..\..\Core\Debugger\DebugInterface.h" +extern HMENU g_hPopupMenus; + enum { WM_DEB_RUNTOWPARAM = WM_USER+2, WM_DEB_GOTOWPARAM, WM_DEB_GOTOBREAKPOINT, diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index a8952c3906..054f433c7e 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -354,9 +354,9 @@ void CDisasm::showBreakpointMenu(int itemIndex, const POINT &pt) HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_BREAKPOINTLIST); if (isMemory) { - CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, mcPrev.result & MEMCHECK_BREAK ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (mcPrev.result & MEMCHECK_BREAK ? MF_CHECKED : MF_UNCHECKED)); } else { - CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, bpPrev.enabled ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (bpPrev.enabled ? MF_CHECKED : MF_UNCHECKED)); } switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0)) diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index b328353b37..cc1d1f649c 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -3,6 +3,7 @@ #include #include #include "DebuggerShared.h" +#include "Windows/resource.h" enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT }; @@ -14,6 +15,8 @@ const float threadColumnSizes[] = { 0.20f, 0.15f, 0.15f, 0.15f, 0.15f, 0.20f }; +const int POPUP_SUBMENU_ID_THREADLIST = 6; + void CtrlThreadList::setDialogItem(HWND hwnd) { wnd = hwnd; @@ -76,6 +79,51 @@ LRESULT CALLBACK CtrlThreadList::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA return (LRESULT)CallWindowProc((WNDPROC)tl->oldProc,hwnd,msg,wParam,lParam); } +void CtrlThreadList::showMenu(int itemIndex, const POINT &pt) +{ + auto threadInfo = threads[itemIndex]; + + // Can't do it, sorry. Needs to not be running. + if (Core_IsActive()) + return; + + POINT screenPt(pt); + ClientToScreen(wnd, &screenPt); + + HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_THREADLIST); + switch (threadInfo.status) { + case THREADSTATUS_DEAD: + case THREADSTATUS_DORMANT: + case THREADSTATUS_RUNNING: + EnableMenuItem(subMenu, ID_DISASM_THREAD_FORCERUN, MF_BYCOMMAND | MF_DISABLED); + EnableMenuItem(subMenu, ID_DISASM_THREAD_KILL, MF_BYCOMMAND | MF_DISABLED); + break; + case THREADSTATUS_READY: + EnableMenuItem(subMenu, ID_DISASM_THREAD_FORCERUN, MF_BYCOMMAND | MF_DISABLED); + EnableMenuItem(subMenu, ID_DISASM_THREAD_KILL, MF_BYCOMMAND | MF_ENABLED); + break; + case THREADSTATUS_SUSPEND: + case THREADSTATUS_WAIT: + case THREADSTATUS_WAITSUSPEND: + default: + EnableMenuItem(subMenu, ID_DISASM_THREAD_FORCERUN, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(subMenu, ID_DISASM_THREAD_KILL, MF_BYCOMMAND | MF_ENABLED); + break; + } + + switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0)) + { + case ID_DISASM_THREAD_FORCERUN: + __KernelResumeThreadFromWait(threadInfo.id, 0); + reloadThreads(); + break; + case ID_DISASM_THREAD_KILL: + sceKernelTerminateThread(threadInfo.id); + reloadThreads(); + break; + } +} + void CtrlThreadList::handleNotify(LPARAM lParam) { LPNMHDR mhdr = (LPNMHDR) lParam; @@ -99,6 +147,12 @@ void CtrlThreadList::handleNotify(LPARAM lParam) SendMessage(GetParent(wnd),WM_DEB_GOTOWPARAM,address,0); return; } + if (mhdr->code == NM_RCLICK) + { + const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE)lParam; + showMenu(item->iItem, item->ptAction); + return; + } if (mhdr->code == LVN_GETDISPINFO) { @@ -188,7 +242,7 @@ void CtrlThreadList::reloadThreads() items++; } - while (items > threads.size()) + while (items > (int)threads.size()) { ListView_DeleteItem(wnd,--items); } @@ -199,7 +253,7 @@ void CtrlThreadList::reloadThreads() const char* CtrlThreadList::getCurrentThreadName() { - for (int i = 0; i < threads.size(); i++) + for (size_t i = 0; i < threads.size(); i++) { if (threads[i].isCurrent) return threads[i].name; } diff --git a/Windows/Debugger/Debugger_Lists.h b/Windows/Debugger/Debugger_Lists.h index ac8ffd5afb..b9260604c9 100644 --- a/Windows/Debugger/Debugger_Lists.h +++ b/Windows/Debugger/Debugger_Lists.h @@ -14,6 +14,7 @@ public: void setDialogItem(HWND hwnd); void reloadThreads(); void handleNotify(LPARAM lParam); + void showMenu(int itemIndex, const POINT &pt); static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); const char* getCurrentThreadName(); }; \ No newline at end of file diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 28e751a457..359fa3106b 100644 Binary files a/Windows/ppsspp.rc and b/Windows/ppsspp.rc differ diff --git a/Windows/resource.h b/Windows/resource.h index 47c921cb77..032d62c03c 100644 Binary files a/Windows/resource.h and b/Windows/resource.h differ