CEF 3 无边框 window

CEF 3 Borderless window

我是 CEF 的新手,我正在尝试在 ubuntu 12.04 x64 上创建新的无边界浏览器(仅用于网页查看)。 目前我已经尝试过这种方式(gtk 顶级 window -> 禁用装饰 -> 设置 window 信息,父级设置为以前装箱的 window -> 创建浏览器):

GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_decorated (GTK_WINDOW(window), FALSE);
CefWindowHandle window_handle = GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window);

CefWindowInfo window_info;
window_info.SetAsChild(window_handle, CefRect(100, 100, 800, 600));

CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings, NULL);

但这只会在指定位置正确打开浏览器 width/height,但它仍然有边框。

另一方面,我已经在 windows 上成功创建了无边框浏览器 window,只有:

CefWindowInfo window_info;
window_info.style = WS_VISIBLE | WS_POPUP;
window_info.x = 2120;
window_info.y = 200;
window_info.width = 800;
window_info.height = 600;

CefBrowserHost::CreateBrowserSync(window_info, handler, url, browser_settings, NULL);

注:

我用 X11 window 管理器解决了这个问题。

首先,我创建了一个用于删除 window 边框的函数:

#include <X11/Xlib.h>

static void RemoveBorders(Window window) {
  struct Data {
    unsigned long flags;
    unsigned long functions;
    unsigned long decorations;
    long          inputMode;
    unsigned long status;
  } data = {2, 0, 0, 0, 0};
  auto display = cef_get_xdisplay();
  auto atom = XInternAtom(display, "_MOTIF_WM_HINTS", True);
  XChangeProperty(display, window, atom, atom, 32, PropModeReplace, (unsigned char*)&data, 5);
}

之后,当我创建浏览器时,我同步创建它以检索创建的浏览器句柄并在浏览器上调用 RemoveBorders 函数 window 句柄:

...
auto browser = CefBrowserHost::CreateBrowserSync(window_info, handler, url, browser_settings, NULL);
RemoveBorders(browser->GetHost()->GetWindowHandle());
...