mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-22 15:07:42 +01:00
Linux: Add support for setting the initial window title (issue #2204).
This commit is contained in:
parent
efe3cde8be
commit
18b362b338
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<CefBrowserHostImpl> 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<CefBrowserHostImpl> browser,
|
||||
long pid = getpid();
|
||||
XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(kNetWMPid), XA_CARDINAL, 32,
|
||||
PropModeReplace, reinterpret_cast<unsigned char*>(&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<const unsigned char*>(title.c_str()),
|
||||
title.size());
|
||||
}
|
||||
}
|
||||
|
||||
CefWindowX11::~CefWindowX11() {
|
||||
|
@ -29,7 +29,8 @@ class CefWindowX11 : public ui::PlatformEventDispatcher {
|
||||
public:
|
||||
CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
||||
::Window parent_xwindow,
|
||||
const gfx::Rect& bounds);
|
||||
const gfx::Rect& bounds,
|
||||
const std::string& title);
|
||||
~CefWindowX11() override;
|
||||
|
||||
void Close();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user