From e41b0d4d2cec9ca6107f61b58df1bdb4b72d086c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 25 Jun 2015 13:18:36 +0800 Subject: [PATCH] Remove NativeWindow::ActivateContents --- atom/browser/api/atom_api_web_contents.cc | 3 +-- atom/browser/api/lib/browser-window.coffee | 5 +++++ atom/browser/native_window.h | 1 - atom/browser/native_window_views.cc | 7 ------- atom/browser/native_window_views.h | 1 - 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index dd059886d048..ef49218e1819 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -267,8 +267,7 @@ void WebContents::CloseContents(content::WebContents* source) { } void WebContents::ActivateContents(content::WebContents* source) { - if (type_ == BROWSER_WINDOW) - owner_window()->CloseContents(source); + Emit("activate"); } bool WebContents::IsPopupOrPanel(const content::WebContents* source) const { diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 24ae7b8deb37..4305b29e21f9 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -20,6 +20,11 @@ BrowserWindow::_init = -> @webContents.on 'move', (event, size) => @setSize size + # Hide the auto-hide menu when webContents is focused. + @webContents.on 'activate', => + if process.platform isnt 'darwin' and @isMenuBarAutoHide() and @isMenuBarVisible() + @setMenuBarVisibility false + # Redirect focus/blur event to app instance too. @on 'blur', (event) => app.emit 'browser-window-blur', event, this diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index c52a1e0a9a3e..cc14d7b1410a 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -178,7 +178,6 @@ class NativeWindow : public content::WebContentsObserver, virtual void CloseContents(content::WebContents* source); virtual void RendererUnresponsive(content::WebContents* source); virtual void RendererResponsive(content::WebContents* source); - virtual void ActivateContents(content::WebContents* contents) {} virtual void HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) {} diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e0e276fea640..b4f511877d28 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -872,13 +872,6 @@ void NativeWindowViews::GetDevToolsWindowWMClass( } #endif -void NativeWindowViews::ActivateContents(content::WebContents* contents) { - NativeWindow::ActivateContents(contents); - // Hide menu bar when web view is clicked. - if (menu_bar_autohide_ && menu_bar_visible_) - SetMenuBarVisibility(false); -} - void NativeWindowViews::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index fe4e8a8eb0b1..fa7e13c1c335 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -128,7 +128,6 @@ class NativeWindowViews : public NativeWindow, #endif // NativeWindow: - void ActivateContents(content::WebContents* contents) override; void HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) override;