From 7e04a1b8d313914cc70c587b8a522e425d298a29 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Fri, 26 Apr 2024 00:47:06 -0400 Subject: [PATCH] Hackfix macOS to keep erc/drc on top Fixes https://gitlab.com/kicad/code/kicad/-/issues/14356 --- eeschema/dialogs/dialog_erc.cpp | 3 +++ libs/kiplatform/gtk/ui.cpp | 7 ++++++- libs/kiplatform/include/kiplatform/ui.h | 5 +++++ libs/kiplatform/msw/ui.cpp | 5 +++++ libs/kiplatform/osx/ui.mm | 7 +++++++ pcbnew/dialogs/dialog_drc.cpp | 6 ++++++ 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 724c88da24..7beb985301 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -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( 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 ); } diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index 3a1915b28d..ab4c092c23 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -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 **** // diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index 9126c6ab91..9341b097c5 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -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 ); } } diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 5b2cced663..a376b46b9b 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -194,3 +194,8 @@ void KIPLATFORM::UI::InfiniteDragReleaseWindow() { // Not needed on this platform } + + +void KIPLATFORM::UI::SetFloatLevel( wxWindow* aWindow ) +{ +} \ No newline at end of file diff --git a/libs/kiplatform/osx/ui.mm b/libs/kiplatform/osx/ui.mm index 1aeb8360ef..61af484f21 100644 --- a/libs/kiplatform/osx/ui.mm +++ b/libs/kiplatform/osx/ui.mm @@ -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]; +} \ No newline at end of file diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index ecf1ac80e1..0f572707e9 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -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(); }