xref: /aosp_15_r20/external/webrtc/modules/desktop_capture/window_finder.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #ifndef MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
12*d9f75844SAndroid Build Coastguard Worker #define MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #include <memory>
15*d9f75844SAndroid Build Coastguard Worker 
16*d9f75844SAndroid Build Coastguard Worker #include "api/scoped_refptr.h"
17*d9f75844SAndroid Build Coastguard Worker #include "modules/desktop_capture/desktop_capture_types.h"
18*d9f75844SAndroid Build Coastguard Worker #include "modules/desktop_capture/desktop_geometry.h"
19*d9f75844SAndroid Build Coastguard Worker 
20*d9f75844SAndroid Build Coastguard Worker #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
21*d9f75844SAndroid Build Coastguard Worker #include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
22*d9f75844SAndroid Build Coastguard Worker #endif
23*d9f75844SAndroid Build Coastguard Worker 
24*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
25*d9f75844SAndroid Build Coastguard Worker 
26*d9f75844SAndroid Build Coastguard Worker #if defined(WEBRTC_USE_X11)
27*d9f75844SAndroid Build Coastguard Worker class XAtomCache;
28*d9f75844SAndroid Build Coastguard Worker #endif
29*d9f75844SAndroid Build Coastguard Worker 
30*d9f75844SAndroid Build Coastguard Worker // An interface to return the id of the visible window under a certain point.
31*d9f75844SAndroid Build Coastguard Worker class WindowFinder {
32*d9f75844SAndroid Build Coastguard Worker  public:
33*d9f75844SAndroid Build Coastguard Worker   WindowFinder() = default;
34*d9f75844SAndroid Build Coastguard Worker   virtual ~WindowFinder() = default;
35*d9f75844SAndroid Build Coastguard Worker 
36*d9f75844SAndroid Build Coastguard Worker   // Returns the id of the visible window under `point`. This function returns
37*d9f75844SAndroid Build Coastguard Worker   // kNullWindowId if no window is under `point` and the platform does not have
38*d9f75844SAndroid Build Coastguard Worker   // "root window" concept, i.e. the visible area under `point` is the desktop.
39*d9f75844SAndroid Build Coastguard Worker   // `point` is always in system coordinate, i.e. the primary monitor always
40*d9f75844SAndroid Build Coastguard Worker   // starts from (0, 0).
41*d9f75844SAndroid Build Coastguard Worker   virtual WindowId GetWindowUnderPoint(DesktopVector point) = 0;
42*d9f75844SAndroid Build Coastguard Worker 
43*d9f75844SAndroid Build Coastguard Worker   struct Options final {
44*d9f75844SAndroid Build Coastguard Worker     Options();
45*d9f75844SAndroid Build Coastguard Worker     ~Options();
46*d9f75844SAndroid Build Coastguard Worker     Options(const Options& other);
47*d9f75844SAndroid Build Coastguard Worker     Options(Options&& other);
48*d9f75844SAndroid Build Coastguard Worker 
49*d9f75844SAndroid Build Coastguard Worker #if defined(WEBRTC_USE_X11)
50*d9f75844SAndroid Build Coastguard Worker     XAtomCache* cache = nullptr;
51*d9f75844SAndroid Build Coastguard Worker #endif
52*d9f75844SAndroid Build Coastguard Worker #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
53*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor;
54*d9f75844SAndroid Build Coastguard Worker #endif
55*d9f75844SAndroid Build Coastguard Worker   };
56*d9f75844SAndroid Build Coastguard Worker 
57*d9f75844SAndroid Build Coastguard Worker   // Creates a platform-independent WindowFinder implementation. This function
58*d9f75844SAndroid Build Coastguard Worker   // returns nullptr if `options` does not contain enough information or
59*d9f75844SAndroid Build Coastguard Worker   // WindowFinder does not support current platform.
60*d9f75844SAndroid Build Coastguard Worker   static std::unique_ptr<WindowFinder> Create(const Options& options);
61*d9f75844SAndroid Build Coastguard Worker };
62*d9f75844SAndroid Build Coastguard Worker 
63*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
64*d9f75844SAndroid Build Coastguard Worker 
65*d9f75844SAndroid Build Coastguard Worker #endif  // MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
66