From 2d9c08e0cc505a0a4cae9758fc619086fbf4d4e8 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Thu, 5 Nov 2020 09:27:20 +0100 Subject: [PATCH] WebViewEdge: Forward window visibility to SDK Tell the SDK controller if the control is shown or hidden. This allows creating a hidden webview which will be shown later and might fix other potential issues. --- include/wx/msw/webview_edge.h | 2 ++ src/msw/webview_edge.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/wx/msw/webview_edge.h b/include/wx/msw/webview_edge.h index f969566b33..4b5b4aa410 100644 --- a/include/wx/msw/webview_edge.h +++ b/include/wx/msw/webview_edge.h @@ -134,6 +134,8 @@ private: void OnSize(wxSizeEvent& event); + void OnShow(wxShowEvent& event); + bool RunScriptSync(const wxString& javascript, wxString* output = NULL); wxDECLARE_DYNAMIC_CLASS(wxWebViewEdge); diff --git a/src/msw/webview_edge.cpp b/src/msw/webview_edge.cpp index b741a450b5..6dc1fd3957 100644 --- a/src/msw/webview_edge.cpp +++ b/src/msw/webview_edge.cpp @@ -364,6 +364,7 @@ bool wxWebViewEdge::IsAvailable() wxWebViewEdge::~wxWebViewEdge() { + Unbind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this); delete m_impl; } @@ -388,6 +389,7 @@ bool wxWebViewEdge::Create(wxWindow* parent, if (!m_impl->Create()) return false; Bind(wxEVT_SIZE, &wxWebViewEdge::OnSize, this); + Bind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this); LoadURL(url); return true; @@ -399,6 +401,13 @@ void wxWebViewEdge::OnSize(wxSizeEvent& event) event.Skip(); } +void wxWebViewEdge::OnShow(wxShowEvent& event) +{ + if (m_impl->m_webView) + m_impl->m_webViewController->put_IsVisible(event.IsShown()); + event.Skip(); +} + void wxWebViewEdge::LoadURL(const wxString& url) { if (!m_impl->m_webView)