LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/desktop_capture/x11 - shared_x_display.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 8 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2013 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 WEBRTC_MODULES_DESKTOP_CAPTURE_X11_SHARED_X_DISPLAY_H_
      12             : #define WEBRTC_MODULES_DESKTOP_CAPTURE_X11_SHARED_X_DISPLAY_H_
      13             : 
      14             : #include <map>
      15             : #include <vector>
      16             : 
      17             : #include <string>
      18             : 
      19             : #include "webrtc/base/constructormagic.h"
      20             : #include "webrtc/base/scoped_ref_ptr.h"
      21             : #include "webrtc/system_wrappers/include/atomic32.h"
      22             : 
      23             : // Including Xlib.h will involve evil defines (Bool, Status, True, False), which
      24             : // easily conflict with other headers.
      25             : typedef struct _XDisplay Display;
      26             : typedef union _XEvent XEvent;
      27             : 
      28             : namespace webrtc {
      29             : 
      30             : // A ref-counted object to store XDisplay connection.
      31             : class SharedXDisplay {
      32             :  public:
      33           0 :   class XEventHandler {
      34             :    public:
      35           0 :     virtual ~XEventHandler() {}
      36             : 
      37             :     // Processes XEvent. Returns true if the event has been handled.
      38             :     virtual bool HandleXEvent(const XEvent& event) = 0;
      39             :   };
      40             : 
      41             :   // Takes ownership of |display|.
      42             :   explicit SharedXDisplay(Display* display);
      43             : 
      44             :   // Creates a new X11 Display for the |display_name|. NULL is returned if X11
      45             :   // connection failed. Equivalent to CreateDefault() when |display_name| is
      46             :   // empty.
      47             :   static rtc::scoped_refptr<SharedXDisplay> Create(
      48             :       const std::string& display_name);
      49             : 
      50             :   // Creates X11 Display connection for the default display (e.g. specified in
      51             :   // DISPLAY). NULL is returned if X11 connection failed.
      52             :   static rtc::scoped_refptr<SharedXDisplay> CreateDefault();
      53             : 
      54           0 :   void AddRef() { ++ref_count_; }
      55           0 :   void Release() {
      56           0 :     if (--ref_count_ == 0)
      57           0 :       delete this;
      58           0 :   }
      59             : 
      60           0 :   Display* display() { return display_; }
      61             : 
      62             :   // Adds a new event |handler| for XEvent's of |type|.
      63             :   void AddEventHandler(int type, XEventHandler* handler);
      64             : 
      65             :   // Removes event |handler| added using |AddEventHandler|. Doesn't do anything
      66             :   // if |handler| is not registered.
      67             :   void RemoveEventHandler(int type, XEventHandler* handler);
      68             : 
      69             :   // Processes pending XEvents, calling corresponding event handlers.
      70             :   void ProcessPendingXEvents();
      71             : 
      72             :  private:
      73             :   typedef std::map<int, std::vector<XEventHandler*> > EventHandlersMap;
      74             : 
      75             :   ~SharedXDisplay();
      76             : 
      77             :   Atomic32 ref_count_;
      78             :   Display* display_;
      79             : 
      80             :   EventHandlersMap event_handlers_;
      81             : 
      82             :   RTC_DISALLOW_COPY_AND_ASSIGN(SharedXDisplay);
      83             : };
      84             : 
      85             : }  // namespace webrtc
      86             : 
      87             : #endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_X11_SHARED_X_DISPLAY_H_

Generated by: LCOV version 1.13