From c05cdf801935665f175394d54a052f08e29196b5 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 8 Feb 2019 12:10:39 +0100 Subject: [PATCH] Fix window geometry shenanigans --- xs/src/slic3r/GUI/GUI.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index ce6d2735e7..2b672dff4c 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -1042,18 +1042,24 @@ void restore_window_size(wxTopLevelWindow *window, const std::string &name) 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 } void about()