reparent cefBrowser after creation Linux

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

reparent cefBrowser after creation Linux

Postby calkins » Tue Aug 23, 2022 3:14 pm

Hi all,

Is it possible to reparent the cefBrowser after it has been created? Currently I am creating the browser in the standard way as shown below by passing in the XID of its parent to the windowInfo variable. For our use case we need to reparent the browser when our main process quits but cannot find a way to do so.

Code: Select all
CefWindowInfo windowInfo;
CefRect rc(0, 0, 320, 320);
windowInfo.SetAsChild(parentXID, rc);
CefBrowserSettings browserSettings;
CefBrowserHost::CreateBrowser(windowInfo, this, "", browserSettings, nullptr, nullptr);
calkins
Techie
 
Posts: 10
Joined: Thu Aug 11, 2022 3:26 pm

Re: reparent cefBrowser after creation Linux

Postby magreenblatt » Tue Aug 23, 2022 4:40 pm

An XID is returned via browser->GetHost()->GetWindowHandle(). You will need to reparent that. See example here: https://github.com/chromiumembedded/cef ... tk.cc#L132
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: reparent cefBrowser after creation Linux

Postby calkins » Thu Aug 25, 2022 4:31 pm

magreenblatt wrote:An XID is returned via browser->GetHost()->GetWindowHandle(). You will need to reparent that. See example here: https://github.com/chromiumembedded/cef ... tk.cc#L132

This didnt quite seem to solve our problem. When our application closes the variable xwindow_ is being set to None and we return here: https://sourcegraph.com/github.com/chro ... x11.cc?L15

This is causing windowDestroy to not be called and as a result OnBeforeClose to not be called. From the code we cant find how xwindow_ is being set to None, do you have a clue as to why this could be? Our thought was reparenting would help but it doesnt.
calkins
Techie
 
Posts: 10
Joined: Thu Aug 11, 2022 3:26 pm

Re: reparent cefBrowser after creation Linux

Postby magreenblatt » Thu Aug 25, 2022 4:49 pm

calkins wrote:When our application closes the variable xwindow_ is being set to None and we return here: https://sourcegraph.com/github.com/chro ... x11.cc?L15

I don't think your link is working as intended. What code line did you intend to reference?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: reparent cefBrowser after creation Linux

Postby calkins » Thu Aug 25, 2022 5:34 pm

magreenblatt wrote:
calkins wrote:When our application closes the variable xwindow_ is being set to None and we return here: https://sourcegraph.com/github.com/chro ... x11.cc?L15

I don't think your link is working as intended. What code line did you intend to reference?

My bad. CefWindowX11::Close() function line 151. Our application is returning on line 153.
calkins
Techie
 
Posts: 10
Joined: Thu Aug 11, 2022 3:26 pm


Return to Support Forum

Who is online

Users browsing this forum: Majestic-12 [Bot] and 108 guests