From d7e14d079249f966c8f73c16ecd710f977a53ed5 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 19 Feb 2019 15:54:43 +0100 Subject: [PATCH] Ensuring that GLCanvas gets focus when it should (Linux only fix) --- src/slic3r/GUI/Plater.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 8e32288239..42c5224a6f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3110,15 +3110,17 @@ void Plater::on_config_change(const DynamicPrintConfig &config) void Plater::on_activate() { +#ifdef __linux__ wxWindow *focus_window = wxWindow::FindFocus(); - if (focus_window == nullptr) { - // Activating the main frame, and no window has keyboard focus. - // Set the keyboard focus to the visible Canvas3D. - if (this->p->view3D->IsShown()) - this->p->view3D->get_wxglcanvas()->SetFocus(); - else if (this->p->preview->IsShown()) - this->p->preview->get_wxglcanvas()->SetFocus(); - } + // Activating the main frame, and no window has keyboard focus. + // Set the keyboard focus to the visible Canvas3D. + if (this->p->view3D->IsShown() && (!focus_window || focus_window == this->p->view3D->get_wxglcanvas())) + this->p->view3D->get_wxglcanvas()->SetFocus(); + + else if (this->p->preview->IsShown() && (!focus_window || focus_window == this->p->view3D->get_wxglcanvas())) + this->p->preview->get_wxglcanvas()->SetFocus(); +#endif + if (! this->p->delayed_error_message.empty()) { std::string msg = std::move(this->p->delayed_error_message); this->p->delayed_error_message.clear();