Skip to content

Commit

Permalink
Fix for #888
Browse files Browse the repository at this point in the history
The CallAfter() on Linux causes weird window focus issues.

For me, using ALT-Tab to switch away from PrusaSlicer/SuperSlicer would cause
PrusaSlicer/SuperSlicer to take back focus after about one second.  Stranger
things reportedly occur with focus-follows-mouse.

The #ifdef is there because it is assumed the CallAfter() was added
in 20f5b7a for a good reason.
  • Loading branch information
RealDeuce authored and supermerill committed Sep 6, 2021
1 parent 1a94ea2 commit b1eef1f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/slic3r/GUI/Plater.cpp
Expand Up @@ -6115,9 +6115,14 @@ void Plater::force_print_bed_update()

void Plater::on_activate()
{
#if defined(__linux__) || defined(_WIN32)
// Activating the main frame, and no window has keyboard focus.
// Set the keyboard focus to the visible Canvas3D.
#if defined(__linux__)
if (this->p->view3D->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas())
this->p->view3D->get_wxglcanvas()->SetFocus();
else if (this->p->preview->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas())
this->p->preview->get_wxglcanvas()->SetFocus();
#elif defined(_WIN32)
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())
Expand Down

0 comments on commit b1eef1f

Please sign in to comment.