FIX: [STUDIO-2186] hide PopupWindow on alt-tab

Change-Id: Ie1bffdd9ace2c6e05979743da9f75ca2c1e87cf3
This commit is contained in:
chunmao.guo 2023-02-13 14:06:39 +08:00 committed by Lane.Wei
parent 6faecbf718
commit 81dea77932
23 changed files with 139 additions and 70 deletions

View file

@ -5,7 +5,7 @@
wxDEFINE_EVENT(EVT_DISMISS, wxCommandEvent);
BEGIN_EVENT_TABLE(DropDown, wxPopupTransientWindow)
BEGIN_EVENT_TABLE(DropDown, PopupWindow)
EVT_LEFT_DOWN(DropDown::mouseDown)
EVT_LEFT_UP(DropDown::mouseReleased)
@ -50,7 +50,7 @@ DropDown::DropDown(wxWindow * parent,
void DropDown::Create(wxWindow * parent,
long style)
{
wxPopupTransientWindow::Create(parent, wxPU_CONTAINS_CONTROLS);
PopupWindow::Create(parent, wxPU_CONTAINS_CONTROLS);
SetBackgroundStyle(wxBG_STYLE_PAINT);
SetBackgroundColour(*wxWHITE);
state_handler.attach({&border_color, &text_color, &selector_border_color, &selector_background_color});
@ -62,7 +62,7 @@ void DropDown::Create(wxWindow * parent,
// BBS set default font
SetFont(Label::Body_14);
#ifdef __WXOSX__
// wxPopupTransientWindow releases mouse on idle, which may cause various problems,
// PopupWindow releases mouse on idle, which may cause various problems,
// such as losting mouse move, and dismissing soon on first LEFT_DOWN event.
Bind(wxEVT_IDLE, [] (wxIdleEvent & evt) {});
#endif

View file

@ -4,6 +4,7 @@
#include <wx/stattext.h>
#include "../wxExtensions.hpp"
#include "StateHandler.hpp"
#include "PopupWindow.hpp"
#define DD_NO_CHECK_ICON 0x0001
#define DD_NO_TEXT 0x0002
@ -11,7 +12,7 @@
wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
class DropDown : public wxPopupTransientWindow
class DropDown : public PopupWindow
{
std::vector<wxString> & texts;
std::vector<wxBitmap> & icons;

View file

@ -499,7 +499,7 @@ void FanControl::post_event(wxCommandEvent&& event)
Description:FanControlPopup
**************************************************/
FanControlPopup::FanControlPopup(wxWindow* parent)
:wxPopupTransientWindow(parent, wxBORDER_NONE)
:PopupWindow(parent, wxBORDER_NONE)
{
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
@ -628,7 +628,7 @@ void FanControlPopup::post_event(int fan_type, wxString speed)
bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event)
{
return wxPopupTransientWindow::ProcessLeftDown(event);
return PopupWindow::ProcessLeftDown(event);
}
void FanControlPopup::on_show(wxShowEvent& evt)

View file

@ -5,6 +5,7 @@
#include "StaticBox.hpp"
#include "StepCtrl.hpp"
#include "Button.hpp"
#include "PopupWindow.hpp"
#include "../DeviceManager.hpp"
#include "slic3r/GUI/Event.hpp"
#include <wx/simplebook.h>
@ -137,7 +138,7 @@ public:
/*************************************************
Description:FanControlPopup
**************************************************/
class FanControlPopup : public wxPopupTransientWindow
class FanControlPopup : public PopupWindow
{
public:
FanControlPopup(wxWindow* parent);

View file

@ -0,0 +1,33 @@
#include "PopupWindow.hpp"
static wxWindow *GetTopParent(wxWindow *pWindow)
{
wxWindow *pWin = pWindow;
while (pWin->GetParent()) pWin = pWin->GetParent();
return pWin;
}
bool PopupWindow::Create(wxWindow *parent, int style)
{
if (!wxPopupTransientWindow::Create(parent, style))
return false;
#ifdef __WXGTK__
GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
#endif
return true;
}
PopupWindow::~PopupWindow()
{
#ifdef __WXGTK__
GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
#endif
}
#ifdef __WXGTK__
void PopupWindow::topWindowActiavate(wxActivateEvent &event)
{
event.Skip();
if (!event.GetActive() && IsShown()) DismissAndNotify();
}
#endif

View file

@ -0,0 +1,24 @@
#ifndef slic3r_GUI_PopupWindow_hpp_
#define slic3r_GUI_PopupWindow_hpp_
#include <wx/popupwin.h>
class PopupWindow : public wxPopupTransientWindow
{
public:
PopupWindow() {}
~PopupWindow();
PopupWindow(wxWindow *parent, int style = wxBORDER_NONE)
{ Create(parent, style); }
bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
private:
#ifdef __WXGTK__
void topWindowActiavate(wxActivateEvent &event);
#endif
};
#endif // !slic3r_GUI_PopupWindow_hpp_

View file

@ -6,12 +6,12 @@
wxBEGIN_EVENT_TABLE(SidePopup,wxPopupTransientWindow)
wxBEGIN_EVENT_TABLE(SidePopup,PopupWindow)
EVT_PAINT(SidePopup::paintEvent)
wxEND_EVENT_TABLE()
SidePopup::SidePopup(wxWindow* parent)
:wxPopupTransientWindow(parent,
:PopupWindow(parent,
wxBORDER_NONE |
wxPU_CONTAINS_CONTROLS)
{
@ -28,16 +28,16 @@ SidePopup::~SidePopup()
void SidePopup::OnDismiss()
{
Slic3r::GUI::wxGetApp().set_side_menu_popup_status(false);
wxPopupTransientWindow::OnDismiss();
PopupWindow::OnDismiss();
}
bool SidePopup::ProcessLeftDown(wxMouseEvent& event)
{
return wxPopupTransientWindow::ProcessLeftDown(event);
return PopupWindow::ProcessLeftDown(event);
}
bool SidePopup::Show( bool show )
{
return wxPopupTransientWindow::Show(show);
return PopupWindow::Show(show);
}
void SidePopup::Popup(wxWindow* focus)
@ -66,7 +66,7 @@ void SidePopup::Popup(wxWindow* focus)
Position(pos, {0, focus->GetSize().y + 12});
}
Slic3r::GUI::wxGetApp().set_side_menu_popup_status(true);
wxPopupTransientWindow::Popup();
PopupWindow::Popup();
}
void SidePopup::Create()

View file

@ -9,8 +9,9 @@
#include "../wxExtensions.hpp"
#include "StateHandler.hpp"
#include "SideButton.hpp"
#include "PopupWindow.hpp"
class SidePopup : public wxPopupTransientWindow
class SidePopup : public PopupWindow
{
private:
std::vector<SideButton*> btn_list;

View file

@ -1,5 +1,6 @@
#include "TempInput.hpp"
#include "Label.hpp"
#include "PopupWindow.hpp"
#include "../I18N.hpp"
#include <wx/dcgraph.h>
#include "../GUI.hpp"
@ -190,7 +191,7 @@ void TempInput::Warning(bool warn, WarningType type)
if (warning_mode) {
if (wdialog == nullptr) {
wdialog = new wxPopupTransientWindow(this);
wdialog = new PopupWindow(this);
wdialog->SetBackgroundColour(wxColour(0xFFFFFF));
wdialog->SetSizeHints(wxDefaultSize, wxDefaultSize);