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 #include "modules/desktop_capture/linux/x_atom_cache.h"
12 
13 #include "rtc_base/checks.h"
14 
15 namespace webrtc {
16 
XAtomCache(::Display * display)17 XAtomCache::XAtomCache(::Display* display) : display_(display) {
18   RTC_DCHECK(display_);
19 }
20 
21 XAtomCache::~XAtomCache() = default;
22 
display() const23 ::Display* XAtomCache::display() const {
24   return display_;
25 }
26 
WmState()27 Atom XAtomCache::WmState() {
28   return CreateIfNotExist(&wm_state_, "WM_STATE");
29 }
30 
WindowType()31 Atom XAtomCache::WindowType() {
32   return CreateIfNotExist(&window_type_, "_NET_WM_WINDOW_TYPE");
33 }
34 
WindowTypeNormal()35 Atom XAtomCache::WindowTypeNormal() {
36   return CreateIfNotExist(&window_type_normal_, "_NET_WM_WINDOW_TYPE_NORMAL");
37 }
38 
IccProfile()39 Atom XAtomCache::IccProfile() {
40   return CreateIfNotExist(&icc_profile_, "_ICC_PROFILE");
41 }
42 
CreateIfNotExist(Atom * atom,const char * name)43 Atom XAtomCache::CreateIfNotExist(Atom* atom, const char* name) {
44   RTC_DCHECK(atom);
45   if (*atom == None) {
46     *atom = XInternAtom(display(), name, True);
47   }
48   return *atom;
49 }
50 
51 }  // namespace webrtc
52