From b7a92b5525c63be6d99879b8d3a941c1242a7633 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 2 Jan 2019 17:49:23 +0100 Subject: [PATCH] Fix of #1512 "Printer Host Upload Queue vanishes in the background [1.42.0-alpha1]" the canvas3d used to grab focus when mouse entered a window even if the top level window was not active. This was now changed and the top level must be active for the canvas3d to grab the focus. --- src/slic3r/GUI/GLCanvas3D.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1d6c3b1175..df70a787e7 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4906,8 +4906,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { #if defined(__WXMSW__) || defined(__linux__) // On Windows and Linux needs focus in order to catch key events - if (m_canvas != nullptr) - m_canvas->SetFocus(); + if (m_canvas != nullptr) { + // Only set focus, if the top level window of this canvas is active. + auto p = dynamic_cast(evt.GetEventObject()); + while (p->GetParent()) + p = p->GetParent(); + auto *top_level_wnd = dynamic_cast(p); + if (top_level_wnd && top_level_wnd->IsActive()) + m_canvas->SetFocus(); + } m_mouse.set_start_position_2D_as_invalid(); #endif