Commit a47218f5 authored by James Hollyer's avatar James Hollyer Committed by Commit Bot

Use a smaller capture region in Pointer Lock

The capture region that held the mouse inside the chrome window was the
full size of the window. This caused issues while when the invisible
mouse hit the edge of the window it could fire certain events and cause
strange things to happen. For example the linked bug discusses an "x"
appearing when you are also in fullscreen. There are also some dual
monitor setups that have consistently proven that the mouse moves just
out of the window and onto the other monitor while in fullscreen. To
solve this this CL is adding a 5 pixel border to the edge of the capture
region to give some wiggle room for the small Windows errors and to stop
events from firing when the mouse hits the edge of the window.

Bug: 1107507
Change-Id: Ia2314f7726b5a18d96800a9efcd990bace564ef7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343005
Commit-Queue: James Hollyer <jameshollyer@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797072}
parent 02b1d356
......@@ -54,6 +54,16 @@ namespace {
// of the border area, in percentage of the corresponding dimension.
const int kMouseLockBorderPercentage = 15;
// While the mouse is locked we want the invisible mouse to stay within the
// confines of the screen so we keep it in a capture region the size of the
// screen. However, on windows when the mouse hits the edge of the screen some
// events trigger and cause strange issues to occur. To stop those events from
// occuring we add a small border around the edge of the capture region.
// This constant controls how many pixels wide that border is.
#if defined(OS_WIN)
const int KMouseCaptureRegionBorder = 5;
#endif
#if defined(OS_WIN)
// A callback function for EnumThreadWindows to enumerate and dismiss
// any owned popup windows.
......@@ -152,6 +162,10 @@ void RenderWidgetHostViewEventHandler::UpdateMouseLockRegion() {
display::Screen::GetScreen()
->DIPToScreenRectInWindow(window_, window_->GetBoundsInScreen())
.ToRECT();
window_rect.left += KMouseCaptureRegionBorder;
window_rect.right -= KMouseCaptureRegionBorder;
window_rect.top += KMouseCaptureRegionBorder;
window_rect.bottom -= KMouseCaptureRegionBorder;
::ClipCursor(&window_rect);
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment