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 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (!result || error_trap.GetLastErrorAndDisable() != 0) { | 178 if (!result || error_trap.GetLastErrorAndDisable() != 0) { |
179 state = OUTSIDE; | 179 state = OUTSIDE; |
180 } else { | 180 } else { |
181 // In screen mode (window_ == root_window) the mouse is always inside. | 181 // In screen mode (window_ == root_window) the mouse is always inside. |
182 // XQueryPointer() sets |child_window| to None if the cursor is outside | 182 // XQueryPointer() sets |child_window| to None if the cursor is outside |
183 // |window_|. | 183 // |window_|. |
184 state = | 184 state = |
185 (window_ == root_window || child_window != None) ? INSIDE : OUTSIDE; | 185 (window_ == root_window || child_window != None) ? INSIDE : OUTSIDE; |
186 } | 186 } |
187 | 187 |
| 188 // As the comments to GetTopLevelWindow() above indicate, in window capture, |
| 189 // the cursor position capture happens in |window_|, while the frame catpure |
| 190 // happens in |child_window|. These two windows are not alwyas same, as |
| 191 // window manager may add some decorations to the |window_|. So translate |
| 192 // the coordinate in |window_| to the coordinate space of |child_window|. |
| 193 if (window_ != root_window && state == INSIDE) { |
| 194 int translated_x, translated_y; |
| 195 Window unused; |
| 196 if (XTranslateCoordinates(display(), window_, child_window, win_x, win_y, |
| 197 &translated_x, &translated_y, &unused)) { |
| 198 win_x = translated_x; |
| 199 win_y = translated_y; |
| 200 } |
| 201 } |
| 202 |
188 callback_->OnMouseCursorPosition(state, | 203 callback_->OnMouseCursorPosition(state, |
189 webrtc::DesktopVector(win_x, win_y)); | 204 webrtc::DesktopVector(win_x, win_y)); |
190 } | 205 } |
191 } | 206 } |
192 | 207 |
193 bool MouseCursorMonitorX11::HandleXEvent(const XEvent& event) { | 208 bool MouseCursorMonitorX11::HandleXEvent(const XEvent& event) { |
194 if (have_xfixes_ && event.type == xfixes_event_base_ + XFixesCursorNotify) { | 209 if (have_xfixes_ && event.type == xfixes_event_base_ + XFixesCursorNotify) { |
195 const XFixesCursorNotifyEvent* cursor_event = | 210 const XFixesCursorNotifyEvent* cursor_event = |
196 reinterpret_cast<const XFixesCursorNotifyEvent*>(&event); | 211 reinterpret_cast<const XFixesCursorNotifyEvent*>(&event); |
197 if (cursor_event->subtype == XFixesDisplayCursorNotify) { | 212 if (cursor_event->subtype == XFixesDisplayCursorNotify) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( | 262 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( |
248 const DesktopCaptureOptions& options, | 263 const DesktopCaptureOptions& options, |
249 ScreenId screen) { | 264 ScreenId screen) { |
250 if (!options.x_display()) | 265 if (!options.x_display()) |
251 return NULL; | 266 return NULL; |
252 return new MouseCursorMonitorX11( | 267 return new MouseCursorMonitorX11( |
253 options, DefaultRootWindow(options.x_display()->display())); | 268 options, DefaultRootWindow(options.x_display()->display())); |
254 } | 269 } |
255 | 270 |
256 } // namespace webrtc | 271 } // namespace webrtc |
OLD | NEW |