[GSoC] How to host a CEF browser window in wxwidgets window on Linux?

463 views
Skip to first unread message

Haojian Wu

unread,
Jun 6, 2014, 10:46:24 AM6/6/14
to wx-...@googlegroups.com, Steven Lamerton
Hello wxwidgets-dev,

I'm porting webviewChromium to linux. Now I can build the sample successfully and it can runs without host the cef window in wxwidgets windows.

However, there is a UI-specific issue, I don't know how to host a CEF browser window in wxWidgets windows.

CEF3 provides a CefWindowInfo to set cef browser window as child window, and it works fine on Windows, see the below code:


bool wxWebViewChromium::Create(wxWindow* parent,
           wxWindowID id,
           const wxString& url,
           const wxPoint& pos,
           const wxSize& size,
           long style,
           const wxString& name) {
   ...
   info.SetAsChild(GetHWND(), wxGetClientRect(this->GetHWND()));

    CefBrowserHost::CreateBrowser(info, static_cast<CefRefPtr<CefClient>>   (m_clientHandler), url.ToStdString(), browsersettings, NULL);
}



However, I don't know how to do this with GTK+ on Linux platform, since GetHWND() is a windows platform specific function.

I tried to modify the above code from info.SetAsChild(GetHWND(), wxGetClientRect(this->GetHWND()))  to  info.SetAsChild(parent->GetHandle()) .

But it doesn't work.  I would appreciate it very much if anyone can give me some guides.


Thanks,
Haojian

Vadim Zeitlin

unread,
Jun 6, 2014, 11:15:25 AM6/6/14
to wx-...@googlegroups.com
On Fri, 6 Jun 2014 22:46:23 +0800 Haojian Wu wrote:

HW> However, there is a UI-specific issue, I don't know how to host a CEF
HW> browser window in wxWidgets windows.

You need to find out about how to do it in GTK+ programs, wxGTK gives you
access to GtkWidget which is probably used instead of HWND in CEF under
GTK.

Regards,
VZ

Haojian Wu

unread,
Jun 6, 2014, 12:03:46 PM6/6/14
to wx-...@googlegroups.com, Steven Lamerton
Thanks for your suggestion. I noticed wxWindow::GetHandle() will return gtkwidget on Linux GTK+.

I know how to do it in GTK+ program, and cefclient is a good example.

But I think there are still some differences between GTK and wxGTK.

Can we create a gtk vbox widget in wxGTK? cefclient hosts the browser window to gtk vbox.

 

Vadim Zeitlin

unread,
Jun 6, 2014, 12:13:53 PM6/6/14
to wx-...@googlegroups.com
On Sat, 7 Jun 2014 00:03:45 +0800 Haojian Wu wrote:

HW> Thanks for your suggestion. I noticed wxWindow::GetHandle() will return
HW> gtkwidget on Linux GTK+.

This might not be the widget you need though. See the comment explaining
the difference between m_widget and m_wxwindow in src/gtk/window.cpp.

HW> I know how to do it in GTK+ program, and cefclient
HW> <https://code.google.com/p/chromiumembedded/source/browse/branches/1650/cef3/tests/cefclient/cefclient_gtk.cpp>is
HW> a good example.
HW>
HW> But I think there are still some differences between GTK and wxGTK.
HW>
HW> Can we create a gtk vbox widget in wxGTK? cefclient hosts the browser
HW> window to gtk vbox.

If it needs to be a GtkBox, you'll have to create it yourself. But you
should be able to put this box inside the parent window using its widget as
parent. I.e. while wxGTK doesn't support this out of the box, you can still
do it.

Regards,
VZ

Haojian Wu

unread,
Jun 6, 2014, 8:30:07 PM6/6/14
to wx-...@googlegroups.com
On Sat, Jun 7, 2014 at 12:13 AM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
 If it needs to be a GtkBox, you'll have to create it yourself. But you
should be able to put this box inside the parent window using its widget as
parent. I.e. while wxGTK doesn't support this out of the box, you can still
do it.

Thanks! I will have a try. By the way, Are there any samples about this(Using gtk widget in wxwidgets)? 

Steven Lamerton

unread,
Jun 7, 2014, 2:35:05 AM6/7/14
to wx-...@googlegroups.com
Although it might not be exactly what you need the gtk source in src/gtk might give you some hints.

Steven

Stefano Mtangoo

unread,
Jun 7, 2014, 3:39:44 AM6/7/14
to wx-...@googlegroups.com
Hi,
the best I could find on internet concerning gtk is this example: https://github.com/CzarekTomczak/cefcapi/blob/master/main_linux.c
Not sure if it really work but it might shed a bit of light!

Best Regards,
Stefano
Reply all
Reply to author
Forward
0 new messages