From 32af91cf61b54780d779f44ea91dddba31d1bfc0 Mon Sep 17 00:00:00 2001 From: hemai Date: Wed, 17 Sep 2025 20:22:13 +0800 Subject: [PATCH] FIX: speed switch popup window display bug Jira: [STUDIO-14642] Change-Id: If95ca1b448b2d3a03c2f6d6c0b5faad4a3c04e8c (cherry picked from commit 08943207564c0256d5a5efea9440e55efb7ccea0) --- src/slic3r/GUI/StatusPanel.cpp | 3 +++ src/slic3r/GUI/Widgets/PopupWindow.cpp | 34 ++++++++++++++++++++++++++ src/slic3r/GUI/Widgets/PopupWindow.hpp | 14 ++++++++--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 3b61db735a..b7cb8ca1b7 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -4662,6 +4662,9 @@ void StatusPanel::on_switch_speed(wxCommandEvent &event) PopupWindow *popUp = new PopupWindow(nullptr); #else PopupWindow *popUp = new PopupWindow(m_switch_speed); +#endif +#ifdef __WXMSW__ + popUp->BindUnfocusEvent(); #endif popUp->SetBackgroundColour(StateColor::darkModeColorFor(0xeeeeee)); StepCtrl *step = new StepCtrl(popUp, wxID_ANY); diff --git a/src/slic3r/GUI/Widgets/PopupWindow.cpp b/src/slic3r/GUI/Widgets/PopupWindow.cpp index 9c99f6ecd7..a8412bcfc9 100644 --- a/src/slic3r/GUI/Widgets/PopupWindow.cpp +++ b/src/slic3r/GUI/Widgets/PopupWindow.cpp @@ -31,6 +31,11 @@ PopupWindow::~PopupWindow() #ifdef __WXGTK__ GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this); #endif +#ifdef __WXMSW__ + GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActivate, this); + GetTopParent(this)->Unbind(wxEVT_ICONIZE, &PopupWindow::topWindowIconize, this); + GetTopParent(this)->Unbind(wxEVT_SHOW, &PopupWindow::topWindowShow, this); +#endif } #ifdef __WXOSX__ @@ -84,3 +89,32 @@ void PopupWindow::topWindowActiavate(wxActivateEvent &event) if (!event.GetActive() && IsShown()) DismissAndNotify(); } #endif + +#ifdef __WXMSW__ +void PopupWindow::BindUnfocusEvent() +{ + GetTopParent(this)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActivate, this); + GetTopParent(this)->Bind(wxEVT_ICONIZE, &PopupWindow::topWindowIconize, this); + GetTopParent(this)->Bind(wxEVT_SHOW, &PopupWindow::topWindowShow, this); +} + +void PopupWindow::topWindowActivate(wxActivateEvent &event) +{ + if (!event.GetActive()) + Dismiss(); +} + +void PopupWindow::topWindowIconize(wxIconizeEvent &event) +{ + event.Skip(); + if (event.IsIconized()) + Dismiss(); +} + +void PopupWindow::topWindowShow(wxShowEvent &event) +{ + event.Skip(); + if (!event.IsShown()) + Dismiss(); +} +#endif diff --git a/src/slic3r/GUI/Widgets/PopupWindow.hpp b/src/slic3r/GUI/Widgets/PopupWindow.hpp index 706f804045..55231accce 100644 --- a/src/slic3r/GUI/Widgets/PopupWindow.hpp +++ b/src/slic3r/GUI/Widgets/PopupWindow.hpp @@ -2,6 +2,7 @@ #define slic3r_GUI_PopupWindow_hpp_ #include +#include class PopupWindow : public wxPopupTransientWindow { @@ -10,11 +11,12 @@ public: ~PopupWindow(); - PopupWindow(wxWindow *parent, int style = wxBORDER_NONE) - { Create(parent, style); } + PopupWindow(wxWindow *parent, int style = wxBORDER_NONE) { Create(parent, style); } bool Create(wxWindow *parent, int flags = wxBORDER_NONE); - +#ifdef __WXMSW__ + void BindUnfocusEvent(); +#endif private: #ifdef __WXOSX__ void OnMouseEvent2(wxMouseEvent &evt); @@ -24,6 +26,12 @@ private: #ifdef __WXGTK__ void topWindowActiavate(wxActivateEvent &event); #endif + +#ifdef __WXMSW__ + void topWindowActivate(wxActivateEvent &event); + void topWindowIconize(wxIconizeEvent &event); + void topWindowShow(wxShowEvent &event); +#endif }; #endif // !slic3r_GUI_PopupWindow_hpp_