From 3ee166101a1459da47d0078a869ff6023ba0ff64 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:06:59 +0100 Subject: [PATCH] debugger: fix breakpoints window right-click being offset --- src/gui/wxgui/debugger/BreakpointWindow.cpp | 39 ++++++++++----------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/gui/wxgui/debugger/BreakpointWindow.cpp b/src/gui/wxgui/debugger/BreakpointWindow.cpp index 13ce86c8..64e82c59 100644 --- a/src/gui/wxgui/debugger/BreakpointWindow.cpp +++ b/src/gui/wxgui/debugger/BreakpointWindow.cpp @@ -32,7 +32,7 @@ BreakpointWindow::BreakpointWindow(DebuggerWindow2& parent, const wxPoint& main_ wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); - m_breakpoints = new wxListView(this, wxID_ANY); + m_breakpoints = new wxListView(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); m_breakpoints->EnableCheckBoxes(true); wxListItem col0; @@ -162,10 +162,12 @@ void BreakpointWindow::OnBreakpointToggled(wxListEvent& event) void BreakpointWindow::OnLeftDClick(wxMouseEvent& event) { const auto position = event.GetPosition(); - const sint32 index = (position.y / m_breakpoints->GetCharHeight()) - 2; - if (index < 0 || index >= m_breakpoints->GetItemCount()) + int flags = 0; + const long index = m_breakpoints->HitTest(position, flags); + + if (index == wxNOT_FOUND) return; - + sint32 x = position.x; const auto enabled_width = m_breakpoints->GetColumnWidth(ColumnEnabled); if (x <= enabled_width) @@ -173,7 +175,7 @@ void BreakpointWindow::OnLeftDClick(wxMouseEvent& event) x -= enabled_width; const auto address_width = m_breakpoints->GetColumnWidth(ColumnAddress); - if(x <= address_width) + if (x <= address_width) { const auto item = m_breakpoints->GetItemText(index, ColumnAddress); const auto address = std::stoul(item.ToStdString(), nullptr, 16); @@ -183,13 +185,13 @@ void BreakpointWindow::OnLeftDClick(wxMouseEvent& event) } x -= address_width; - const auto type_width = m_breakpoints->GetColumnWidth(ColumnType); + const auto type_width = m_breakpoints->GetColumnWidth(ColumnType); if (x <= type_width) return; x -= type_width; const auto comment_width = m_breakpoints->GetColumnWidth(ColumnComment); - if(x <= comment_width) + if (x <= comment_width) { if (index >= debuggerState.breakpoints.size()) return; @@ -213,9 +215,9 @@ void BreakpointWindow::OnLeftDClick(wxMouseEvent& event) void BreakpointWindow::OnRightDown(wxMouseEvent& event) { - const auto position = event.GetPosition(); - const sint32 index = (position.y / m_breakpoints->GetCharHeight()) - 2; - if (index < 0 || index >= m_breakpoints->GetItemCount()) + int flags = 0; + const long index = m_breakpoints->HitTest(event.GetPosition(), flags); + if (index == wxNOT_FOUND || index < 0 || index >= m_breakpoints->GetItemCount()) { wxMenu menu; menu.Append(MENU_ID_CREATE_CODE_BP_EXECUTION, _("Create execution breakpoint")); @@ -244,19 +246,16 @@ void BreakpointWindow::OnContextMenuClickSelected(wxCommandEvent& evt) if (evt.GetId() == MENU_ID_DELETE_BP) { long sel = m_breakpoints->GetFirstSelected(); - if (sel != wxNOT_FOUND) - { - if (sel >= debuggerState.breakpoints.size()) - return; + if (sel == wxNOT_FOUND || sel < 0 || sel >= m_breakpoints->GetItemCount()) + return; - auto it = debuggerState.breakpoints.begin(); - std::advance(it, sel); + auto it = debuggerState.breakpoints.begin(); + std::advance(it, sel); - debugger_deleteBreakpoint(*it); + debugger_deleteBreakpoint(*it); - wxCommandEvent evt(wxEVT_BREAKPOINT_CHANGE); - wxPostEvent(this->m_parent, evt); - } + wxCommandEvent evt(wxEVT_BREAKPOINT_CHANGE); + wxPostEvent(this->m_parent, evt); } }