Implement browser window resizing correctly under Mac too
While the window was somehow resized on its own under Mac (and only there) after the initial creation, it didn't have the correct size initially if we didn't give it to it, so provide a Mac-specific implementation of wxEVT_SIZE handler too, which fixes this and allows to remove an ugly Mac-specific workaround from the sample.
This commit is contained in:
parent
0dffac1829
commit
7aec5a7e62
4 changed files with 20 additions and 11 deletions
|
|
@ -10,7 +10,16 @@
|
|||
#ifndef _WX_OSX_PRIVATE_WEBVIEW_CHROMIUM_H_
|
||||
#define _WX_OSX_PRIVATE_WEBVIEW_CHROMIUM_H_
|
||||
|
||||
wxGCC_WARNING_SUPPRESS(unused-parameter)
|
||||
|
||||
#include "include/cef_base.h"
|
||||
|
||||
wxGCC_WARNING_RESTORE(unused-parameter)
|
||||
|
||||
// Called during startup to add CefAppProtocol support to wxNSApplication.
|
||||
void wxWebViewChromium_InitOSX();
|
||||
|
||||
// Called to resize the given NSView to fit its parent.
|
||||
void wxWebViewChromium_Resize(cef_window_handle_t handle, wxSize size);
|
||||
|
||||
#endif // _WX_OSX_PRIVATE_WEBVIEW_CHROMIUM_H_
|
||||
|
|
|
|||
|
|
@ -460,14 +460,7 @@ WebFrame::WebFrame(const wxString& url, bool isMain, wxWebViewWindowFeatures* wi
|
|||
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new AdvancedWebViewHandler()));
|
||||
}
|
||||
#endif
|
||||
if ( !m_browser->Create(this, wxID_ANY, url, wxDefaultPosition,
|
||||
#if defined(wxWEBVIEW_SAMPLE_CHROMIUM) && defined(__WXOSX__)
|
||||
// OSX implementation currently cannot handle the default size
|
||||
wxSize(800, 600)
|
||||
#else
|
||||
wxDefaultSize
|
||||
#endif
|
||||
) )
|
||||
if ( !m_browser->Create(this, wxID_ANY, url) )
|
||||
{
|
||||
wxLogFatalError("Failed to create wxWebView");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -614,8 +614,6 @@ void wxWebViewChromium::OnSize(wxSizeEvent& event)
|
|||
{
|
||||
event.Skip();
|
||||
|
||||
// Under Mac we don't have to do anything to resize the browser window.
|
||||
#ifndef __WXOSX__
|
||||
const auto handle = m_clientHandler ? m_clientHandler->GetWindowHandle() : 0;
|
||||
if ( !handle )
|
||||
return;
|
||||
|
|
@ -629,8 +627,9 @@ void wxWebViewChromium::OnSize(wxSizeEvent& event)
|
|||
size *= GetDPIScaleFactor();
|
||||
|
||||
::XResizeWindow(wxGetX11Display(), handle, size.x, size.y);
|
||||
#elif defined(__WXOSX__)
|
||||
wxWebViewChromium_Resize(handle, size);
|
||||
#endif
|
||||
#endif // !__WXOSX__
|
||||
}
|
||||
|
||||
void wxWebViewChromium::SetPageSource(const wxString& pageSource)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <objc/runtime.h>
|
||||
#include "wx/log.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/private/webview_chromium.h"
|
||||
|
||||
#import "include/cef_application_mac.h"
|
||||
|
|
@ -75,3 +76,10 @@ void wxWebViewChromium_InitOSX()
|
|||
wxLogError("Could not add setHandlingSendEvent impl");
|
||||
}
|
||||
}
|
||||
|
||||
void wxWebViewChromium_Resize(cef_window_handle_t handle, wxSize size)
|
||||
{
|
||||
auto const view = static_cast<NSView*>(handle);
|
||||
|
||||
[view setFrame:wxToNSRect([view superview], size)];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue