diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 98ed958a26..f3ae36ea20 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "slic3r/GUI/Widgets/AMSItem.hpp" #include "slic3r/GUI/Widgets/TextInput.hpp" @@ -1730,6 +1731,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) CentreOnParent(wxBOTH); Move(wxPoint(GetScreenPosition().x, GetScreenPosition().y - FromDIP(50))); + clamp_to_work_area(); wxGetApp().UpdateDlgDarkUI(this); closeTimer = new wxTimer(); @@ -1757,6 +1759,22 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) }); } +void InputIpAddressDialog::clamp_to_work_area() +{ + // CentreOnParent picks the display from the parent, so the clamp has to use the same one. + const wxRect work_area = wxDisplay(GetParent() ? GetParent() : this).GetClientArea(); + const wxSize size = GetSize(); + const wxPoint pos = GetScreenPosition(); + + wxPoint clamped = pos; + // std::max runs last, so a dialog bigger than the work area keeps its top left corner, and its title bar, on screen. + clamped.x = std::max(work_area.x, std::min(clamped.x, work_area.x + work_area.width - size.x)); + clamped.y = std::max(work_area.y, std::min(clamped.y, work_area.y + work_area.height - size.y)); + + if (clamped != pos) + Move(clamped); +} + void InputIpAddressDialog::switch_input_panel(int index) { m_button_manual_setup->Hide(); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index f78bcc274a..f32d5f8535 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -353,6 +353,7 @@ public: std::map m_models_map;// display_name -> model_id void switch_input_panel(int index); + void clamp_to_work_area(); void on_cancel(); void update_title(wxString title); void set_machine_obj(MachineObject* obj);