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 aea70a14ff
commit 7e04a1b8d3
6 changed files with 32 additions and 1 deletions

View File

@ -79,6 +79,7 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
m_currentSchematic = &parent->Schematic();
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() );
m_severities = settings->m_Appearance.erc_severities;
@ -466,6 +467,8 @@ void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
m_ercRun = true;
redrawDrawPanel();
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 );
return false;
}
#endif
@ -314,6 +314,11 @@ void KIPLATFORM::UI::ImmControl( wxWindow* aWindow, bool aEnable )
{
}
void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
{
}
//
// **** Wayland hacks ahead ****
//

View File

@ -172,6 +172,11 @@ namespace KIPLATFORM
* On Wayland, allows the cursor to freely move again after a drag (see `InfiniteDragPrepareWindow`).
*/
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
}
void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow )
{
}

View File

@ -194,3 +194,10 @@ void KIPLATFORM::UI::InfiniteDragReleaseWindow()
{
// 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

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