Keep the IP and access code dialog inside the display work area (#17763)

InputIpAddressDialog centers itself on the main frame and then moves up by
50 DIP, with nothing clamping the result to the display. wxWidgets pulls a
centered window back onto the display, but for a window taller than the work
area its last step is to bring the bottom edge into view, which leaves the top
off screen. The 50 DIP shift then adds to that. At 350% display scaling it is
175 physical pixels, so the title bar, the first line and step 1 all end up
above the top edge, as reported in #17749. The dialog has no resize border and
the title bar is the part that goes off screen, so it cannot be dragged back
into view either.

Clamp the final position to the work area of the display the dialog was
centered on. The clamp moves the dialog only when it would fall outside the
work area, so one that already fits keeps its exact position and size. Every
later Layout() and Fit() in this dialog preserves its top left corner, so
clamping once after it is positioned is enough to keep the title bar reachable.
This commit is contained in:
Kris Austin authored and GitHub committed 2026-11-23 08:39:31 -06:00
1 parent aefb6b3d66
commit 8474bc9e2d
2 files changed
+19

No files matched your search

+18
View File
@@ -32,6 +32,7 @@
#include <md4c/src/md4c.h>
#include <wx/image.h>
#include <wx/datetime.h>
#include <wx/display.h>
#include <utility>
#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();
+1
View File
@@ -353,6 +353,7 @@ public:
std::map<std::string, std::string> 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);