blob: 783da77bc3437f03d04e679743108f2c033be146 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// 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_BASE_X_X11_ATOM_CACHE_H_
#define UI_BASE_X_X11_ATOM_CACHE_H_
#include "base/basictypes.h"
#include "base/memory/singleton.h"
#include "ui/base/ui_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 ui {
// 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 UI_EXPORT X11AtomCache {
public:
static X11AtomCache* GetInstance();
// Returns the pre-interned Atom by enum instead of string.
::Atom GetAtom(AtomName name) const;
private:
friend struct DefaultSingletonTraits<X11AtomCache>;
// Constructor performs all interning
X11AtomCache();
~X11AtomCache();
std::map<AtomName, ::Atom> cached_atoms_;
DISALLOW_COPY_AND_ASSIGN(X11AtomCache);
};
} // namespace ui
#endif // UI_BASE_X_ATOM_CACHE_H_
|