diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-22 17:44:57 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-22 17:44:57 +0000 |
commit | d610b37d141bcc2b46386dd036111e92a0bc35d3 (patch) | |
tree | 2a63f7ed50363d6e5a313c7db18e8d7c52802478 /ui/aura/x11_atom_cache.h | |
parent | 1cbfc98734a736a66ddbdacf2ab315c294d0a3e4 (diff) | |
download | chromium_src-d610b37d141bcc2b46386dd036111e92a0bc35d3.zip chromium_src-d610b37d141bcc2b46386dd036111e92a0bc35d3.tar.gz chromium_src-d610b37d141bcc2b46386dd036111e92a0bc35d3.tar.bz2 |
Desktop aura: Put x11 cache in aura, instead of ui/base/x/.
This should solve the pyauto compile error because MessagePumpX is actually an aura component, not a general x11 component.
Instead of being a Singleton, X11AtomCache should tie its lifetime to an aura::Env, which are reset in the unit tests whenever an X server is switched out.
BUG=128584, 129075
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10416020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/x11_atom_cache.h')
-rw-r--r-- | ui/aura/x11_atom_cache.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ui/aura/x11_atom_cache.h b/ui/aura/x11_atom_cache.h new file mode 100644 index 0000000..78b94ee --- /dev/null +++ b/ui/aura/x11_atom_cache.h @@ -0,0 +1,56 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_AURA_X11_ATOM_CACHE_H_ +#define UI_AURA_X11_ATOM_CACHE_H_ + +#include "base/basictypes.h" +#include "ui/aura/aura_export.h" + +#include <X11/Xlib.h> + +#include <map> + +// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. +#undef RootWindow + +namespace aura { +class Env; + +// Names of cached atoms that we fetch from X11AtomCache. Adding an entry here +// also requires adding an entry in the cc file. +enum AtomName { + ATOM_WM_DELETE_WINDOW = 0, + ATOM__NET_WM_MOVERESIZE, + ATOM__NET_WM_PING, + ATOM__NET_WM_PID, + ATOM_WM_S0, + ATOM__MOTIF_WM_HINTS, + + ATOM_COUNT +}; + +// Pre-caches all Atoms on first use to minimize roundtrips to the X11 +// server. Assumes that we only have a single X11 display, +// base::MessagePumpX::GetDefaultXDisplay(). +class AURA_EXPORT X11AtomCache { + public: + // Returns the pre-interned Atom by enum instead of string. + ::Atom GetAtom(AtomName name) const; + + private: + friend class aura::Env; + + // Constructor performs all interning + X11AtomCache(); + ~X11AtomCache(); + + std::map<AtomName, ::Atom> cached_atoms_; + + DISALLOW_COPY_AND_ASSIGN(X11AtomCache); +}; + +} // namespace aura + +#endif // UI_AURA_ATOM_CACHE_H_ |