Borderless browser with CEF 3.3112.1659/Ubuntu 12.04.5 x64

Built a cool app using CEF that you'd like to share with the community? Talk about it here.

Borderless browser with CEF 3.3112.1659/Ubuntu 12.04.5 x64

Postby fr3nzy » Thu Sep 14, 2017 2:49 am

I'm fairly new to CEF, i'm trying to create new borderless browser (just for webpage viewing) on ubuntu 12.04.5 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):
Code: Select all
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:
Code: Select all
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:
- i can only use prebuild binaries (i cannot rebuild the entire cef),
- i'm stuck with the EOF ubuntu version.
Last edited by fr3nzy on Thu Sep 14, 2017 11:42 am, edited 1 time in total.
fr3nzy
Techie
 
Posts: 13
Joined: Tue Sep 12, 2017 5:47 am

Re: Borderless browser with CEF 3.3112.1659 on Ubuntu 12.04.

Postby magreenblatt » Thu Sep 14, 2017 10:49 am

You can do this using Views. Run `cefclient --use-views --hide-frame` for an example.
magreenblatt
Site Admin
 
Posts: 9837
Joined: Fri May 29, 2009 6:57 pm

Re: Borderless browser with CEF 3.3112.1659/Ubuntu 12.04.5 x

Postby fr3nzy » Fri Sep 15, 2017 1:20 am

Thank you for the suggestion. I managed to solve the issue without views - with pure X11 window manager.
First I created a function for removing window borders:

Code: Select all
#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:

Code: Select all
...
auto browser = CefBrowserHost::CreateBrowserSync(window_info, handler, url, browser_settings, NULL);
RemoveBorders(browser->GetHost()->GetWindowHandle());
...
fr3nzy
Techie
 
Posts: 13
Joined: Tue Sep 12, 2017 5:47 am


Return to Apps Discussion

Who is online

Users browsing this forum: No registered users and 1 guest