diff --git a/include/internal/cef_linux.h b/include/internal/cef_linux.h index 90577288e..a247d4482 100644 --- a/include/internal/cef_linux.h +++ b/include/internal/cef_linux.h @@ -71,11 +71,16 @@ struct CefWindowInfoTraits { typedef cef_window_info_t struct_type; static inline void init(struct_type* s) {} - static inline void clear(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->window_name); + } static inline void set(const struct_type* src, struct_type* target, bool copy) { + cef_string_set(src->window_name.str, src->window_name.length, + &target->window_name, copy); target->x = src->x; target->y = src->y; target->width = src->width; diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h index c0a57014a..627d28e76 100644 --- a/include/internal/cef_types_linux.h +++ b/include/internal/cef_types_linux.h @@ -72,6 +72,16 @@ typedef struct _cef_main_args_t { // Class representing window information. /// typedef struct _cef_window_info_t { + /// + // The initial title of the window, to be set when the window is created. + // Some layout managers (e.g., Compiz) can look at the window title + // in order to decide where to place the window when it is + // created. When this attribute is not empty, the window title will + // be set before the window is mapped to the dispay. Otherwise the + // title will be initially empty. + /// + cef_string_t window_name; + unsigned int x; unsigned int y; unsigned int width; diff --git a/libcef/browser/native/browser_platform_delegate_native_linux.cc b/libcef/browser/native/browser_platform_delegate_native_linux.cc index a1322a7c2..4e7f48a28 100644 --- a/libcef/browser/native/browser_platform_delegate_native_linux.cc +++ b/libcef/browser/native/browser_platform_delegate_native_linux.cc @@ -74,7 +74,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() { // Create a new window object. It will delete itself when the associated X11 // window is destroyed. - window_x11_ = new CefWindowX11(browser_, window_info_.parent_window, rect); + window_x11_ = new CefWindowX11(browser_, window_info_.parent_window, rect, + CefString(&window_info_.window_name).ToString()); window_info_.window = window_x11_->xwindow(); host_window_created_ = true; diff --git a/libcef/browser/native/window_x11.cc b/libcef/browser/native/window_x11.cc index 2300b1b67..fa76b9812 100644 --- a/libcef/browser/native/window_x11.cc +++ b/libcef/browser/native/window_x11.cc @@ -21,10 +21,12 @@ namespace { const char kAtom[] = "ATOM"; const char kWMDeleteWindow[] = "WM_DELETE_WINDOW"; const char kWMProtocols[] = "WM_PROTOCOLS"; +const char kNetWMName[] = "_NET_WM_NAME"; const char kNetWMPid[] = "_NET_WM_PID"; const char kNetWMPing[] = "_NET_WM_PING"; const char kNetWMState[] = "_NET_WM_STATE"; const char kXdndProxy[] = "XdndProxy"; +const char kUTF8String[] = "UTF8_STRING"; ::Window FindEventTarget(const ui::PlatformEvent& xev) { ::Window target = xev->xany.window; @@ -81,7 +83,8 @@ CEF_EXPORT XDisplay* cef_get_xdisplay() { CefWindowX11::CefWindowX11(CefRefPtr browser, ::Window parent_xwindow, - const gfx::Rect& bounds) + const gfx::Rect& bounds, + const std::string& title) : browser_(browser), xdisplay_(gfx::GetXDisplay()), parent_xwindow_(parent_xwindow), @@ -133,6 +136,14 @@ CefWindowX11::CefWindowX11(CefRefPtr browser, long pid = getpid(); XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(kNetWMPid), XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(&pid), 1); + + // Set the initial window name, if provided. + if (!title.empty()) { + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(kNetWMName), + gfx::GetAtom(kUTF8String), 8, PropModeReplace, + reinterpret_cast(title.c_str()), + title.size()); + } } CefWindowX11::~CefWindowX11() { diff --git a/libcef/browser/native/window_x11.h b/libcef/browser/native/window_x11.h index a9bca9094..998857f91 100644 --- a/libcef/browser/native/window_x11.h +++ b/libcef/browser/native/window_x11.h @@ -29,7 +29,8 @@ class CefWindowX11 : public ui::PlatformEventDispatcher { public: CefWindowX11(CefRefPtr browser, ::Window parent_xwindow, - const gfx::Rect& bounds); + const gfx::Rect& bounds, + const std::string& title); ~CefWindowX11() override; void Close(); diff --git a/libcef/browser/osr/render_widget_host_view_osr_linux.cc b/libcef/browser/osr/render_widget_host_view_osr_linux.cc index 12c75bd29..c56258005 100644 --- a/libcef/browser/osr/render_widget_host_view_osr_linux.cc +++ b/libcef/browser/osr/render_widget_host_view_osr_linux.cc @@ -167,7 +167,7 @@ XCursorCache* cursor_cache = nullptr; void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget( bool is_guest_view_hack) { // Create a hidden 1x1 window. It will delete itself on close. - window_ = new CefWindowX11(NULL, None, gfx::Rect(0, 0, 1, 1)); + window_ = new CefWindowX11(NULL, None, gfx::Rect(0, 0, 1, 1), ""); compositor_widget_ = window_->xwindow(); }