1 /*
2  *  Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef MODULES_DESKTOP_CAPTURE_LINUX_X_ATOM_CACHE_H_
12 #define MODULES_DESKTOP_CAPTURE_LINUX_X_ATOM_CACHE_H_
13 
14 #include <X11/X.h>
15 #include <X11/Xlib.h>
16 
17 namespace webrtc {
18 
19 // A cache of Atom. Each Atom object is created on demand.
20 class XAtomCache final {
21  public:
22   explicit XAtomCache(::Display* display);
23   ~XAtomCache();
24 
25   ::Display* display() const;
26 
27   Atom WmState();
28   Atom WindowType();
29   Atom WindowTypeNormal();
30   Atom IccProfile();
31 
32  private:
33   // If |*atom| is None, this function uses XInternAtom() to retrieve an Atom.
34   Atom CreateIfNotExist(Atom* atom, const char* name);
35 
36   ::Display* const display_;
37   Atom wm_state_ = None;
38   Atom window_type_ = None;
39   Atom window_type_normal_ = None;
40   Atom icc_profile_ = None;
41 };
42 
43 }  // namespace webrtc
44 
45 #endif  // MODULES_DESKTOP_CAPTURE_LINUX_X_ATOM_CACHE_H_
46