[Window Capturer] Inaccurate cursor position on cinnamon

When cinnamon is used, it always wraps the application window with its own
window. Instead of (0, 0), the DesktopRect from XWindowAttributes starts from
(10, 36).
So this change considers this difference when translating the DesktopRect in
GetWindowRect() function.

Bug: chromium:778035
Change-Id: I4944b2d1e13a4c379e114fd1749d74e95a63003b
Reviewed-on: https://webrtc-review.googlesource.com/17660
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Commit-Queue: Zijie He <zijiehe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#20538}
This commit is contained in:
Zijie He 2017-10-31 17:55:56 -07:00 committed by Commit Bot
parent 884ead083b
commit 8686077102

View File

@ -237,14 +237,16 @@ bool GetWindowRect(::Display* display,
return false;
}
}
*rect = DesktopRectFromXAttributes(*attributes);
{
XErrorTrap error_trap(display);
::Window child;
if (!XTranslateCoordinates(display,
window,
attributes->root,
0,
0,
-rect->left(),
-rect->top(),
&offset_x,
&offset_y,
&child) ||
@ -252,8 +254,6 @@ bool GetWindowRect(::Display* display,
return false;
}
}
*rect = DesktopRectFromXAttributes(*attributes);
rect->Translate(offset_x, offset_y);
return true;
}