From 29abba824d2a7ee836ebd4fe843b206016b4ff92 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 18 Aug 2014 16:14:28 +0800 Subject: [PATCH] A little cleanup. --- atom.gyp | 4 ++-- atom/browser/native_window_views.cc | 30 +++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/atom.gyp b/atom.gyp index e880d1269c1..44e5e3e8b48 100644 --- a/atom.gyp +++ b/atom.gyp @@ -150,12 +150,12 @@ 'atom/browser/ui/views/global_menu_bar_x11.h', 'atom/browser/ui/views/menu_bar.cc', 'atom/browser/ui/views/menu_bar.h', - 'atom/browser/ui/views/submenu_button.cc', - 'atom/browser/ui/views/submenu_button.h', 'atom/browser/ui/views/menu_delegate.cc', 'atom/browser/ui/views/menu_delegate.h', 'atom/browser/ui/views/menu_layout.cc', 'atom/browser/ui/views/menu_layout.h', + 'atom/browser/ui/views/submenu_button.cc', + 'atom/browser/ui/views/submenu_button.h', 'atom/browser/ui/views/win_frame_view.cc', 'atom/browser/ui/views/win_frame_view.h', 'atom/browser/ui/win/notify_icon_host.cc', diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index a2702d36ebe..efadac5c46b 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -572,22 +572,24 @@ void NativeWindowViews::HandleKeyboardEvent( const content::NativeWebKeyboardEvent& event) { keyboard_event_handler_->HandleKeyboardEvent(event, GetFocusManager()); - if (menu_bar_) { - // Toggle accelerator when "Alt" is pressed. - if (menu_bar_visible_ && IsAltKey(event)) - menu_bar_->SetAcceleratorVisibility( - event.type == blink::WebInputEvent::RawKeyDown); + if (!menu_bar_) + return; - // Show the submenu when "Alt+Key" is pressed. - if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) && - IsAltModifier(event)) { - if (!menu_bar_visible_ && - (menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1)) { - SetMenuBarVisibility(true); - Layout(); - } - menu_bar_->ActivateAccelerator(event.windowsKeyCode); + // Show accelerator when "Alt" is pressed. + if (menu_bar_visible_ && IsAltKey(event)) + menu_bar_->SetAcceleratorVisibility( + event.type == blink::WebInputEvent::RawKeyDown); + + // Show the submenu when "Alt+Key" is pressed. + if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) && + IsAltModifier(event)) { + if (!menu_bar_visible_ && + (menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1)) { + SetMenuBarVisibility(true); + Layout(); } + menu_bar_->ActivateAccelerator(event.windowsKeyCode); + return; } if (!menu_bar_autohide_)