Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix popup bounds recompute on monitor scale change. #11467

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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