Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 2914103002: Remove usages of XInternAtom (Closed)
Patch Set: Address sadrul and sergeyu comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index e7fd89c85fe7084eb018cb13bab71957aa50c7c1..c56a0014fbfad623409fe73a3e37b266d718bc1a 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -88,53 +88,6 @@ const int k_NET_WM_STATE_REMOVE = 0;
// should appear on all desktops.
const int kAllDesktops = 0xFFFFFFFF;
-const char* kAtomsToCache[] = {
- "UTF8_STRING",
- "WM_DELETE_WINDOW",
- "WM_PROTOCOLS",
- "_NET_ACTIVE_WINDOW",
- "_NET_FRAME_EXTENTS",
- "_NET_WM_CM_S0",
- "_NET_WM_DESKTOP",
- "_NET_WM_ICON",
- "_NET_WM_NAME",
- "_NET_WM_PID",
- "_NET_WM_PING",
- "_NET_WM_STATE",
- "_NET_WM_STATE_ABOVE",
- "_NET_WM_STATE_FULLSCREEN",
- "_NET_WM_STATE_HIDDEN",
- "_NET_WM_STATE_MAXIMIZED_HORZ",
- "_NET_WM_STATE_MAXIMIZED_VERT",
- "_NET_WM_STATE_SKIP_TASKBAR",
- "_NET_WM_STATE_STICKY",
- "_NET_WM_USER_TIME",
- "_NET_WM_WINDOW_OPACITY",
- "_NET_WM_WINDOW_TYPE",
- "_NET_WM_WINDOW_TYPE_DND",
- "_NET_WM_WINDOW_TYPE_MENU",
- "_NET_WM_WINDOW_TYPE_NORMAL",
- "_NET_WM_WINDOW_TYPE_NOTIFICATION",
- "_NET_WM_WINDOW_TYPE_TOOLTIP",
- "XdndActionAsk",
- "XdndActionCopy",
- "XdndActionLink",
- "XdndActionList",
- "XdndActionMove",
- "XdndActionPrivate",
- "XdndAware",
- "XdndDrop",
- "XdndEnter",
- "XdndFinished",
- "XdndLeave",
- "XdndPosition",
- "XdndProxy", // Proxy windows?
- "XdndSelection",
- "XdndStatus",
- "XdndTypeList",
- NULL
-};
-
const char kX11WindowRolePopup[] = "popup";
const char kX11WindowRoleBubble[] = "bubble";
@@ -190,7 +143,6 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
: xdisplay_(gfx::GetXDisplay()),
xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)),
- atom_cache_(xdisplay_, kAtomsToCache),
window_mapped_in_server_(false),
window_mapped_in_client_(false),
is_fullscreen_(false),
@@ -779,7 +731,7 @@ void DesktopWindowTreeHostX11::Activate() {
// https://code.google.com/p/wmii/issues/detail?id=266
static bool wm_supports_active_window =
ui::GuessWindowManager() != ui::WM_WMII &&
- ui::WmSupportsHint(atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"));
+ ui::WmSupportsHint(ui::GetAtom("_NET_ACTIVE_WINDOW"));
Time timestamp = ui::X11EventSource::GetInstance()->GetTimestamp();
@@ -788,7 +740,7 @@ void DesktopWindowTreeHostX11::Activate() {
memset(&xclient, 0, sizeof(xclient));
xclient.type = ClientMessage;
xclient.xclient.window = xwindow_;
- xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
+ xclient.xclient.message_type = ui::GetAtom("_NET_ACTIVE_WINDOW");
xclient.xclient.format = 32;
xclient.xclient.data.l[0] = 1; // Specified we are an app.
xclient.xclient.data.l[1] = timestamp;
@@ -845,9 +797,7 @@ bool DesktopWindowTreeHostX11::IsActive() const {
void DesktopWindowTreeHostX11::Maximize() {
if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN")) {
// Unfullscreen the window if it is fullscreen.
- SetWMSpecState(false,
- atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"),
- None);
+ SetWMSpecState(false, ui::GetAtom("_NET_WM_STATE_FULLSCREEN"), None);
// Resize the window so that it does not have the same size as a monitor.
// (Otherwise, some window managers immediately put the window back in
@@ -867,9 +817,8 @@ void DesktopWindowTreeHostX11::Maximize() {
// heuristics that are in the PropertyNotify and ConfigureNotify handlers.
restored_bounds_in_pixels_ = bounds_in_pixels_;
- SetWMSpecState(true,
- atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"),
- atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
+ SetWMSpecState(true, ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"),
+ ui::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
if (IsMinimized())
ShowWindowWithState(ui::SHOW_STATE_NORMAL);
}
@@ -881,9 +830,8 @@ void DesktopWindowTreeHostX11::Minimize() {
void DesktopWindowTreeHostX11::Restore() {
should_maximize_after_map_ = false;
- SetWMSpecState(false,
- atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"),
- atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
+ SetWMSpecState(false, ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"),
+ ui::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
if (IsMinimized())
ShowWindowWithState(ui::SHOW_STATE_NORMAL);
}
@@ -903,9 +851,7 @@ bool DesktopWindowTreeHostX11::HasCapture() const {
void DesktopWindowTreeHostX11::SetAlwaysOnTop(bool always_on_top) {
is_always_on_top_ = always_on_top;
- SetWMSpecState(always_on_top,
- atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"),
- None);
+ SetWMSpecState(always_on_top, ui::GetAtom("_NET_WM_STATE_ABOVE"), None);
}
bool DesktopWindowTreeHostX11::IsAlwaysOnTop() const {
@@ -913,9 +859,7 @@ bool DesktopWindowTreeHostX11::IsAlwaysOnTop() const {
}
void DesktopWindowTreeHostX11::SetVisibleOnAllWorkspaces(bool always_visible) {
- SetWMSpecState(always_visible,
- atom_cache_.GetAtom("_NET_WM_STATE_STICKY"),
- None);
+ SetWMSpecState(always_visible, ui::GetAtom("_NET_WM_STATE_STICKY"), None);
int new_desktop = 0;
if (always_visible) {
@@ -930,7 +874,7 @@ void DesktopWindowTreeHostX11::SetVisibleOnAllWorkspaces(bool always_visible) {
memset (&xevent, 0, sizeof (xevent));
xevent.type = ClientMessage;
xevent.xclient.window = xwindow_;
- xevent.xclient.message_type = atom_cache_.GetAtom("_NET_WM_DESKTOP");
+ xevent.xclient.message_type = ui::GetAtom("_NET_WM_DESKTOP");
xevent.xclient.format = 32;
xevent.xclient.data.l[0] = new_desktop;
xevent.xclient.data.l[1] = 0;
@@ -955,12 +899,8 @@ bool DesktopWindowTreeHostX11::SetWindowTitle(const base::string16& title) {
return false;
window_title_ = title;
std::string utf8str = base::UTF16ToUTF8(title);
- XChangeProperty(xdisplay_,
- xwindow_,
- atom_cache_.GetAtom("_NET_WM_NAME"),
- atom_cache_.GetAtom("UTF8_STRING"),
- 8,
- PropModeReplace,
+ XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_NAME"),
+ ui::GetAtom("UTF8_STRING"), 8, PropModeReplace,
reinterpret_cast<const unsigned char*>(utf8str.c_str()),
utf8str.size());
XTextProperty xtp;
@@ -1057,9 +997,7 @@ void DesktopWindowTreeHostX11::SetFullscreen(bool fullscreen) {
if (unmaximize_and_remaximize)
Restore();
- SetWMSpecState(fullscreen,
- atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"),
- None);
+ SetWMSpecState(fullscreen, ui::GetAtom("_NET_WM_STATE_FULLSCREEN"), None);
if (unmaximize_and_remaximize)
Maximize();
@@ -1104,13 +1042,10 @@ void DesktopWindowTreeHostX11::SetOpacity(float opacity) {
unsigned long cardinality = opacity_8bit * channel_multiplier;
if (cardinality == 0xffffffff) {
- XDeleteProperty(xdisplay_, xwindow_,
- atom_cache_.GetAtom("_NET_WM_WINDOW_OPACITY"));
+ XDeleteProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_WINDOW_OPACITY"));
} else {
- XChangeProperty(xdisplay_, xwindow_,
- atom_cache_.GetAtom("_NET_WM_WINDOW_OPACITY"),
- XA_CARDINAL, 32,
- PropModeReplace,
+ XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_WINDOW_OPACITY"),
+ XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<unsigned char*>(&cardinality), 1);
}
}
@@ -1367,22 +1302,22 @@ void DesktopWindowTreeHostX11::InitX11Window(
switch (params.type) {
case Widget::InitParams::TYPE_MENU:
swa.override_redirect = True;
- window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_MENU");
+ window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_MENU");
break;
case Widget::InitParams::TYPE_TOOLTIP:
swa.override_redirect = True;
- window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_TOOLTIP");
+ window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_TOOLTIP");
break;
case Widget::InitParams::TYPE_POPUP:
swa.override_redirect = True;
- window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NOTIFICATION");
+ window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_NOTIFICATION");
break;
case Widget::InitParams::TYPE_DRAG:
swa.override_redirect = True;
- window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_DND");
+ window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_DND");
break;
default:
- window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL");
+ window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_NORMAL");
break;
}
// An in-activatable window should not interact with the system wm.
@@ -1451,8 +1386,8 @@ void DesktopWindowTreeHostX11::InitX11Window(
// should listen for activation events and anything else that GTK+ listens
// for, and do something useful.
::Atom protocols[2];
- protocols[0] = atom_cache_.GetAtom("WM_DELETE_WINDOW");
- protocols[1] = atom_cache_.GetAtom("_NET_WM_PING");
+ protocols[0] = ui::GetAtom("WM_DELETE_WINDOW");
+ protocols[1] = ui::GetAtom("_NET_WM_PING");
XSetWMProtocols(xdisplay_, xwindow_, protocols, 2);
// We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with
@@ -1465,20 +1400,12 @@ void DesktopWindowTreeHostX11::InitX11Window(
static_assert(sizeof(long) >= sizeof(pid_t),
"pid_t should not be larger than long");
long pid = getpid();
- XChangeProperty(xdisplay_,
- xwindow_,
- atom_cache_.GetAtom("_NET_WM_PID"),
- XA_CARDINAL,
- 32,
- PropModeReplace,
- reinterpret_cast<unsigned char*>(&pid), 1);
+ XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_PID"), XA_CARDINAL,
+ 32, PropModeReplace, reinterpret_cast<unsigned char*>(&pid),
+ 1);
- XChangeProperty(xdisplay_,
- xwindow_,
- atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE"),
- XA_ATOM,
- 32,
- PropModeReplace,
+ XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_WINDOW_TYPE"),
+ XA_ATOM, 32, PropModeReplace,
reinterpret_cast<unsigned char*>(&window_type), 1);
// List of window state properties (_NET_WM_STATE) to set, if any.
@@ -1488,19 +1415,18 @@ void DesktopWindowTreeHostX11::InitX11Window(
if ((params.type == Widget::InitParams::TYPE_POPUP ||
params.type == Widget::InitParams::TYPE_BUBBLE) &&
!params.force_show_in_taskbar) {
- state_atom_list.push_back(
- atom_cache_.GetAtom("_NET_WM_STATE_SKIP_TASKBAR"));
+ state_atom_list.push_back(ui::GetAtom("_NET_WM_STATE_SKIP_TASKBAR"));
}
// If the window should stay on top of other windows, add the
// _NET_WM_STATE_ABOVE property.
is_always_on_top_ = params.keep_on_top;
if (is_always_on_top_)
- state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"));
+ state_atom_list.push_back(ui::GetAtom("_NET_WM_STATE_ABOVE"));
workspace_.clear();
if (params.visible_on_all_workspaces) {
- state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_STICKY"));
+ state_atom_list.push_back(ui::GetAtom("_NET_WM_STATE_STICKY"));
ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops);
} else if (!params.workspace.empty()) {
int workspace;
@@ -1717,13 +1643,9 @@ void DesktopWindowTreeHostX11::UpdateWMUserTime(
type == ui::ET_TOUCH_PRESSED) {
unsigned long wm_user_time_ms = static_cast<unsigned long>(
(ui::EventTimeFromNative(event) - base::TimeTicks()).InMilliseconds());
- XChangeProperty(xdisplay_,
- xwindow_,
- atom_cache_.GetAtom("_NET_WM_USER_TIME"),
- XA_CARDINAL,
- 32,
- PropModeReplace,
- reinterpret_cast<const unsigned char *>(&wm_user_time_ms),
+ XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_USER_TIME"),
+ XA_CARDINAL, 32, PropModeReplace,
+ reinterpret_cast<const unsigned char*>(&wm_user_time_ms),
1);
}
}
@@ -1735,7 +1657,7 @@ void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled,
memset(&xclient, 0, sizeof(xclient));
xclient.type = ClientMessage;
xclient.xclient.window = xwindow_;
- xclient.xclient.message_type = atom_cache_.GetAtom("_NET_WM_STATE");
+ xclient.xclient.message_type = ui::GetAtom("_NET_WM_STATE");
xclient.xclient.format = 32;
xclient.xclient.data.l[0] =
enabled ? k_NET_WM_STATE_ADD : k_NET_WM_STATE_REMOVE;
@@ -1750,8 +1672,8 @@ void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled,
}
bool DesktopWindowTreeHostX11::HasWMSpecProperty(const char* property) const {
- return window_properties_.find(atom_cache_.GetAtom(property)) !=
- window_properties_.end();
+ return window_properties_.find(ui::GetAtom(property)) !=
+ window_properties_.end();
}
void DesktopWindowTreeHostX11::SetUseNativeFrame(bool use_native_frame) {
@@ -1931,10 +1853,10 @@ void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) {
? 0
: ui::X11EventSource::GetInstance()->GetTimestamp();
if (show_state == ui::SHOW_STATE_INACTIVE || wm_user_time_ms != 0) {
- XChangeProperty(
- xdisplay_, xwindow_, atom_cache_.GetAtom("_NET_WM_USER_TIME"),
- XA_CARDINAL, 32, PropModeReplace,
- reinterpret_cast<const unsigned char*>(&wm_user_time_ms), 1);
+ XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_USER_TIME"),
+ XA_CARDINAL, 32, PropModeReplace,
+ reinterpret_cast<const unsigned char*>(&wm_user_time_ms),
+ 1);
}
ui::X11EventSource* event_source = ui::X11EventSource::GetInstance();
@@ -2192,12 +2114,12 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
}
case ClientMessage: {
Atom message_type = xev->xclient.message_type;
- if (message_type == atom_cache_.GetAtom("WM_PROTOCOLS")) {
+ if (message_type == ui::GetAtom("WM_PROTOCOLS")) {
Atom protocol = static_cast<Atom>(xev->xclient.data.l[0]);
- if (protocol == atom_cache_.GetAtom("WM_DELETE_WINDOW")) {
+ if (protocol == ui::GetAtom("WM_DELETE_WINDOW")) {
// We have received a close message from the window manager.
OnHostCloseRequested();
- } else if (protocol == atom_cache_.GetAtom("_NET_WM_PING")) {
+ } else if (protocol == ui::GetAtom("_NET_WM_PING")) {
XEvent reply_event = *xev;
reply_event.xclient.window = x_root_window_;
@@ -2207,17 +2129,17 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
SubstructureRedirectMask | SubstructureNotifyMask,
&reply_event);
}
- } else if (message_type == atom_cache_.GetAtom("XdndEnter")) {
+ } else if (message_type == ui::GetAtom("XdndEnter")) {
drag_drop_client_->OnXdndEnter(xev->xclient);
- } else if (message_type == atom_cache_.GetAtom("XdndLeave")) {
+ } else if (message_type == ui::GetAtom("XdndLeave")) {
drag_drop_client_->OnXdndLeave(xev->xclient);
- } else if (message_type == atom_cache_.GetAtom("XdndPosition")) {
+ } else if (message_type == ui::GetAtom("XdndPosition")) {
drag_drop_client_->OnXdndPosition(xev->xclient);
- } else if (message_type == atom_cache_.GetAtom("XdndStatus")) {
+ } else if (message_type == ui::GetAtom("XdndStatus")) {
drag_drop_client_->OnXdndStatus(xev->xclient);
- } else if (message_type == atom_cache_.GetAtom("XdndFinished")) {
+ } else if (message_type == ui::GetAtom("XdndFinished")) {
drag_drop_client_->OnXdndFinished(xev->xclient);
- } else if (message_type == atom_cache_.GetAtom("XdndDrop")) {
+ } else if (message_type == ui::GetAtom("XdndDrop")) {
drag_drop_client_->OnXdndDrop(xev->xclient);
}
break;
@@ -2261,11 +2183,11 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
}
case PropertyNotify: {
::Atom changed_atom = xev->xproperty.atom;
- if (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE")) {
+ if (changed_atom == ui::GetAtom("_NET_WM_STATE")) {
OnWMStateUpdated();
- } else if (changed_atom == atom_cache_.GetAtom("_NET_FRAME_EXTENTS")) {
+ } else if (changed_atom == ui::GetAtom("_NET_FRAME_EXTENTS")) {
OnFrameExtentsUpdated();
- } else if (changed_atom == atom_cache_.GetAtom("_NET_WM_DESKTOP")) {
+ } else if (changed_atom == ui::GetAtom("_NET_WM_DESKTOP")) {
if (UpdateWorkspace())
OnHostWorkspaceChanged();
}

Powered by Google App Engine
This is Rietveld 408576698