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_WINDOW_FINDER_H_
12 #define MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
13 
14 #include <memory>
15 
16 #include "api/scoped_refptr.h"
17 #include "modules/desktop_capture/desktop_capture_types.h"
18 #include "modules/desktop_capture/desktop_geometry.h"
19 
20 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
21 #include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
22 #endif
23 
24 namespace webrtc {
25 
26 #if defined(WEBRTC_USE_X11)
27 class XAtomCache;
28 #endif
29 
30 // An interface to return the id of the visible window under a certain point.
31 class WindowFinder {
32  public:
33   WindowFinder() = default;
34   virtual ~WindowFinder() = default;
35 
36   // Returns the id of the visible window under |point|. This function returns
37   // kNullWindowId if no window is under |point| and the platform does not have
38   // "root window" concept, i.e. the visible area under |point| is the desktop.
39   // |point| is always in system coordinate, i.e. the primary monitor always
40   // starts from (0, 0).
41   virtual WindowId GetWindowUnderPoint(DesktopVector point) = 0;
42 
43   struct Options final {
44     Options();
45     ~Options();
46     Options(const Options& other);
47     Options(Options&& other);
48 
49 #if defined(WEBRTC_USE_X11)
50     XAtomCache* cache = nullptr;
51 #endif
52 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
53     rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor;
54 #endif
55   };
56 
57   // Creates a platform-independent WindowFinder implementation. This function
58   // returns nullptr if |options| does not contain enough information or
59   // WindowFinder does not support current platform.
60   static std::unique_ptr<WindowFinder> Create(const Options& options);
61 };
62 
63 }  // namespace webrtc
64 
65 #endif  // MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
66