From 2f1a91279fcc3c20043bdc31f8342ab3a031f7a2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 10 Sep 2025 16:15:59 +0100 Subject: [PATCH] Make sure DRC inspection dialogs come up in front of DRC dialog. --- libs/kiplatform/include/kiplatform/ui.h | 3 +++ libs/kiplatform/port/wxosx/ui.mm | 23 ++++++++++------------- pcbnew/tools/board_inspection_tool.cpp | 20 ++++++++++++++------ pcbnew/tools/board_inspection_tool.h | 2 +- pcbnew/tools/drc_tool.h | 2 ++ 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index c6fb4f3787..c7c9c5c8a5 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -25,6 +25,7 @@ class wxChoice; class wxNonOwnedWindow; +class wxTopLevelWindow; class wxWindow; namespace KIPLATFORM @@ -71,6 +72,8 @@ namespace KIPLATFORM */ void ReparentModal( wxNonOwnedWindow* aWindow ); + void ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent ); + /* * An ugly hack to fix an issue on OSX: cmd+c closes the dialog instead of copying the * text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer created by diff --git a/libs/kiplatform/port/wxosx/ui.mm b/libs/kiplatform/port/wxosx/ui.mm index b75f7db15d..1d54ff41df 100644 --- a/libs/kiplatform/port/wxosx/ui.mm +++ b/libs/kiplatform/port/wxosx/ui.mm @@ -103,24 +103,21 @@ void KIPLATFORM::UI::EnsureVisible( wxWindow* aWindow ) } -void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow ) +void KIPLATFORM::UI::ReparentWindow( wxNonOwnedWindow* aWindow, wxTopLevelWindow* aParent ) { - wxTopLevelWindow* parent = - static_cast( wxGetTopLevelParent( aWindow->GetParent() ) ); - - // Quietly return if no parent is found - if( !parent ) - { - return; - } - - NSWindow* parentWindow = parent->GetWXWindow(); + NSWindow* parentWindow = aParent->GetWXWindow(); NSWindow* theWindow = aWindow->GetWXWindow(); if( parentWindow && theWindow ) - { [parentWindow addChildWindow:theWindow ordered:NSWindowAbove]; - } +} + + +void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow ) +{ + // Quietly return if no parent is found + if( wxTopLevelWindow* parent = static_cast( wxGetTopLevelParent( aWindow->GetParent() ) ) ) + ReparentWindow( aWindow, parent ); } diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index cbaedf45c3..9bc4b0d9c1 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -34,11 +35,12 @@ #include #include #include +#include +#include #include #include #include #include -#include #include #include #include @@ -338,7 +340,9 @@ wxString BOARD_INSPECTION_TOOL::InspectDRCErrorMenuText( const std::shared_ptr& aDRCItem ) { - wxCHECK( m_frame, /* void */ ); + DRC_TOOL* drcTool = m_toolMgr->GetTool(); + + wxCHECK( drcTool && m_frame, /* void */ ); BOARD_ITEM* a = m_frame->GetBoard()->ResolveItem( aDRCItem->GetMainItemID() ); BOARD_ITEM* b = m_frame->GetBoard()->ResolveItem( aDRCItem->GetAuxItemID() ); @@ -349,7 +353,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH ) { if( FOOTPRINT* footprint = dynamic_cast( a ) ) - DiffFootprint( footprint ); + DiffFootprint( footprint, drcTool->GetDRCDialog() ); return; } @@ -698,7 +702,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR r->Flush(); - dialog->Raise(); + KIPLATFORM::UI::ReparentWindow( dialog, drcTool->GetDRCDialog() ); dialog->Show( true ); } @@ -1613,7 +1617,7 @@ int BOARD_INSPECTION_TOOL::ShowFootprintLinks( const TOOL_EVENT& aEvent ) } -void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint ) +void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo ) { DIALOG_BOOK_REPORTER* dialog = m_frame->GetFootprintDiffDialog(); @@ -1694,7 +1698,11 @@ void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint ) r->Flush(); - dialog->Raise(); + if( aReparentTo ) + KIPLATFORM::UI::ReparentWindow( dialog, aReparentTo ); + else + dialog->Raise(); + dialog->Show( true ); } diff --git a/pcbnew/tools/board_inspection_tool.h b/pcbnew/tools/board_inspection_tool.h index c3820aa791..93ea8cb8d8 100644 --- a/pcbnew/tools/board_inspection_tool.h +++ b/pcbnew/tools/board_inspection_tool.h @@ -90,7 +90,7 @@ public: int ShowFootprintLinks( const TOOL_EVENT& aEvent ); int DiffFootprint( const TOOL_EVENT& aEvent ); - void DiffFootprint( FOOTPRINT* aFootprint ); + void DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo = nullptr ); /** * @return true if a net or nets to highlight have been set diff --git a/pcbnew/tools/drc_tool.h b/pcbnew/tools/drc_tool.h index 7565502218..6133ac1ac4 100644 --- a/pcbnew/tools/drc_tool.h +++ b/pcbnew/tools/drc_tool.h @@ -60,6 +60,8 @@ public: int ShowDRCDialog( const TOOL_EVENT& aEvent ); + DIALOG_DRC* GetDRCDialog() { return m_drcDialog; } + /** * Check to see if the DRC_TOOL dialog is currently shown */