diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index e6b773404d..38a5f33875 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -352,22 +352,6 @@ void GUI_App::persist_window_geometry(wxTopLevelWindow *window) window_pos_restore(window, name); -// #ifdef _WIN32 -// // On windows, the wxEVT_SHOW is not received if the window is created maximized -// // cf. https://groups.google.com/forum/#!topic/wx-users/c7ntMt6piRI -// // so we sanitize the position right away -// window_pos_sanitize(window); -// #else -// // On other platforms on the other hand it's needed to wait before the window is actually on screen -// // and some initial round of events is complete otherwise position / display index is not reported correctly. -// window->Bind(wxEVT_SHOW, [=](wxShowEvent &event) { -// CallAfter([=]() { -// window_pos_sanitize(window); -// }); -// event.Skip(); -// }); -// #endif - on_window_geometry(window, [=]() { window_pos_sanitize(window); }); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index c1a3934b91..56d6eaeb58 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -28,18 +28,24 @@ wxTopLevelWindow* find_toplevel_parent(wxWindow *window) void on_window_geometry(wxTopLevelWindow *tlw, std::function callback) { - tlw->Bind(wxEVT_CREATE, [=](wxWindowCreateEvent &event) { -#ifdef __linux__ - // On Linux, the geometry is only available after wxEVT_CREATE + CallAfter +#ifdef _WIN32 + // On windows, the wxEVT_SHOW is not received if the window is created maximized + // cf. https://groups.google.com/forum/#!topic/wx-users/c7ntMt6piRI + // OTOH the geometry is available very soon, so we can call the callback right away + callback(); +#elif defined __linux__ + tlw->Bind(wxEVT_SHOW, [=](wxShowEvent &evt) { + // On Linux, the geometry is only available after wxEVT_SHOW + CallAfter // cf. https://groups.google.com/forum/?pli=1#!topic/wx-users/fERSXdpVwAI - tlw->CallAfter([=]() { -#endif - callback(); -#ifdef __linux__ - }); -#endif - event.Skip(); + tlw->CallAfter([=]() { callback(); }); + evt.Skip(); }); +#elif defined __APPLE__ + tlw->Bind(wxEVT_SHOW, [=](wxShowEvent &evt) { + callback(); + evt.Skip(); + }); +#endif }