diff --git a/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc b/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc index 4870bae7ff..22339d4221 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)); }