xref: /aosp_15_r20/external/webrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2018 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 <memory>
12 
13 #include "modules/desktop_capture/desktop_capture_types.h"
14 #include "modules/desktop_capture/mouse_cursor_monitor.h"
15 
16 #if defined(WEBRTC_USE_X11)
17 #include "modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.h"
18 #endif  // defined(WEBRTC_USE_X11)
19 
20 #if defined(WEBRTC_USE_PIPEWIRE)
21 #include "modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.h"
22 #endif  // defined(WEBRTC_USE_PIPEWIRE)
23 
24 namespace webrtc {
25 
26 // static
CreateForWindow(const DesktopCaptureOptions & options,WindowId window)27 MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
28     const DesktopCaptureOptions& options,
29     WindowId window) {
30 #if defined(WEBRTC_USE_X11)
31   return MouseCursorMonitorX11::CreateForWindow(options, window);
32 #else
33   return nullptr;
34 #endif  // defined(WEBRTC_USE_X11)
35 }
36 
37 // static
CreateForScreen(const DesktopCaptureOptions & options,ScreenId screen)38 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen(
39     const DesktopCaptureOptions& options,
40     ScreenId screen) {
41 #if defined(WEBRTC_USE_X11)
42   return MouseCursorMonitorX11::CreateForScreen(options, screen);
43 #else
44   return nullptr;
45 #endif  // defined(WEBRTC_USE_X11)
46 }
47 
48 // static
Create(const DesktopCaptureOptions & options)49 std::unique_ptr<MouseCursorMonitor> MouseCursorMonitor::Create(
50     const DesktopCaptureOptions& options) {
51 #if defined(WEBRTC_USE_PIPEWIRE)
52   if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland() &&
53       options.screencast_stream()) {
54     return std::make_unique<MouseCursorMonitorPipeWire>(options);
55   }
56 #endif  // defined(WEBRTC_USE_PIPEWIRE)
57 
58 #if defined(WEBRTC_USE_X11)
59   return MouseCursorMonitorX11::Create(options);
60 #else
61   return nullptr;
62 #endif  // defined(WEBRTC_USE_X11)
63 }
64 
65 }  // namespace webrtc
66