我是CEF的新手,我正在尝试在Ubuntu 12.04 x64上创建新的无边界浏览器(仅用于网页查看)。目前,我已经尝试过这种方式(GTK顶级窗口 ->禁用装饰 ->将窗口信息设置为parent设置为先前板条窗口 ->创建浏览器):
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);
,但这仅在指定位置打开浏览器,其宽度/高度仍然有边界。
另一方面,我仅在Windows上成功创建了无边界浏览器窗口:
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);
注意:
- 我无法重建整个CEF,
- 我无法升级Ubuntu。
我解决了X11窗口管理器的问题。
首先,我创建一个用于删除窗口边框的函数:
#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 handle:
...
auto browser = CefBrowserHost::CreateBrowserSync(window_info, handler, url, browser_settings, NULL);
RemoveBorders(browser->GetHost()->GetWindowHandle());
...