diff options
author | mgiuca <mgiuca@chromium.org> | 2016-01-05 16:47:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-06 00:48:28 +0000 |
commit | cbfdf50792d77cf312f8ca4020f39db586778cc9 (patch) | |
tree | 8b58e3308db97e9797f8cb81e2c095eaf31acfd7 | |
parent | d80e1ac8369b436668dfe8d3ac84e4cab0d29c8f (diff) | |
download | chromium_src-cbfdf50792d77cf312f8ca4020f39db586778cc9.zip chromium_src-cbfdf50792d77cf312f8ca4020f39db586778cc9.tar.gz chromium_src-cbfdf50792d77cf312f8ca4020f39db586778cc9.tar.bz2 |
Mouse lock bubble: Position relative to browser window, not screen.
Fixes an issue where the mouse lock ("xxx wants to disable your mouse
cursor") warning prompt is clipped by the browser window but at a fixed
screen position. This could result in the bubble being completely
invisible if the browser window did not overlap the bubble area
on-screen.
BUG=514471
TEST=Make the browser window small and away from top of screen. Enter
fullscreen (both with F11 and from a website e.g. YouTube). Should
show the grey bubble just below the top of the screen.
TEST=Make the browser window small and away from top of screen. Enter
mouselock (from https://mdn.github.io/pointer-lock-demo/). Should
show the grey bubble just below the top of the browser window.
Review URL: https://codereview.chromium.org/1522823002
Cr-Commit-Position: refs/heads/master@{#367723}
3 files changed, 10 insertions, 15 deletions
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h index 5def540..f5bc4db 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h +++ b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h @@ -54,9 +54,9 @@ class ExclusiveAccessBubble : public gfx::AnimationDelegate { // Space between top of screen and popup, in simplified UI. static const int kSimplifiedPopupTopPx; - // Returns the current desirable rect for the popup window. If - // |ignore_animation_state| is true this returns the rect assuming the popup - // is fully onscreen. + // Returns the current desirable rect for the popup window in screen + // coordinates. If |ignore_animation_state| is true this returns the rect + // assuming the popup is fully onscreen. virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const = 0; virtual gfx::Point GetCursorScreenPoint() = 0; virtual bool WindowContainsPoint(gfx::Point pos) = 0; diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.cc b/chrome/browser/ui/views/exclusive_access_bubble_views.cc index 78721f3c..5028490 100644 --- a/chrome/browser/ui/views/exclusive_access_bubble_views.cc +++ b/chrome/browser/ui/views/exclusive_access_bubble_views.cc @@ -422,6 +422,7 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( popup_->Init(params); popup_->SetContentsView(view_); gfx::Size size = GetPopupRect(true).size(); + // Bounds are in screen coordinates. popup_->SetBounds(GetPopupRect(false)); // We set layout manager to nullptr to prevent the widget from sizing its // contents to the same size as itself. This prevents the widget contents from @@ -574,17 +575,11 @@ void ExclusiveAccessBubbleViews::AnimationEnded( gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect( bool ignore_animation_state) const { gfx::Size size(view_->GetPreferredSize()); - // NOTE: don't use the bounds of the root_view_. On linux GTK changing window - // size is async. Instead we use the size of the screen. - gfx::Screen* screen = gfx::Screen::GetScreenFor( - bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView()); - gfx::Rect screen_bounds = - screen->GetDisplayNearestWindow( - bubble_view_context_->GetBubbleAssociatedWidget() - ->GetNativeView()).bounds(); - int x = screen_bounds.x() + (screen_bounds.width() - size.width()) / 2; - - int top_container_bottom = screen_bounds.y(); + gfx::Rect widget_bounds = bubble_view_context_->GetBubbleAssociatedWidget() + ->GetClientAreaBoundsInScreen(); + int x = widget_bounds.x() + (widget_bounds.width() - size.width()) / 2; + + int top_container_bottom = widget_bounds.y(); if (bubble_view_context_->IsImmersiveModeEnabled()) { // Skip querying the top container height in non-immersive fullscreen // because: diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.h b/chrome/browser/ui/views/exclusive_access_bubble_views.h index 8feb2f5..ce614a8 100644 --- a/chrome/browser/ui/views/exclusive_access_bubble_views.h +++ b/chrome/browser/ui/views/exclusive_access_bubble_views.h @@ -65,7 +65,7 @@ class ExclusiveAccessBubbleViews : public ExclusiveAccessBubble, // Returns the root view containing |browser_view_|. views::View* GetBrowserRootView() const; - // FullScreenExitBubble overrides: + // ExclusiveAccessBubble overrides: void AnimationProgressed(const gfx::Animation* animation) override; void AnimationEnded(const gfx::Animation* animation) override; gfx::Rect GetPopupRect(bool ignore_animation_state) const override; |