Refactor window position & size persistence
in a way that is hopefully robust wrt. platform quirks
This commit is contained in:
parent
2e274b5646
commit
d4371b6089
6 changed files with 153 additions and 51 deletions
src/slic3r/GUI
|
@ -78,8 +78,6 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
|
|||
Fit();
|
||||
SetMinSize(wxSize(760, 490));
|
||||
SetSize(GetMinSize());
|
||||
wxGetApp().restore_window_pos(this, "main_frame");
|
||||
Show();
|
||||
Layout();
|
||||
|
||||
// declare events
|
||||
|
@ -89,7 +87,7 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
|
|||
return;
|
||||
}
|
||||
// save window size
|
||||
wxGetApp().save_window_pos(this, "main_frame");
|
||||
wxGetApp().window_pos_save(this, "mainframe");
|
||||
// Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
|
||||
// but in rare cases it may not have been called yet.
|
||||
wxGetApp().app_config->save();
|
||||
|
@ -101,6 +99,17 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
|
|||
event.Skip();
|
||||
});
|
||||
|
||||
// NB: Restoring the window position is done in a two-phase manner here,
|
||||
// first the saved position is restored as-is and validation is done after the window is shown
|
||||
// and initial round of events is complete, because on some platforms that is the only way
|
||||
// to get an accurate window position & size.
|
||||
wxGetApp().window_pos_restore(this, "mainframe");
|
||||
Bind(wxEVT_SHOW, [this](wxShowEvent&) {
|
||||
CallAfter([this]() {
|
||||
wxGetApp().window_pos_sanitize(this);
|
||||
});
|
||||
});
|
||||
|
||||
update_ui_from_settings();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue