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 #ifndef MODULES_DESKTOP_CAPTURE_LINUX_MOUSE_CURSOR_MONITOR_X11_H_ 12 #define MODULES_DESKTOP_CAPTURE_LINUX_MOUSE_CURSOR_MONITOR_X11_H_ 13 14 #include <X11/X.h> 15 16 #include <memory> 17 18 #include "api/scoped_refptr.h" 19 #include "modules/desktop_capture/desktop_capture_options.h" 20 #include "modules/desktop_capture/desktop_capture_types.h" 21 #include "modules/desktop_capture/linux/shared_x_display.h" 22 #include "modules/desktop_capture/mouse_cursor.h" 23 #include "modules/desktop_capture/mouse_cursor_monitor.h" 24 25 namespace webrtc { 26 27 class MouseCursorMonitorX11 : public MouseCursorMonitor, 28 public SharedXDisplay::XEventHandler { 29 public: 30 MouseCursorMonitorX11(const DesktopCaptureOptions& options, Window window); 31 ~MouseCursorMonitorX11() override; 32 33 static MouseCursorMonitor* CreateForWindow( 34 const DesktopCaptureOptions& options, 35 WindowId window); 36 static MouseCursorMonitor* CreateForScreen( 37 const DesktopCaptureOptions& options, 38 ScreenId screen); 39 static std::unique_ptr<MouseCursorMonitor> Create( 40 const DesktopCaptureOptions& options); 41 42 void Init(Callback* callback, Mode mode) override; 43 void Capture() override; 44 45 private: 46 // SharedXDisplay::XEventHandler interface. 47 bool HandleXEvent(const XEvent& event) override; 48 display()49 Display* display() { return x_display_->display(); } 50 51 // Captures current cursor shape and stores it in |cursor_shape_|. 52 void CaptureCursor(); 53 54 rtc::scoped_refptr<SharedXDisplay> x_display_; 55 Callback* callback_; 56 Mode mode_; 57 Window window_; 58 59 bool have_xfixes_; 60 int xfixes_event_base_; 61 int xfixes_error_base_; 62 63 std::unique_ptr<MouseCursor> cursor_shape_; 64 }; 65 66 } // namespace webrtc 67 68 #endif // MODULES_DESKTOP_CAPTURE_LINUX_MOUSE_CURSOR_MONITOR_X11_H_ 69