From 141894aacd766b37231dc9ce00b5b780bf91c713 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 17 Oct 2014 22:51:20 +0800 Subject: [PATCH] Implement BrowserWindow::ShowInactive --- atom/browser/api/atom_api_window.cc | 5 +++++ atom/browser/api/atom_api_window.h | 1 + atom/browser/native_window.h | 1 + atom/browser/native_window_mac.h | 1 + atom/browser/native_window_mac.mm | 4 ++++ atom/browser/native_window_views.cc | 4 ++++ atom/browser/native_window_views.h | 1 + 7 files changed, 17 insertions(+) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 40498153c3fe..7bfffff1a5b4 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -153,6 +153,10 @@ void Window::Show() { window_->Show(); } +void Window::ShowInactive() { + window_->ShowInactive(); +} + void Window::Hide() { window_->Hide(); } @@ -388,6 +392,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("focus", &Window::Focus) .SetMethod("isFocused", &Window::IsFocused) .SetMethod("show", &Window::Show) + .SetMethod("showInactive", &Window::ShowInactive) .SetMethod("hide", &Window::Hide) .SetMethod("isVisible", &Window::IsVisible) .SetMethod("maximize", &Window::Maximize) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 25ea3700cf81..8681e7571f90 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -59,6 +59,7 @@ class Window : public mate::EventEmitter, void Focus(); bool IsFocused(); void Show(); + void ShowInactive(); void Hide(); bool IsVisible(); void Maximize(); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 0a2abb7059c8..2b9fbfa09b4e 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -101,6 +101,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, virtual void Focus(bool focus) = 0; virtual bool IsFocused() = 0; virtual void Show() = 0; + virtual void ShowInactive() = 0; virtual void Hide() = 0; virtual bool IsVisible() = 0; virtual void Maximize() = 0; diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index ecdabc800cd5..32df2ed8b4d4 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -28,6 +28,7 @@ class NativeWindowMac : public NativeWindow { virtual void Focus(bool focus) OVERRIDE; virtual bool IsFocused() OVERRIDE; virtual void Show() OVERRIDE; + virtual void ShowInactive() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsVisible() OVERRIDE; virtual void Maximize() OVERRIDE; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 0c4eec816c0c..167b3a1c5da2 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -334,6 +334,10 @@ bool NativeWindowMac::IsFocused() { } void NativeWindowMac::Show() { + [window_ makeKeyAndOrderFront:nil]; +} + +void NativeWindowMac::ShowInactive() { [window_ orderFrontRegardless]; } diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 77ff969140cc..ec5a9a666a9a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -232,6 +232,10 @@ bool NativeWindowViews::IsFocused() { } void NativeWindowViews::Show() { + window_->Show(); +} + +void NativeWindowViews::ShowInactive() { window_->ShowInactive(); } diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index b38769c39265..faf9bc55aa04 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -38,6 +38,7 @@ class NativeWindowViews : public NativeWindow, virtual void Focus(bool focus) OVERRIDE; virtual bool IsFocused() OVERRIDE; virtual void Show() OVERRIDE; + virtual void ShowInactive() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsVisible() OVERRIDE; virtual void Maximize() OVERRIDE;