Skip to content

Commit

Permalink
Merge pull request #11467 from /issues/19210
Browse files Browse the repository at this point in the history
Fix popup bounds recompute on monitor scale change.
  • Loading branch information
aseren authored Dec 9, 2021
2 parents 770aad8 + 2c8caa4 commit ce6de9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions browser/ui/views/brave_ads/ad_notification_popup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,17 @@ void AdNotificationPopup::SaveOrigin(const gfx::Point& origin) const {
origin.y());
}

gfx::Rect AdNotificationPopup::CalculateBounds() {
gfx::Size AdNotificationPopup::CalculateViewSize() const {
DCHECK(ad_notification_view_);
gfx::Size size = ad_notification_view_->size();
DCHECK(!size.IsEmpty());

size += gfx::Size(-GetShadowMargin().width(), -GetShadowMargin().height());
return size;
}

gfx::Rect AdNotificationPopup::CalculateBounds() {
const gfx::Size size = CalculateViewSize();
const gfx::Point origin = GetOriginForSize(size);
return gfx::Rect(origin, size);
}
Expand All @@ -348,8 +353,11 @@ void AdNotificationPopup::RecomputeAlignment() {
return;
}

const gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen();
AdjustBoundsAndSnapToFitWorkAreaForWidget(GetWidget(), bounds);
const gfx::Point window_origin =
GetWidget()->GetWindowBoundsInScreen().origin();
const gfx::Size view_size = CalculateViewSize();
AdjustBoundsAndSnapToFitWorkAreaForWidget(
GetWidget(), gfx::Rect(window_origin, view_size));
}

const gfx::ShadowDetails& AdNotificationPopup::GetShadowDetails() const {
Expand Down
1 change: 1 addition & 0 deletions browser/ui/views/brave_ads/ad_notification_popup.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class AdNotificationPopup : public views::WidgetDelegateView,
gfx::Point GetOriginForSize(const gfx::Size& size);
void SaveOrigin(const gfx::Point& origin) const;

gfx::Size CalculateViewSize() const;
gfx::Rect CalculateBounds();

void RecomputeAlignment();
Expand Down

0 comments on commit ce6de9a

Please sign in to comment.