user7435094
user7435094

Reputation:

CEF 3 Borderless window

I'm fairly new to CEF, i'm trying to create new borderless browser (just for webpage viewing) on ubuntu 12.04 x64. Currently I have tried this way (gtk top level window -> disable decoration -> set window info with parent set to previously crated window -> 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);

But this only opens a browser on specified location with correct width/height, but it still has borders.

On the other hand i have successfully created borderless browser window on windows with only:

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);

Note:

Upvotes: 0

Views: 2023

Answers (1)

user7435094
user7435094

Reputation:

I solved the problem with X11 window manager.

First I create a function for removing window borders:

#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);
}

After that when I create a browser, I create it synchronously to retrieve created browser handle and call RemoveBorders function on browsers window handle:

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

Upvotes: 1

Related Questions