Skip to content

Commit 3e9b099

Browse files
committed
Fixed cursor is not changed to resize when hovered to sidebar resize area
fix brave/brave-browser#43507 On macOS, previous cursor is not cleared when mouse goes out. So, we can see resize cursor only once. To fix, clear current cursor manually. Widget doesn't change its current cursor if it's same with requested one.
1 parent d535da5 commit 3e9b099

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

browser/ui/views/side_panel/brave_side_panel_resize_widget.cc

+34-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include "brave/browser/ui/views/frame/brave_browser_view.h"
1111
#include "brave/browser/ui/views/side_panel/brave_side_panel.h"
12+
#include "build/build_config.h"
13+
#include "ui/base/metadata/metadata_impl_macros.h"
1214
#include "ui/views/controls/resize_area.h"
1315
#include "ui/views/layout/fill_layout.h"
1416
#include "ui/views/widget/widget.h"
@@ -18,6 +20,31 @@
1820
#include "ui/views/view_constants_aura.h"
1921
#endif
2022

23+
#if BUILDFLAG(IS_MAC)
24+
namespace {
25+
26+
// Subclassed to clear resize cursor when goes out.
27+
// On macOS, it seems not clear widget's current cursor(resize) when mouse goes
28+
// out. Because of that, cursor is not changed when mouse moves in. As this
29+
// resize widget is located over the Maybe this problem happens because it's
30+
// located above WebView.
31+
class CustomResizeArea : public views::ResizeArea {
32+
METADATA_HEADER(CustomResizeArea, views::ResizeArea)
33+
public:
34+
using ResizeArea::ResizeArea;
35+
36+
void OnMouseExited(const ui::MouseEvent& event) override {
37+
ResizeArea::OnMouseExited(event);
38+
GetWidget()->SetCursor(ui::Cursor());
39+
}
40+
};
41+
42+
BEGIN_METADATA(CustomResizeArea)
43+
END_METADATA
44+
45+
} // namespace
46+
#endif
47+
2148
SidePanelResizeWidget::SidePanelResizeWidget(
2249
BraveSidePanel* panel,
2350
BraveBrowserView* browser_view,
@@ -38,8 +65,13 @@ SidePanelResizeWidget::SidePanelResizeWidget(
3865
params.activatable = views::Widget::InitParams::Activatable::kNo;
3966
widget_->Init(std::move(params));
4067

41-
auto resize_area = std::make_unique<views::ResizeArea>(resize_area_delegate);
42-
widget_->SetContentsView(std::move(resize_area));
68+
#if BUILDFLAG(IS_MAC)
69+
widget_->SetContentsView(
70+
std::make_unique<CustomResizeArea>(resize_area_delegate));
71+
#else
72+
widget_->SetContentsView(
73+
std::make_unique<views::ResizeArea>(resize_area_delegate));
74+
#endif
4375

4476
#if defined(USE_AURA)
4577
widget_->GetNativeView()->SetProperty(views::kHostViewKey,

0 commit comments

Comments
 (0)