From bdc18f68b6634d66f4b3e7dbbf18f9c868ad259f Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 28 Nov 2020 16:56:10 +0100 Subject: [PATCH] Update wxHtmlWindow on DPI change This is not ideal, as resetting the page contents loses the current selection and redoes a lot of work that could be avoided, but it's (much) better than nothing, as it fixes the window appearance after e.g. moving it to another monitor. Closes #18564. --- include/wx/html/htmlwin.h | 1 + src/html/htmlwin.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index 8c98c3d030..aabb574f70 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -405,6 +405,7 @@ protected: void OnPaint(wxPaintEvent& event); void OnEraseBackground(wxEraseEvent& event); void OnSize(wxSizeEvent& event); + void OnDPIChanged(wxDPIChangedEvent& event); void OnMouseMove(wxMouseEvent& event); void OnMouseDown(wxMouseEvent& event); void OnMouseUp(wxMouseEvent& event); diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index 94f23dfa7c..fe3760b61b 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -1319,6 +1319,10 @@ void wxHtmlWindow::OnSize(wxSizeEvent& event) Refresh(); } +void wxHtmlWindow::OnDPIChanged(wxDPIChangedEvent& WXUNUSED(event)) +{ + DoSetPage(*(m_Parser->GetSource())); +} void wxHtmlWindow::OnMouseMove(wxMouseEvent& WXUNUSED(event)) { @@ -1761,6 +1765,7 @@ wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxHtmlWindow, wxScrolledWindow, "wx/html/htmlwin.h wxBEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow) EVT_SIZE(wxHtmlWindow::OnSize) + EVT_DPI_CHANGED(wxHtmlWindow::OnDPIChanged) EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown) EVT_LEFT_UP(wxHtmlWindow::OnMouseUp) EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp)