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: Alt+Click should not toggle menu bar #29452

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions shell/browser/native_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
last_window_state_ = ui::SHOW_STATE_NORMAL;
#endif

#if defined(OS_LINUX)
// Listen to move events.
// Listen to mouse events.
aura::Window* window = GetNativeWindow();
if (window)
window->AddPreTargetHandler(this);

#if defined(OS_LINUX)
// On linux after the widget is initialized we might have to force set the
// bounds if the bounds are smaller than the current display
SetBounds(gfx::Rect(GetPosition(), bounds.size()), false);
Expand All @@ -352,11 +352,9 @@ NativeWindowViews::~NativeWindowViews() {
SetForwardMouseMessages(false);
#endif

#if defined(OS_LINUX)
aura::Window* window = GetNativeWindow();
if (window)
window->RemovePreTargetHandler(this);
#endif
}

void NativeWindowViews::SetGTKDarkThemeEnabled(bool use_dark_theme) {
Expand Down Expand Up @@ -1461,11 +1459,9 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget,
}

void NativeWindowViews::OnWidgetDestroying(views::Widget* widget) {
#if defined(OS_LINUX)
aura::Window* window = GetNativeWindow();
if (window)
window->RemovePreTargetHandler(this);
#endif
}

void NativeWindowViews::OnWidgetDestroyed(views::Widget* changed_widget) {
Expand Down Expand Up @@ -1583,17 +1579,20 @@ void NativeWindowViews::HandleKeyboardEvent(
root_view_->HandleKeyEvent(event);
}

#if defined(OS_LINUX)
void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() != ui::ET_MOUSE_PRESSED)
return;

// Alt+Click should not toggle menu bar.
root_view_->ResetAltState();

#if defined(OS_LINUX)
if (event->changed_button_flags() == ui::EF_BACK_MOUSE_BUTTON)
NotifyWindowExecuteAppCommand(kBrowserBackward);
else if (event->changed_button_flags() == ui::EF_FORWARD_MOUSE_BUTTON)
NotifyWindowExecuteAppCommand(kBrowserForward);
}
#endif
}

ui::WindowShowState NativeWindowViews::GetRestoredState() {
if (IsMaximized())
Expand Down
2 changes: 0 additions & 2 deletions shell/browser/native_window_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,8 @@ class NativeWindowViews : public NativeWindow,
content::WebContents*,
const content::NativeWebKeyboardEvent& event) override;

#if defined(OS_LINUX)
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override;
#endif

// Returns the restore state for the window.
ui::WindowShowState GetRestoredState();
Expand Down