Skip to content

Commit

Permalink
Use system context menu in vertical tab on Windows
Browse files Browse the repository at this point in the history
fix brave/brave-browser#43197

It should use same context menu with horizontal tab's one in title bar
area.
  • Loading branch information
simonhong committed Jan 9, 2025
1 parent 3140cfb commit 4d8b204
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions browser/ui/views/frame/vertical_tab_strip_region_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d8b204

Please sign in to comment.