Center DIALOG_SHIM position if it would have appeared off the screen

DIALOG_SHIM stores the dialog position, so every time it is shown, it is
displayed in the same location. This caused problems on multidisplay
setups, as dialogs could show up off the screen if the original display
has been detached in the meantime, effectively making them inaccesible
to the user.

Fixes: lp:1756623
* https://bugs.launchpad.net/kicad/+bug/1756623
This commit is contained in:
Maciej Suminski 2018-03-20 00:02:22 +01:00
parent 620c2af356
commit b40bf4c0ea
1 changed files with 7 additions and 1 deletions

View File

@ -27,7 +27,7 @@
#include <wx/evtloop.h>
#include <pgm_base.h>
#include <eda_rect.h>
#include <wx/display.h>
/// Toggle a window's "enable" status to disabled, then enabled on destruction.
class WDO_ENABLE_DISABLE
@ -178,6 +178,12 @@ bool DIALOG_SHIM::Show( bool show )
std::max( wxDialog::GetSize().y, savedDialogRect.GetSize().y ),
0 );
}
// Be sure that the dialog appears in a visible area
// (the dialog position might have been stored at the time when it was
// shown on another display)
if( wxDisplay::GetFromWindow( this ) == wxNOT_FOUND )
Centre();
}
else
{