blob: 9785b736b2a85d5e04c649c7e46b58e962dc7ac5 [file] [log] [blame]
sergeyu@chromium.orgaf54d4b2013-10-16 02:42:38 +00001/*
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_MOUSE_CURSOR_MONITOR_H_
12#define WEBRTC_MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_H_
13
14#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
15#include "webrtc/modules/desktop_capture/desktop_geometry.h"
16#include "webrtc/typedefs.h"
17
18namespace webrtc {
19
20class DesktopCaptureOptions;
21class DesktopFrame;
22class MouseCursor;
23
24// Captures mouse shape and position.
25class MouseCursorMonitor {
26 public:
27 enum CursorState {
28 // Cursor on top of the window including window decorations.
29 INSIDE,
30
31 // Cursor is outside of the window.
32 OUTSIDE,
33 };
34
35 enum Mode {
36 // Capture only shape of the mouse cursor, but not position.
37 SHAPE_ONLY,
38
39 // Capture both, mouse cursor shape and position.
40 SHAPE_AND_POSITION,
41 };
42
43 // Callback interface used to pass current mouse cursor position and shape.
44 class Callback {
45 public:
46 // Called in response to Capture() when the cursor shape has changed. Must
47 // take ownership of |cursor|.
48 virtual void OnMouseCursor(MouseCursor* cursor) = 0;
49
50 // Called in response to Capture(). |position| indicates cursor position
51 // relative to the |window| specified in the constructor.
52 virtual void OnMouseCursorPosition(CursorState state,
53 const DesktopVector& position) = 0;
54
55 protected:
56 virtual ~Callback() {}
57 };
58
59 virtual ~MouseCursorMonitor() {}
60
61 // Creates a capturer that notifies of mouse cursor events while the cursor is
62 // over the specified window.
63 static MouseCursorMonitor* CreateForWindow(
64 const DesktopCaptureOptions& options,
65 WindowId window);
66
67 // Creates a capturer that monitors the mouse cursor shape and position across
68 // the entire desktop.
69 //
70 // TODO(sergeyu): Provide a way to select a specific screen.
71 static MouseCursorMonitor* CreateForScreen(
72 const DesktopCaptureOptions& options);
73
74 // Initializes the monitor with the |callback|, which must remain valid until
75 // capturer is destroyed.
76 virtual void Init(Callback* callback, Mode mode) = 0;
77
78 // Captures current cursor shape and position (depending on the |mode| passed
79 // to Init()). Calls Callback::OnMouseCursor() if cursor shape has
80 // changed since the last call (or when Capture() is called for the first
81 // time) and then Callback::OnMouseCursorPosition() if mode is set to
82 // SHAPE_AND_POSITION.
83 virtual void Capture() = 0;
84};
85
86} // namespace webrtc
87
88#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_H_
89