I'm developing a CEF-Based app on macOS.
I use the "--use-views" switch to make sure the browser window was created with the "CEF Browser View" way.
Below are several key points about my program.
- Code: Select all
class WindowDelegate : public CefWindowDelegate
{
public:
// omit the Constructor and other methods...
bool IsFrameless(CefRefPtr<CefWindow> window) override;
void OnWindowCreated(CefRefPtr<CefWindow> window) override;
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override;
bool CanClose(CefRefPtr<CefWindow> window) override;
CefRect GetInitialBounds(CefRefPtr<CefWindow> window) override;
private:
CefRefPtr<CefBrowserView> browserView;
IMPLEMENT_REFCOUNTING(WindowDelegate);
};
- Code: Select all
void WindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) {
window->AddChildView(browserView);
window->Show();
browserView->RequestFocus();
}
bool WindowDelegate::IsFrameless(CefRefPtr<CefWindow> window) {
return true;
}
- Code: Select all
if (use_views) {
CefRefPtr<PageHandler> pageHandler(new PageHandler());
CefRefPtr<ViewDelegate> viewDelegate(new ViewDelegate());
// Create the BrowserView.
CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(
pageHandler, url, browser_settings, nullptr, nullptr,
viewDelegate);
// Create the Window. It will show itself after creation.
CefWindow::CreateTopLevelWindow(new WindowDelegate(browser_view));
}
In my code, IsFrameless method always returns true. But the app displays a title bar. Why?