| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_AURA_X11_ATOM_CACHE_H_ | |
| 6 #define UI_AURA_X11_ATOM_CACHE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "ui/aura/aura_export.h" | |
| 10 | |
| 11 #include <X11/Xlib.h> | |
| 12 | |
| 13 #include <map> | |
| 14 | |
| 15 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | |
| 16 #undef RootWindow | |
| 17 | |
| 18 namespace aura { | |
| 19 class Env; | |
| 20 | |
| 21 // Names of cached atoms that we fetch from X11AtomCache. Adding an entry here | |
| 22 // also requires adding an entry in the cc file. | |
| 23 enum AtomName { | |
| 24 ATOM_WM_DELETE_WINDOW = 0, | |
| 25 ATOM__NET_WM_MOVERESIZE, | |
| 26 ATOM__NET_WM_PING, | |
| 27 ATOM__NET_WM_PID, | |
| 28 ATOM_WM_S0, | |
| 29 ATOM__MOTIF_WM_HINTS, | |
| 30 | |
| 31 ATOM_COUNT | |
| 32 }; | |
| 33 | |
| 34 // Pre-caches all Atoms on first use to minimize roundtrips to the X11 | |
| 35 // server. Assumes that we only have a single X11 display, | |
| 36 // base::MessagePumpX::GetDefaultXDisplay(). | |
| 37 class AURA_EXPORT X11AtomCache { | |
| 38 public: | |
| 39 // Returns the pre-interned Atom by enum instead of string. | |
| 40 ::Atom GetAtom(AtomName name) const; | |
| 41 | |
| 42 private: | |
| 43 friend class aura::Env; | |
| 44 | |
| 45 // Constructor performs all interning | |
| 46 X11AtomCache(); | |
| 47 ~X11AtomCache(); | |
| 48 | |
| 49 std::map<AtomName, ::Atom> cached_atoms_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(X11AtomCache); | |
| 52 }; | |
| 53 | |
| 54 } // namespace aura | |
| 55 | |
| 56 #endif // UI_AURA_ATOM_CACHE_H_ | |
| OLD | NEW |