Merge pull request #717 from atom/show-inactive
Add BrowserWindow.showInactive()
This commit is contained in:
commit
53b83eba8c
9 changed files with 31 additions and 2 deletions
|
@ -153,6 +153,10 @@ void Window::Show() {
|
||||||
window_->Show();
|
window_->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::ShowInactive() {
|
||||||
|
window_->ShowInactive();
|
||||||
|
}
|
||||||
|
|
||||||
void Window::Hide() {
|
void Window::Hide() {
|
||||||
window_->Hide();
|
window_->Hide();
|
||||||
}
|
}
|
||||||
|
@ -388,6 +392,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("focus", &Window::Focus)
|
.SetMethod("focus", &Window::Focus)
|
||||||
.SetMethod("isFocused", &Window::IsFocused)
|
.SetMethod("isFocused", &Window::IsFocused)
|
||||||
.SetMethod("show", &Window::Show)
|
.SetMethod("show", &Window::Show)
|
||||||
|
.SetMethod("showInactive", &Window::ShowInactive)
|
||||||
.SetMethod("hide", &Window::Hide)
|
.SetMethod("hide", &Window::Hide)
|
||||||
.SetMethod("isVisible", &Window::IsVisible)
|
.SetMethod("isVisible", &Window::IsVisible)
|
||||||
.SetMethod("maximize", &Window::Maximize)
|
.SetMethod("maximize", &Window::Maximize)
|
||||||
|
|
|
@ -59,6 +59,7 @@ class Window : public mate::EventEmitter,
|
||||||
void Focus();
|
void Focus();
|
||||||
bool IsFocused();
|
bool IsFocused();
|
||||||
void Show();
|
void Show();
|
||||||
|
void ShowInactive();
|
||||||
void Hide();
|
void Hide();
|
||||||
bool IsVisible();
|
bool IsVisible();
|
||||||
void Maximize();
|
void Maximize();
|
||||||
|
|
|
@ -101,6 +101,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void Focus(bool focus) = 0;
|
virtual void Focus(bool focus) = 0;
|
||||||
virtual bool IsFocused() = 0;
|
virtual bool IsFocused() = 0;
|
||||||
virtual void Show() = 0;
|
virtual void Show() = 0;
|
||||||
|
virtual void ShowInactive() = 0;
|
||||||
virtual void Hide() = 0;
|
virtual void Hide() = 0;
|
||||||
virtual bool IsVisible() = 0;
|
virtual bool IsVisible() = 0;
|
||||||
virtual void Maximize() = 0;
|
virtual void Maximize() = 0;
|
||||||
|
|
|
@ -28,6 +28,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
virtual void Focus(bool focus) OVERRIDE;
|
virtual void Focus(bool focus) OVERRIDE;
|
||||||
virtual bool IsFocused() OVERRIDE;
|
virtual bool IsFocused() OVERRIDE;
|
||||||
virtual void Show() OVERRIDE;
|
virtual void Show() OVERRIDE;
|
||||||
|
virtual void ShowInactive() OVERRIDE;
|
||||||
virtual void Hide() OVERRIDE;
|
virtual void Hide() OVERRIDE;
|
||||||
virtual bool IsVisible() OVERRIDE;
|
virtual bool IsVisible() OVERRIDE;
|
||||||
virtual void Maximize() OVERRIDE;
|
virtual void Maximize() OVERRIDE;
|
||||||
|
|
|
@ -334,6 +334,10 @@ bool NativeWindowMac::IsFocused() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::Show() {
|
void NativeWindowMac::Show() {
|
||||||
|
[window_ makeKeyAndOrderFront:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::ShowInactive() {
|
||||||
[window_ orderFrontRegardless];
|
[window_ orderFrontRegardless];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,10 @@ bool NativeWindowViews::IsFocused() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::Show() {
|
void NativeWindowViews::Show() {
|
||||||
|
window_->Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindowViews::ShowInactive() {
|
||||||
window_->ShowInactive();
|
window_->ShowInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ class NativeWindowViews : public NativeWindow,
|
||||||
virtual void Focus(bool focus) OVERRIDE;
|
virtual void Focus(bool focus) OVERRIDE;
|
||||||
virtual bool IsFocused() OVERRIDE;
|
virtual bool IsFocused() OVERRIDE;
|
||||||
virtual void Show() OVERRIDE;
|
virtual void Show() OVERRIDE;
|
||||||
|
virtual void ShowInactive() OVERRIDE;
|
||||||
virtual void Hide() OVERRIDE;
|
virtual void Hide() OVERRIDE;
|
||||||
virtual bool IsVisible() OVERRIDE;
|
virtual bool IsVisible() OVERRIDE;
|
||||||
virtual void Maximize() OVERRIDE;
|
virtual void Maximize() OVERRIDE;
|
||||||
|
|
|
@ -232,7 +232,11 @@ Returns whether the window is focused.
|
||||||
|
|
||||||
### BrowserWindow.show()
|
### BrowserWindow.show()
|
||||||
|
|
||||||
Shows the window.
|
Shows and gives focus to the window.
|
||||||
|
|
||||||
|
### BrowserWindow.showInactive()
|
||||||
|
|
||||||
|
Shows the window but doesn't focus on it.
|
||||||
|
|
||||||
### BrowserWindow.hide()
|
### BrowserWindow.hide()
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ remote = require 'remote'
|
||||||
|
|
||||||
BrowserWindow = remote.require 'browser-window'
|
BrowserWindow = remote.require 'browser-window'
|
||||||
|
|
||||||
|
isCI = remote.process.argv[1] == '--ci'
|
||||||
|
|
||||||
describe 'browser-window module', ->
|
describe 'browser-window module', ->
|
||||||
fixtures = path.resolve __dirname, 'fixtures'
|
fixtures = path.resolve __dirname, 'fixtures'
|
||||||
|
|
||||||
|
@ -57,8 +59,14 @@ describe 'browser-window module', ->
|
||||||
w.loadUrl 'about:blank'
|
w.loadUrl 'about:blank'
|
||||||
|
|
||||||
describe 'BrowserWindow.show()', ->
|
describe 'BrowserWindow.show()', ->
|
||||||
it 'should not focus window', ->
|
it 'should focus on window', ->
|
||||||
|
return if isCI
|
||||||
w.show()
|
w.show()
|
||||||
|
assert w.isFocused()
|
||||||
|
|
||||||
|
describe 'BrowserWindow.showInactive()', ->
|
||||||
|
it 'should not focus on window', ->
|
||||||
|
w.showInactive()
|
||||||
assert !w.isFocused()
|
assert !w.isFocused()
|
||||||
|
|
||||||
describe 'BrowserWindow.focus()', ->
|
describe 'BrowserWindow.focus()', ->
|
||||||
|
|
Loading…
Reference in a new issue