我对CEF相当陌生,我正尝试在ubuntu12.04 x64上创建新的无边界浏览器(仅用于查看网页)。目前,我已经尝试过这种方法(gtk顶级窗口->禁用装饰-> set窗口信息,父窗口设置为以前的容器窗口-> create browser):
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);但这只会在指定位置打开一个具有正确宽度/高度的浏览器,但它仍然有边框。
另一方面,我成功地在窗口上创建了无边界浏览器窗口,其中只有:
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);注意:
发布于 2017-09-15 06:17:26
我用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函数:
...
auto browser = CefBrowserHost::CreateBrowserSync(window_info, handler, url, browser_settings, NULL);
RemoveBorders(browser->GetHost()->GetWindowHandle());
...https://stackoverflow.com/questions/46213163
复制相似问题