Linux desktopCapture: fix the cursor position issue in Window sharing
On Linux, during Windwo sharing, the cursore capture may happen in the parent window of the target. And the parent window may have some decorations added by window manager(Chrome windows don't have those decorations.), so the relative cursor position to the parent window with decorations may differ to its child target window. The offset includes the height of caption bar and the around shadow and border. This problem only happens with Window sharing on Linux. The fix is to translate the coordinates from the parent window to the coordinates space of the target window. BUG=723889 Review-Url: https://codereview.webrtc.org/2889063002 Cr-Commit-Position: refs/heads/master@{#18243}
This commit is contained in:
parent
c1b5ea959e
commit
d019667c00
@ -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));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user