From 20f5b7a7cd79c8797c6cb12c41ecf767e0258e28 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 15 Dec 2020 15:14:59 +0100 Subject: [PATCH] When activating the PrusaSlicer main window, focus the Plater 3D view or G-code preview if it is marked as Active. Fixes 3Dconnexion not work directly after importing stl (focus problem ?) #5141 Keep your fingers crossed that it will not break something else. --- src/slic3r/GUI/Plater.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index fca933fa70..beb503ef30 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5865,15 +5865,14 @@ void Plater::force_print_bed_update() void Plater::on_activate() { -#ifdef __linux__ +#if defined(__linux__) || defined(_WIN32) wxWindow *focus_window = wxWindow::FindFocus(); // 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(); + if (this->p->view3D->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas()) + CallAfter([this]() { this->p->view3D->get_wxglcanvas()->SetFocus(); }); + else if (this->p->preview->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas()) + CallAfter([this]() { this->p->preview->get_wxglcanvas()->SetFocus(); }); #endif this->p->show_delayed_error_message();