Implement availability check for wxWebviewChromium under GTK

Return false when using Wayland as the backend creation can only fail in
this case.
This commit is contained in:
Vadim Zeitlin 2023-09-14 19:11:29 +02:00
parent 9c30f459f8
commit 05a8dfa555
2 changed files with 14 additions and 1 deletions

View file

@ -82,7 +82,9 @@
gdk_set_allowed_backends("x11")
@endcode
in your application code.
in your application code, otherwise wxWebView::IsBackendAvailable() will
return @false when the application is running under Wayland and creating
wxWebviewChromium will fail in this case.
Moreover, the actual browser is only created once the window is shown, and
can't be used until then. You can bind an event handler for wxEVT_CREATE to

View file

@ -1464,6 +1464,17 @@ public:
long style = 0,
const wxString& name = wxWebViewNameStr) override
{ return new wxWebViewChromium(parent, id, url, pos, size, style, name); }
virtual bool IsAvailable() override
{
#ifdef __WXGTK__
// Currently CEF works only with X11.
if ( wxGetDisplayInfo().type != wxDisplayX11 )
return false;
#endif // __WXGTK__
return true;
}
};
class wxWebViewChromiumModule : public wxModule