Ubuntu-12.04 [SOLVED]: Borderless browser with CEF 3.3112.1659 on Ubuntu 12.04.5 x64

Ubuntu-12.04 [SOLVED]: Borderless browser with CEF 3.3112.1659 on Ubuntu 12.04.5 x64

Home Forums Ubuntu 12.04 Ubuntu-12.04 [SOLVED]: Borderless browser with CEF 3.3112.1659 on Ubuntu 12.04.5 x64

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27872

    Anonymous

    QuestionQuestion

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

    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:

    • i can only use prebuild binaries (i cannot rebuild the entire cef),
    • i’m stuck with the EOF ubuntu version.

    #27873

    Anonymous

    Accepted AnswerAnswer

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

    Source: https://stackoverflow.com/questions/46213163/borderless-browser-with-cef-3-3112-1659-on-ubuntu-12-04-5-x64
    Author: fr3nzy90
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.