Hackfix macOS to keep erc/drc on top

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14356
This commit is contained in:
Marek Roszko 2024-04-26 00:47:06 -04:00
parent 60d5780c1c
commit b22bc2737e
6 changed files with 32 additions and 3 deletions

View File

@ -80,6 +80,7 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
m_currentSchematic = &parent->Schematic(); m_currentSchematic = &parent->Schematic();
SetName( DIALOG_ERC_WINDOW_NAME ); // Set a window name to be able to find it SetName( DIALOG_ERC_WINDOW_NAME ); // Set a window name to be able to find it
KIPLATFORM::UI::SetFloatLevel( this );
EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_severities = settings->m_Appearance.erc_severities; m_severities = settings->m_Appearance.erc_severities;
@ -467,6 +468,8 @@ void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
m_ercRun = true; m_ercRun = true;
redrawDrawPanel(); redrawDrawPanel();
updateDisplayedCounts(); updateDisplayedCounts();
// set float level again, it can be lost due to window events during test run
KIPLATFORM::UI::SetFloatLevel( this );
} }

View File

@ -283,7 +283,7 @@ bool KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
} }
wxLogTrace( traceWayland, wxS( "*** Warp to %d %d failed ***" ), aX, aY ); wxLogTrace( traceWayland, wxS( "*** Warp to %d %d failed ***" ), aX, aY );
return false; return false;
} }
#endif #endif
@ -320,6 +320,11 @@ void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
{ {
} }
void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
{
}
// //
// **** Wayland hacks ahead **** // **** Wayland hacks ahead ****
// //
@ -602,6 +607,4 @@ wxPoint KIPLATFORM::UI::GetMousePosition()
{ {
return wxGetMousePosition(); return wxGetMousePosition();
} }
#endif #endif

View File

@ -172,6 +172,11 @@ namespace KIPLATFORM
* On Wayland, allows the cursor to freely move again after a drag (see `InfiniteDragPrepareWindow`). * On Wayland, allows the cursor to freely move again after a drag (see `InfiniteDragPrepareWindow`).
*/ */
void InfiniteDragReleaseWindow(); void InfiniteDragReleaseWindow();
/**
* Intended to set the floating window level in macOS on a window
*/
void SetFloatLevel( wxWindow* aWindow );
} }
} }

View File

@ -194,3 +194,8 @@ void KIPLATFORM::UI::InfiniteDragReleaseWindow()
{ {
// Not needed on this platform // Not needed on this platform
} }
void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
{
}

View File

@ -194,3 +194,10 @@ void KIPLATFORM::UI::InfiniteDragReleaseWindow()
{ {
// Not needed on this platform // Not needed on this platform
} }
void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
{
// On OSX we need to forcefully give the focus to the window
[[aWindow->GetHandle() window] setLevel:NSFloatingWindowLevel];
}

View File

@ -78,6 +78,7 @@ DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
m_lastUpdateUi( std::chrono::steady_clock::now() ) m_lastUpdateUi( std::chrono::steady_clock::now() )
{ {
SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
KIPLATFORM::UI::SetFloatLevel( this );
m_frame = aEditorFrame; m_frame = aEditorFrame;
m_currentBoard = m_frame->GetBoard(); m_currentBoard = m_frame->GetBoard();
@ -293,6 +294,9 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
m_messages->Flush(); m_messages->Flush();
Raise(); Raise();
// set float level again, it can be lost due to window events during test run
KIPLATFORM::UI::SetFloatLevel( this );
return; return;
} }
@ -363,6 +367,8 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
m_sdbSizerOK->Enable( true ); m_sdbSizerOK->Enable( true );
} }
// set float level again, it can be lost due to window events during test run
KIPLATFORM::UI::SetFloatLevel( this );
refreshEditor(); refreshEditor();
} }