tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

x_atom_cache.cc (1359B)


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