mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-23 23:47:43 +01:00
Linux: Add support for setting the initial window title (issue #2204).
This commit is contained in:
parent
658bf2834a
commit
34db87563e
@ -71,11 +71,16 @@ struct CefWindowInfoTraits {
|
|||||||
typedef cef_window_info_t struct_type;
|
typedef cef_window_info_t struct_type;
|
||||||
|
|
||||||
static inline void init(struct_type* s) {}
|
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,
|
static inline void set(const struct_type* src,
|
||||||
struct_type* target,
|
struct_type* target,
|
||||||
bool copy) {
|
bool copy) {
|
||||||
|
cef_string_set(src->window_name.str, src->window_name.length,
|
||||||
|
&target->window_name, copy);
|
||||||
target->x = src->x;
|
target->x = src->x;
|
||||||
target->y = src->y;
|
target->y = src->y;
|
||||||
target->width = src->width;
|
target->width = src->width;
|
||||||
|
@ -72,6 +72,16 @@ typedef struct _cef_main_args_t {
|
|||||||
// Class representing window information.
|
// Class representing window information.
|
||||||
///
|
///
|
||||||
typedef struct _cef_window_info_t {
|
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 x;
|
||||||
unsigned int y;
|
unsigned int y;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
|
@ -74,7 +74,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
|||||||
|
|
||||||
// Create a new window object. It will delete itself when the associated X11
|
// Create a new window object. It will delete itself when the associated X11
|
||||||
// window is destroyed.
|
// 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();
|
window_info_.window = window_x11_->xwindow();
|
||||||
|
|
||||||
host_window_created_ = true;
|
host_window_created_ = true;
|
||||||
|
@ -21,10 +21,12 @@ namespace {
|
|||||||
const char kAtom[] = "ATOM";
|
const char kAtom[] = "ATOM";
|
||||||
const char kWMDeleteWindow[] = "WM_DELETE_WINDOW";
|
const char kWMDeleteWindow[] = "WM_DELETE_WINDOW";
|
||||||
const char kWMProtocols[] = "WM_PROTOCOLS";
|
const char kWMProtocols[] = "WM_PROTOCOLS";
|
||||||
|
const char kNetWMName[] = "_NET_WM_NAME";
|
||||||
const char kNetWMPid[] = "_NET_WM_PID";
|
const char kNetWMPid[] = "_NET_WM_PID";
|
||||||
const char kNetWMPing[] = "_NET_WM_PING";
|
const char kNetWMPing[] = "_NET_WM_PING";
|
||||||
const char kNetWMState[] = "_NET_WM_STATE";
|
const char kNetWMState[] = "_NET_WM_STATE";
|
||||||
const char kXdndProxy[] = "XdndProxy";
|
const char kXdndProxy[] = "XdndProxy";
|
||||||
|
const char kUTF8String[] = "UTF8_STRING";
|
||||||
|
|
||||||
::Window FindEventTarget(const ui::PlatformEvent& xev) {
|
::Window FindEventTarget(const ui::PlatformEvent& xev) {
|
||||||
::Window target = xev->xany.window;
|
::Window target = xev->xany.window;
|
||||||
@ -81,7 +83,8 @@ CEF_EXPORT XDisplay* cef_get_xdisplay() {
|
|||||||
|
|
||||||
CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
||||||
::Window parent_xwindow,
|
::Window parent_xwindow,
|
||||||
const gfx::Rect& bounds)
|
const gfx::Rect& bounds,
|
||||||
|
const std::string& title)
|
||||||
: browser_(browser),
|
: browser_(browser),
|
||||||
xdisplay_(gfx::GetXDisplay()),
|
xdisplay_(gfx::GetXDisplay()),
|
||||||
parent_xwindow_(parent_xwindow),
|
parent_xwindow_(parent_xwindow),
|
||||||
@ -133,6 +136,14 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
|||||||
long pid = getpid();
|
long pid = getpid();
|
||||||
XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(kNetWMPid), XA_CARDINAL, 32,
|
XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(kNetWMPid), XA_CARDINAL, 32,
|
||||||
PropModeReplace, reinterpret_cast<unsigned char*>(&pid), 1);
|
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() {
|
CefWindowX11::~CefWindowX11() {
|
||||||
|
@ -29,7 +29,8 @@ class CefWindowX11 : public ui::PlatformEventDispatcher {
|
|||||||
public:
|
public:
|
||||||
CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
||||||
::Window parent_xwindow,
|
::Window parent_xwindow,
|
||||||
const gfx::Rect& bounds);
|
const gfx::Rect& bounds,
|
||||||
|
const std::string& title);
|
||||||
~CefWindowX11() override;
|
~CefWindowX11() override;
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
@ -167,7 +167,7 @@ XCursorCache* cursor_cache = nullptr;
|
|||||||
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
|
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
|
||||||
bool is_guest_view_hack) {
|
bool is_guest_view_hack) {
|
||||||
// Create a hidden 1x1 window. It will delete itself on close.
|
// 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();
|
compositor_widget_ = window_->xwindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user