Cefsimple remove/hide title bar with chrome runtime

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.

Cefsimple remove/hide title bar with chrome runtime

Postby linuxcef9 » Fri Apr 07, 2023 6:09 pm

Hello,

I am on Windows OS and was wondering if we can remove the title bar (which has new tab, minimize, maximize, close buttons, search bar and other chrome specific buttons like featured experiments, side panels etc) when we launch cefsimple with --enable-chrome-runtime flag. This is to ensure that the look and feel is same as that of cefsimple without the flag but with chrome runtime to make use of their popups for mic, webcam etc
linuxcef9
Expert
 
Posts: 143
Joined: Tue Nov 06, 2018 3:08 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby magreenblatt » Fri Apr 07, 2023 6:34 pm

You can create a Chrome window without toolbar UI by using Views. The cefclient app demonstrates this approach (for example, “cefclient --enable-chrome-runtime --hide-controls --hide-overlays”).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby linuxcef9 » Fri Apr 07, 2023 6:46 pm

I need to have that in cefsimple app only and without views (since it would mess with our app where we reparent cefsimple window to a window created by our app).
Is that possible?
linuxcef9
Expert
 
Posts: 143
Joined: Tue Nov 06, 2018 3:08 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby magreenblatt » Fri Apr 07, 2023 7:45 pm

Does your approach work with cefsimple when Chrome runtime is enabled? If so, then it will also work when using Views to create a browser without a toolbar.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby linuxcef9 » Mon Apr 10, 2023 6:10 pm

Does your approach work with cefsimple when Chrome runtime is enabled? If so, then it will also work when using Views to create a browser without a toolbar.


Yes my approach works with cefsimple with chrome runtime. I thought views use different windowing hierarchy so it won't be compatible with our app. I'll try, thanks!
linuxcef9
Expert
 
Posts: 143
Joined: Tue Nov 06, 2018 3:08 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby linuxcef9 » Mon Apr 17, 2023 5:29 pm

Hello,

I am a bit confused..my application based off cefsimple was always launched without --use-views flag. I thought views won't be compatible with our app because we create a parent window in another process and make cef window child window. As per https://www.magpcss.org/ceforum/viewtop ... 293#p39650 , Marshall mentions "With Views you do not create your own parent window." but like I mentioned, we do create our own parent window.

However, when I tried passing in --use-views flag to our app, everything worked fine as before. What am I missing?

Also, as per https://github.com/chromiumembedded/cef ... ple_app.cc#L109 , the browser window creation logic is separate based on --use-views flag. I've all logic under "else" part where we manage CefBrowser objects so I am not sure if all that logic needs to be changed if I start using views flag.

Thus, I was wondering if there's a way to have chrome runtime without --use-views flag and also not have the address bar and other windows decorations.
linuxcef9
Expert
 
Posts: 143
Joined: Tue Nov 06, 2018 3:08 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby magreenblatt » Mon Apr 17, 2023 5:59 pm

Views does not support use of “CefWindowInfo.SetAsChild(parent_hwnd, …)”; or, in other words, creating a browser window directly as a child HWND. In your case it sounds like you might be creating cefsimple as a normal top-level window and then using WinAPI to reparent that HWND to some other window. That may work with Views (with or without Chrome runtime) at first glance, but some things (like focus, activation, etc) may exhibit problematic edge cases.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby linuxcef9 » Mon Apr 17, 2023 7:53 pm

Views does not support use of “CefWindowInfo.SetAsChild(parent_hwnd, …)”; or, in other words, creating a browser window directly as a child HWND. In your case it sounds like you might be creating cefsimple as a normal top-level window and then using WinAPI to reparent that HWND to some other window. That may work with Views (with or without Chrome runtime) at first glance, but some things (like focus, activation, etc) may exhibit problematic edge cases.


Okay I checked the code again. Even though I pass --use-views --hide-overlays --hide-controls --enable-chrome-runtime flag, we have removed views related logic. We use
CefBrowserHost::CreateBrowser API to create browsers. We always create browsers as child window as we call setAsChild method before CreateBrowser. Since the parent window doesn't have any decorations, I don't need to worry about them when such URLs are loaded.

However, for popup windows, the reparenting is done using WinAPI after popup CefBrowser has been created. Thus in these scenarios, I don't have a way to hide WS_OVERLAPPEDWINDOW decorations and address bar and other controls that come with --enable-chrome-runtime. So is there any workaround for the same?
linuxcef9
Expert
 
Posts: 143
Joined: Tue Nov 06, 2018 3:08 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby linuxcef9 » Mon Apr 17, 2023 11:16 pm

Update : I added code in OnBeforePopup to make popup a child window and that has solved the issue. Thanks a lot for your help. Much appreciated!
linuxcef9
Expert
 
Posts: 143
Joined: Tue Nov 06, 2018 3:08 pm

Re: Cefsimple remove/hide title bar with chrome runtime

Postby ndesktop » Wed Jun 21, 2023 10:35 am

linuxcef9 wrote:Okay I checked the code again. Even though I pass --use-views --hide-overlays --hide-controls --enable-chrome-runtime flag, we have removed views related logic.

Does this means you forked CEF and redirected to CEF instead of view the browser creation?
Because CefBrowserHostBase::Create() goes thru ChromeBrowserhostImpl::Create when IsChromeRuntimeEnabled() is true.

linuxcef9 wrote:We use CefBrowserHost::CreateBrowser API to create browsers. We always create browsers as child window as we call setAsChild method before CreateBrowser. Since the parent window doesn't have any decorations, I don't need to worry about them when such URLs are loaded.

Does this involves - again - a fork and changing perhaps CefWindowView::CreateWidget? I'm trying a similar scenario - which is, mainly, to have --enable-chrome-runtime but in the same time to have the browsers going only thru CefBrowserHost::CreateBrowser. Can you detail perhaps?
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 201 guests