Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hjanuschka/76a8b1d0fac4bd396fe4be91f205d326 to your computer and use it in GitHub Desktop.

Select an option

Save hjanuschka/76a8b1d0fac4bd396fe4be91f205d326 to your computer and use it in GitHub Desktop.
Fix bubble positioning in app windows (Chromium patch)
From b29d44529f19aa24beeaf197838793b8d1b3d1cf Mon Sep 17 00:00:00 2001
From: Helmut Januschka <[email protected]>
Date: Sun, 1 Feb 2026 23:41:10 +0100
Subject: [PATCH] Fix bubble positioning in app windows
When the toolbar isn't visible (e.g., --app mode), fall back to anchoring
bubbles to the contents view and reposition them to the top-right corner.
---
.../location_bar_bubble_delegate_view.cc | 15 +++++++++++++++
chrome/browser/ui/views/toolbar/toolbar_view.cc | 9 +++++++++
2 files changed, 24 insertions(+)
diff --git a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc
index 01a5846cd6d9d..203c9c56c9b8a 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc
@@ -138,6 +138,21 @@ void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason,
GetBubbleFrameView()->SetPreferredArrowAdjustment(
views::BubbleFrameView::PreferredArrowAdjustment::kOffset);
+ // When the anchor view is the contents web view (fallback when toolbar isn't
+ // visible, e.g., in app windows), reposition the bubble to the top-right
+ // corner of the window instead of anchoring to the full contents area.
+ if (auto* anchor_view = GetAnchorView()) {
+ if (auto* widget = anchor_view->GetWidget()) {
+ if (auto* browser_view = BrowserView::GetBrowserViewForNativeWindow(
+ widget->GetNativeWindow())) {
+ if (anchor_view == browser_view->contents_web_view()) {
+ SetAnchorView(nullptr);
+ AdjustForFullscreen(widget->GetWindowBoundsInScreen());
+ }
+ }
+ }
+ }
+
if (reason == USER_GESTURE) {
GetWidget()->Show();
} else {
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
index 85b5fd39dfb5a..27176a3177451 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -1090,6 +1090,15 @@ views::View* ToolbarView::GetAnchorView(
views::BubbleAnchor ToolbarView::GetBubbleAnchor(
std::optional<actions::ActionId> action_id) {
if (views::View* view = GetAnchorView(action_id)) {
+ // In some window modes (notably app windows) the location bar might exist
+ // as a View but not be drawn. Anchoring bubbles to a non-drawn view can
+ // result in invalid bubble bounds (e.g. on Ozone/Wayland).
+ //
+ // Fall back to anchoring to the contents view in that case.
+ if (!view->IsDrawn() && browser_view_ &&
+ browser_view_->contents_web_view()) {
+ return browser_view_->contents_web_view();
+ }
return view;
}
return nullptr;
--
2.52.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment