Update workspace visible APIs.

This commit is contained in:
Haojian Wu 2015-03-27 19:41:07 +08:00
parent 296d5c4515
commit 0342854e25
9 changed files with 16 additions and 36 deletions

View file

@ -424,7 +424,6 @@ void Window::ShowDefinitionForSelection() {
} }
#endif #endif
#if defined(OS_MACOSX) || defined(OS_LINUX)
void Window::SetVisibleOnAllWorkspaces(bool visible) { void Window::SetVisibleOnAllWorkspaces(bool visible) {
return window_->SetVisibleOnAllWorkspaces(visible); return window_->SetVisibleOnAllWorkspaces(visible);
} }
@ -432,7 +431,6 @@ void Window::SetVisibleOnAllWorkspaces(bool visible) {
bool Window::IsVisibleOnAllWorkspaces() { bool Window::IsVisibleOnAllWorkspaces() {
return window_->IsVisibleOnAllWorkspaces(); return window_->IsVisibleOnAllWorkspaces();
} }
#endif
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const { mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
return WebContents::CreateFrom(isolate, window_->GetWebContents()); return WebContents::CreateFrom(isolate, window_->GetWebContents());
@ -504,12 +502,10 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide) .SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
.SetMethod("setMenuBarVisibility", &Window::SetMenuBarVisibility) .SetMethod("setMenuBarVisibility", &Window::SetMenuBarVisibility)
.SetMethod("isMenuBarVisible", &Window::IsMenuBarVisible) .SetMethod("isMenuBarVisible", &Window::IsMenuBarVisible)
#if defined(OS_MACOSX) || defined(OS_LINUX)
.SetMethod("setVisibleOnAllWorkspaces", .SetMethod("setVisibleOnAllWorkspaces",
&Window::SetVisibleOnAllWorkspaces) &Window::SetVisibleOnAllWorkspaces)
.SetMethod("isVisibleOnAllWorkspaces", .SetMethod("isVisibleOnAllWorkspaces",
&Window::IsVisibleOnAllWorkspaces) &Window::IsVisibleOnAllWorkspaces)
#endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
.SetMethod("showDefinitionForSelection", .SetMethod("showDefinitionForSelection",
&Window::ShowDefinitionForSelection) &Window::ShowDefinitionForSelection)

View file

@ -130,10 +130,8 @@ class Window : public mate::EventEmitter,
void ShowDefinitionForSelection(); void ShowDefinitionForSelection();
#endif #endif
#if defined(OS_MACOSX) || defined(OS_LINUX)
void SetVisibleOnAllWorkspaces(bool visible); void SetVisibleOnAllWorkspaces(bool visible);
bool IsVisibleOnAllWorkspaces(); bool IsVisibleOnAllWorkspaces();
#endif
// APIs for WebContents. // APIs for WebContents.
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const; mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;

View file

@ -280,13 +280,6 @@ bool NativeWindow::IsMenuBarVisible() {
return true; return true;
} }
void NativeWindow::SetVisibleOnAllWorkspaces(bool visible) {
}
bool NativeWindow::IsVisibleOnAllWorkspaces() {
return false;
}
bool NativeWindow::HasModalDialog() { bool NativeWindow::HasModalDialog() {
return has_dialog_attached_; return has_dialog_attached_;
} }

View file

@ -144,6 +144,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void SetProgressBar(double progress) = 0; virtual void SetProgressBar(double progress) = 0;
virtual void SetOverlayIcon(const gfx::Image& overlay, virtual void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) = 0; const std::string& description) = 0;
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
virtual bool IsVisibleOnAllWorkspaces() = 0;
virtual bool IsClosed() const { return is_closed_; } virtual bool IsClosed() const { return is_closed_; }
virtual void OpenDevTools(); virtual void OpenDevTools();
@ -172,10 +174,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void SetMenuBarVisibility(bool visible); virtual void SetMenuBarVisibility(bool visible);
virtual bool IsMenuBarVisible(); virtual bool IsMenuBarVisible();
// Visible on all workspaces.
virtual void SetVisibleOnAllWorkspaces(bool visible);
virtual bool IsVisibleOnAllWorkspaces();
// The same with closing a tab in a real browser. // The same with closing a tab in a real browser.
// //
// Should be called by platform code when user want to close the window. // Should be called by platform code when user want to close the window.

View file

@ -115,8 +115,6 @@ class NativeWindowMac : public NativeWindow {
bool is_kiosk_; bool is_kiosk_;
bool is_visible_on_all_workspaces_;
NSInteger attention_request_id_; // identifier from requestUserAttention NSInteger attention_request_id_; // identifier from requestUserAttention
// The presentation options before entering kiosk mode. // The presentation options before entering kiosk mode.

View file

@ -310,7 +310,6 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
const mate::Dictionary& options) const mate::Dictionary& options)
: NativeWindow(web_contents, options), : NativeWindow(web_contents, options),
is_kiosk_(false), is_kiosk_(false),
is_visible_on_all_workspaces_(false),
attention_request_id_(0) { attention_request_id_(0) {
int width = 800, height = 600; int width = 800, height = 600;
options.Get(switches::kWidth, &width); options.Get(switches::kWidth, &width);
@ -695,7 +694,6 @@ void NativeWindowMac::ShowDefinitionForSelection() {
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible) { void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible) {
NSUInteger collectionBehavior = [window_ collectionBehavior]; NSUInteger collectionBehavior = [window_ collectionBehavior];
is_visible_on_all_workspaces_ = visible;
if (visible) { if (visible) {
collectionBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces; collectionBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
} else { } else {
@ -705,7 +703,8 @@ void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible) {
} }
bool NativeWindowMac::IsVisibleOnAllWorkspaces() { bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
return is_visible_on_all_workspaces_; NSUInteger collectionBehavior = [window_ collectionBehavior];
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
} }
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const { bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {

View file

@ -150,9 +150,6 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
menu_bar_autohide_(false), menu_bar_autohide_(false),
menu_bar_visible_(false), menu_bar_visible_(false),
menu_bar_alt_pressed_(false), menu_bar_alt_pressed_(false),
#if defined(OS_LINUX)
is_visible_on_all_workspaces_(false),
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
is_minimized_(false), is_minimized_(false),
#endif #endif
@ -678,12 +675,20 @@ bool NativeWindowViews::IsMenuBarVisible() {
} }
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible) { void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible) {
is_visible_on_all_workspaces_ = visible;
window_->SetVisibleOnAllWorkspaces(visible); window_->SetVisibleOnAllWorkspaces(visible);
} }
bool NativeWindowViews::IsVisibleOnAllWorkspaces() { bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
return is_visible_on_all_workspaces_; #if defined(USE_X11)
// Use the presence/absence of _NET_WM_STATE_STICKY in _NET_WM_STATE to
// determine whether the current window is visible on all workspaces.
XAtom sticky_atom = gfx::GetAtom("_NET_WM_STATE_STICKY");
std::vector<XAtom> atom_properties;
gfx::GetAtomArrayProperty(GetNativeWindow(), "_NET_WM_STATE", &atom_properties);
return std::find(atom_properties.begin(),
atom_properties.end(), sticky_atom) != atom_properties.end();
#endif
return false;
} }
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() { gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {

View file

@ -80,11 +80,8 @@ class NativeWindowViews : public NativeWindow,
bool IsMenuBarAutoHide() override; bool IsMenuBarAutoHide() override;
void SetMenuBarVisibility(bool visible) override; void SetMenuBarVisibility(bool visible) override;
bool IsMenuBarVisible() override; bool IsMenuBarVisible() override;
#if defined(OS_LINUX)
void SetVisibleOnAllWorkspaces(bool visible) override; void SetVisibleOnAllWorkspaces(bool visible) override;
bool IsVisibleOnAllWorkspaces() override; bool IsVisibleOnAllWorkspaces() override;
#endif
gfx::AcceleratedWidget GetAcceleratedWidget(); gfx::AcceleratedWidget GetAcceleratedWidget();
@ -154,10 +151,6 @@ class NativeWindowViews : public NativeWindow,
bool menu_bar_visible_; bool menu_bar_visible_;
bool menu_bar_alt_pressed_; bool menu_bar_alt_pressed_;
#if defined(OS_LINUX)
bool is_visible_on_all_workspaces_;
#endif
#if defined(USE_X11) #if defined(USE_X11)
scoped_ptr<GlobalMenuBarX11> global_menu_bar_; scoped_ptr<GlobalMenuBarX11> global_menu_bar_;

View file

@ -592,13 +592,13 @@ Returns whether the menu bar is visible.
Sets whether the window should be visible on all workspaces. Sets whether the window should be visible on all workspaces.
**Note:** This API is only available on Mac/Linux. **Note:** This API does nothing on Windows.
### BrowserWindow.isVisibleOnAllWorkspaces() ### BrowserWindow.isVisibleOnAllWorkspaces()
Returns whether the window is visible on all workspaces. Returns whether the window is visible on all workspaces.
**Note:** This API is only available on Mac/Linux. **Note:** This API always return false on Windows.
## Class: WebContents ## Class: WebContents