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

Side by Side Diff: ui/aura/x11_atom_cache.cc

Issue 10441028: aura/cros: Rename MessagePump{X => AuraX11} and move the atom cache into it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include "ui/aura/x11_atom_cache.h"
6
7 #include <X11/Xatom.h>
8
9 #include "base/message_pump_x.h"
10
11 namespace aura {
12
13 namespace {
14
15 // A list of atoms that we'll intern on host creation to save roundtrips to the
16 // X11 server. Must be kept in sync with AtomCache::AtomName
17 struct AtomInfo {
18 AtomName id;
19 const char* name;
20 } const kAtomList[] = {
21 { ATOM_WM_DELETE_WINDOW, "WM_DELETE_WINDOW" },
22 { ATOM__NET_WM_MOVERESIZE, "_NET_WM_MOVERESIZE" },
23 { ATOM__NET_WM_PING, "_NET_WM_PING" },
24 { ATOM__NET_WM_PID, "_NET_WM_PID" },
25 { ATOM_WM_S0, "WM_S0" },
26 { ATOM__MOTIF_WM_HINTS, "_MOTIF_WM_HINTS" }
27 };
28
29 // Our lists need to stay in sync here.
30 COMPILE_ASSERT(arraysize(kAtomList) == ATOM_COUNT, atom_lists_are_same_size);
31
32 } // namespace
33
34 ::Atom X11AtomCache::GetAtom(AtomName name) const {
35 std::map<AtomName, ::Atom>::const_iterator it = cached_atoms_.find(name);
36 DCHECK(it != cached_atoms_.end());
37 return it->second;
38 }
39
40 X11AtomCache::X11AtomCache() {
41 const char* all_names[ATOM_COUNT];
42 ::Atom cached_atoms[ATOM_COUNT];
43
44 for (int i = 0; i < ATOM_COUNT; ++i)
45 all_names[i] = kAtomList[i].name;
46
47 // Grab all the atoms we need now to minimize roundtrips to the X11 server.
48 XInternAtoms(base::MessagePumpX::GetDefaultXDisplay(),
49 const_cast<char**>(all_names), ATOM_COUNT, False,
50 cached_atoms);
51
52 for (int i = 0; i < ATOM_COUNT; ++i)
53 cached_atoms_.insert(std::make_pair(kAtomList[i].id, cached_atoms[i]));
54 }
55
56 X11AtomCache::~X11AtomCache() {}
57
58 } // namespace aura
OLDNEW
« base/base.gypi ('K') | « ui/aura/x11_atom_cache.h ('k') | ui/base/x/events_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698