OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h" | 11 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 | 17 |
18 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
19 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 19 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
20 #include "webrtc/modules/desktop_capture/mouse_cursor.h" | 20 #include "webrtc/modules/desktop_capture/mouse_cursor.h" |
21 #include "webrtc/modules/desktop_capture/win/cursor.h" | 21 #include "webrtc/modules/desktop_capture/win/cursor.h" |
22 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" | 22 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" |
23 #include "webrtc/system_wrappers/include/logging.h" | |
24 | 23 |
25 namespace webrtc { | 24 namespace webrtc { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 bool IsSameCursorShape(const CURSORINFO& left, const CURSORINFO& right) { | 28 bool IsSameCursorShape(const CURSORINFO& left, const CURSORINFO& right) { |
30 // If the cursors are not showing, we do not care the hCursor handle. | 29 // If the cursors are not showing, we do not care the hCursor handle. |
31 return left.flags == right.flags && | 30 return left.flags == right.flags && |
32 (left.flags != CURSOR_SHOWING || | 31 (left.flags != CURSOR_SHOWING || |
33 left.hCursor == right.hCursor); | 32 left.hCursor == right.hCursor); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 94 |
96 desktop_dc_ = GetDC(NULL); | 95 desktop_dc_ = GetDC(NULL); |
97 } | 96 } |
98 | 97 |
99 void MouseCursorMonitorWin::Capture() { | 98 void MouseCursorMonitorWin::Capture() { |
100 assert(callback_); | 99 assert(callback_); |
101 | 100 |
102 CURSORINFO cursor_info; | 101 CURSORINFO cursor_info; |
103 cursor_info.cbSize = sizeof(CURSORINFO); | 102 cursor_info.cbSize = sizeof(CURSORINFO); |
104 if (!GetCursorInfo(&cursor_info)) { | 103 if (!GetCursorInfo(&cursor_info)) { |
105 LOG_F(LS_ERROR) << "Unable to get cursor info. Error = " << GetLastError(); | |
106 return; | 104 return; |
107 } | 105 } |
108 | 106 |
109 if (!IsSameCursorShape(cursor_info, last_cursor_)) { | 107 if (!IsSameCursorShape(cursor_info, last_cursor_)) { |
110 if (cursor_info.flags == CURSOR_SUPPRESSED) { | 108 if (cursor_info.flags == CURSOR_SUPPRESSED) { |
111 // The cursor is intentionally hidden now, send an empty bitmap. | 109 // The cursor is intentionally hidden now, send an empty bitmap. |
112 last_cursor_ = cursor_info; | 110 last_cursor_ = cursor_info; |
113 callback_->OnMouseCursor(new MouseCursor( | 111 callback_->OnMouseCursor(new MouseCursor( |
114 new BasicDesktopFrame(DesktopSize()), DesktopVector())); | 112 new BasicDesktopFrame(DesktopSize()), DesktopVector())); |
115 } else { | 113 } else { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 return new MouseCursorMonitorWin(reinterpret_cast<HWND>(window)); | 196 return new MouseCursorMonitorWin(reinterpret_cast<HWND>(window)); |
199 } | 197 } |
200 | 198 |
201 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( | 199 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( |
202 const DesktopCaptureOptions& options, | 200 const DesktopCaptureOptions& options, |
203 ScreenId screen) { | 201 ScreenId screen) { |
204 return new MouseCursorMonitorWin(screen); | 202 return new MouseCursorMonitorWin(screen); |
205 } | 203 } |
206 | 204 |
207 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |