From 4d8b20415d2583d1f49dc3e39a178624dc69400e Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Thu, 9 Jan 2025 17:27:49 +0900 Subject: [PATCH] Use system context menu in vertical tab on Windows fix https://github.com/brave/brave-browser/issues/43197 It should use same context menu with horizontal tab's one in title bar area. --- .../ui/views/frame/vertical_tab_strip_region_view.cc | 10 ++++++++++ .../frame/vertical_tab_strip_root_view_browsertest.cc | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/browser/ui/views/frame/vertical_tab_strip_region_view.cc b/browser/ui/views/frame/vertical_tab_strip_region_view.cc index 22b69d5fd1c0..772d95a826ee 100644 --- a/browser/ui/views/frame/vertical_tab_strip_region_view.cc +++ b/browser/ui/views/frame/vertical_tab_strip_region_view.cc @@ -61,6 +61,10 @@ #include "ui/views/layout/layout_types.h" #include "ui/views/view_utils.h" +#if BUILDFLAG(IS_WIN) +#include "ui/views/win/hwnd_util.h" +#endif + #if !BUILDFLAG(IS_MAC) #include "chrome/app/chrome_command_ids.h" #endif @@ -1422,6 +1426,11 @@ void VerticalTabStripRegionView::ShowContextMenuForViewImpl( views::View* source, const gfx::Point& p, ui::mojom::MenuSourceType source_type) { +#if BUILDFLAG(IS_WIN) + // Use same context menu of horizontal tab's titlebar. + views::ShowSystemMenuAtScreenPixelLocation(views::HWNDForView(browser_view_), + p); +#else if (IsMenuShowing()) { return; } @@ -1434,6 +1443,7 @@ void VerticalTabStripRegionView::ShowContextMenuForViewImpl( menu_runner_->RunMenuAt(source->GetWidget(), nullptr, gfx::Rect(p, gfx::Size(0, 0)), views::MenuAnchorPosition::kTopLeft, source_type); +#endif } void VerticalTabStripRegionView::OnMenuClosed() { diff --git a/browser/ui/views/frame/vertical_tab_strip_root_view_browsertest.cc b/browser/ui/views/frame/vertical_tab_strip_root_view_browsertest.cc index 8b8f679c80aa..3234e0ee7e13 100644 --- a/browser/ui/views/frame/vertical_tab_strip_root_view_browsertest.cc +++ b/browser/ui/views/frame/vertical_tab_strip_root_view_browsertest.cc @@ -155,7 +155,8 @@ IN_PROC_BROWSER_TEST_F(VerticalTabStripRootViewBrowserTest, DragOnCurrentTab) { } // Flaky on Mac. -#if BUILDFLAG(IS_MAC) +// System menu is used on Windows. +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) #define MAYBE_ContextMenuInUnobscuredRegion \ DISABLED_ContextMenuInUnobscuredRegion #else