Index: webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc |
diff --git a/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc b/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc |
index 4870bae7ff0baade0c476f670d074ee36f0b295b..22339d4221c9e48d9a55aec48a6ba8801a14e2f0 100644 |
--- a/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc |
+++ b/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc |
@@ -185,6 +185,21 @@ void MouseCursorMonitorX11::Capture() { |
(window_ == root_window || child_window != None) ? INSIDE : OUTSIDE; |
} |
+ // As the comments to GetTopLevelWindow() above indicate, in window capture, |
+ // the cursor position capture happens in |window_|, while the frame catpure |
+ // happens in |child_window|. These two windows are not alwyas same, as |
+ // window manager may add some decorations to the |window_|. So translate |
+ // the coordinate in |window_| to the coordinate space of |child_window|. |
+ if (window_ != root_window && state == INSIDE) { |
+ int translated_x, translated_y; |
+ Window unused; |
+ if (XTranslateCoordinates(display(), window_, child_window, win_x, win_y, |
+ &translated_x, &translated_y, &unused)) { |
+ win_x = translated_x; |
+ win_y = translated_y; |
+ } |
+ } |
+ |
callback_->OnMouseCursorPosition(state, |
webrtc::DesktopVector(win_x, win_y)); |
} |