Index: ui/aura/root_window_host_linux.cc |
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc |
index 4f42775ff14aa9e8c40e44b6a4b72b2f86672dab..af307806dc9cf0b754b7a57dfe47ad3ff15b9bf5 100644 |
--- a/ui/aura/root_window_host_linux.cc |
+++ b/ui/aura/root_window_host_linux.cc |
@@ -27,10 +27,12 @@ |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/base/touch/touch_factory.h" |
#include "ui/base/view_prop.h" |
+#include "ui/base/x/x11_atom_cache.h" |
#include "ui/base/x/x11_util.h" |
#include "ui/compositor/layer.h" |
#include "ui/gfx/image/image.h" |
+using ui::X11AtomCache; |
using std::max; |
using std::min; |
@@ -286,15 +288,6 @@ bool ShouldSendCharEventForKeyboardCode(ui::KeyboardCode keycode) { |
} |
} |
-// A list of atoms that we'll intern on host creation to save roundtrips to the |
-// X11 server. Must be kept in sync with RootWindowHostLinux::AtomList |
-const char* kAtomList[] = { |
- "WM_DELETE_WINDOW", |
- "_NET_WM_PING", |
- "_NET_WM_PID", |
- "WM_S0" |
-}; |
- |
} // namespace |
// A utility class that provides X Cursor for NativeCursors for which we have |
@@ -395,16 +388,13 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) |
if (RootWindow::hide_host_cursor()) |
XDefineCursor(xdisplay_, x_root_window_, invisible_cursor_); |
- // Grab all the atoms we need now to minimize roundtrips to the X11 server. |
- XInternAtoms(xdisplay_, const_cast<char**>(kAtomList), ATOM_COUNT, False, |
- cached_atoms_); |
- |
// TODO(erg): We currently only request window deletion events. We also |
// should listen for activation events and anything else that GTK+ listens |
// for, and do something useful. |
+ X11AtomCache* cache = X11AtomCache::GetInstance(); |
::Atom protocols[2]; |
- protocols[0] = cached_atoms_[ATOM_WM_DELETE_WINDOW]; |
- protocols[1] = cached_atoms_[ATOM__NET_WM_PING]; |
+ protocols[0] = cache->GetAtom(ui::ATOM_WM_DELETE_WINDOW); |
+ protocols[1] = cache->GetAtom(ui::ATOM__NET_WM_PING); |
XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); |
// We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with |
@@ -416,7 +406,7 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) |
pid_t pid = getpid(); |
XChangeProperty(xdisplay_, |
xwindow_, |
- cached_atoms_[ATOM__NET_WM_PID], |
+ cache->GetAtom(ui::ATOM__NET_WM_PID), |
XA_CARDINAL, |
32, |
PropModeReplace, |
@@ -588,10 +578,11 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { |
} |
case ClientMessage: { |
Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); |
- if (message_type == cached_atoms_[ATOM_WM_DELETE_WINDOW]) { |
+ X11AtomCache* cache = X11AtomCache::GetInstance(); |
+ if (message_type == cache->GetAtom(ui::ATOM_WM_DELETE_WINDOW)) { |
// We have received a close message from the window manager. |
root_window_->OnRootWindowHostClosed(); |
- } else if (message_type == cached_atoms_[ATOM__NET_WM_PING]) { |
+ } else if (message_type == cache->GetAtom(ui::ATOM__NET_WM_PING)) { |
XEvent reply_event = *xev; |
reply_event.xclient.window = x_root_window_; |
@@ -840,7 +831,9 @@ void RootWindowHostLinux::PostNativeEvent( |
bool RootWindowHostLinux::IsWindowManagerPresent() { |
// Per ICCCM 2.8, "Manager Selections", window managers should take ownership |
// of WM_Sn selections (where n is a screen number). |
- return XGetSelectionOwner(xdisplay_, cached_atoms_[ATOM_WM_S0]) != None; |
+ return XGetSelectionOwner( |
+ xdisplay_, |
+ X11AtomCache::GetInstance()->GetAtom(ui::ATOM_WM_S0)) != None; |
} |
void RootWindowHostLinux::SetCursorInternal(gfx::NativeCursor cursor) { |