7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

ShowModal: override method in DIALOG_SHIM

All DIALOG_SHIM dialogues which should be modal, has a problem on OSX
that parent could be lost. So call ReparentModal to fix this before
calling the base ShowModal method. This should fix the problem when
modal window has been hidden when windows were switched.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/3765

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/17460
This commit is contained in:
Andrej Valek 2024-10-27 16:37:47 +00:00 committed by Seth Hillbrand
parent 9231516238
commit 3ad92bc8db
8 changed files with 21 additions and 8 deletions
common
include
libs/kiplatform
include/kiplatform
port
wxgtk
wxmsw
wxosx
pcbnew

View File

@ -471,6 +471,17 @@ void DIALOG_SHIM::ClearModify()
SetTitle( GetTitle().AfterFirst( '*' ) );
}
int DIALOG_SHIM::ShowModal()
{
// Apple in its infinite wisdom will raise a disabled window before even passing
// us the event, so we have no way to stop it. Instead, we must set an order on
// the windows so that the modal will be pushed in front of the disabled
// window when it is raised.
KIPLATFORM::UI::ReparentModal( this );
// Call the base class ShowModal() method
return wxDialog::ShowModal();
}
/*
Quasi-Modal Mode Explained:
@ -527,7 +538,7 @@ int DIALOG_SHIM::ShowQuasiModal()
// us the event, so we have no way to stop it. Instead, we must set an order on
// the windows so that the quasi-modal will be pushed in front of the disabled
// window when it is raised.
KIPLATFORM::UI::ReparentQuasiModal( this );
KIPLATFORM::UI::ReparentModal( this );
Show( true );

View File

@ -104,6 +104,8 @@ public:
m_initialFocusTarget = aWindow;
}
int ShowModal() override;
int ShowQuasiModal(); // disable only the parent window, otherwise modal.
void EndQuasiModal( int retCode ); // End quasi-modal mode

View File

@ -69,7 +69,7 @@ namespace KIPLATFORM
*
* @param aWindow is the window to reparent
*/
void ReparentQuasiModal( wxNonOwnedWindow* aWindow );
void ReparentModal( wxNonOwnedWindow* aWindow );
/*
* An ugly hack to fix an issue on OSX: cmd+c closes the dialog instead of copying the

View File

@ -85,7 +85,7 @@ bool KIPLATFORM::UI::IsWindowActive( wxWindow* aWindow )
}
void KIPLATFORM::UI::ReparentQuasiModal( wxNonOwnedWindow* aWindow )
void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
{
// Not needed on this platform
}

View File

@ -90,7 +90,7 @@ bool KIPLATFORM::UI::IsWindowActive( wxWindow* aWindow )
}
void KIPLATFORM::UI::ReparentQuasiModal( wxNonOwnedWindow* aWindow )
void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
{
// Not needed on this platform
}

View File

@ -76,12 +76,12 @@ bool KIPLATFORM::UI::IsWindowActive( wxWindow* aWindow )
}
void KIPLATFORM::UI::ReparentQuasiModal( wxNonOwnedWindow* aWindow )
void KIPLATFORM::UI::ReparentModal( wxNonOwnedWindow* aWindow )
{
wxTopLevelWindow* parent =
static_cast<wxTopLevelWindow*>( wxGetTopLevelParent( aWindow->GetParent() ) );
wxASSERT_MSG(parent, wxT( "QuasiModal windows require a parent.") );
wxASSERT_MSG(parent, wxT( "Modal windows require a parent.") );
NSWindow* parentWindow = parent->GetWXWindow();
NSWindow* theWindow = aWindow->GetWXWindow();

View File

@ -257,7 +257,7 @@ void FOOTPRINT_CHOOSER_FRAME::Show3DViewerFrame()
EDA_3D_VIEWER_FRAME* draw3DFrame = CreateAndShow3D_Frame();
// A stronger version of Raise() which promotes the window to its parent's level.
KIPLATFORM::UI::ReparentQuasiModal( draw3DFrame );
KIPLATFORM::UI::ReparentModal( draw3DFrame );
// And load or update the current board (if needed)
if( do_reload_board )

View File

@ -80,7 +80,7 @@ int PCB_VIEWER_TOOLS::Show3DViewer( const TOOL_EVENT& aEvent )
|| frame()->IsType( FRAME_FOOTPRINT_WIZARD ) )
{
// A stronger version of Raise() which promotes the window to its parent's level.
KIPLATFORM::UI::ReparentQuasiModal( draw3DFrame );
KIPLATFORM::UI::ReparentModal( draw3DFrame );
}
// And load or update the current board (if needed)