Merge pull request #1309 from hokein/workspace-visible-api
Add workspace visible APIs
This commit is contained in:
commit
3b1be743ef
8 changed files with 68 additions and 0 deletions
|
@ -422,6 +422,14 @@ void Window::ShowDefinitionForSelection() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Window::SetVisibleOnAllWorkspaces(bool visible) {
|
||||||
|
return window_->SetVisibleOnAllWorkspaces(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Window::IsVisibleOnAllWorkspaces() {
|
||||||
|
return window_->IsVisibleOnAllWorkspaces();
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -492,6 +500,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)
|
||||||
|
.SetMethod("setVisibleOnAllWorkspaces",
|
||||||
|
&Window::SetVisibleOnAllWorkspaces)
|
||||||
|
.SetMethod("isVisibleOnAllWorkspaces",
|
||||||
|
&Window::IsVisibleOnAllWorkspaces)
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
.SetMethod("showDefinitionForSelection",
|
.SetMethod("showDefinitionForSelection",
|
||||||
&Window::ShowDefinitionForSelection)
|
&Window::ShowDefinitionForSelection)
|
||||||
|
|
|
@ -130,6 +130,9 @@ class Window : public mate::EventEmitter,
|
||||||
void ShowDefinitionForSelection();
|
void ShowDefinitionForSelection();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void SetVisibleOnAllWorkspaces(bool visible);
|
||||||
|
bool IsVisibleOnAllWorkspaces();
|
||||||
|
|
||||||
// APIs for WebContents.
|
// APIs for WebContents.
|
||||||
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
||||||
mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
|
mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
|
||||||
|
|
|
@ -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(bool can_dock);
|
virtual void OpenDevTools(bool can_dock);
|
||||||
|
|
|
@ -77,6 +77,9 @@ class NativeWindowMac : public NativeWindow {
|
||||||
const std::string& description) override;
|
const std::string& description) override;
|
||||||
void ShowDefinitionForSelection() override;
|
void ShowDefinitionForSelection() override;
|
||||||
|
|
||||||
|
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||||
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
|
|
||||||
// Returns true if |point| in local Cocoa coordinate system falls within
|
// Returns true if |point| in local Cocoa coordinate system falls within
|
||||||
// the draggable region.
|
// the draggable region.
|
||||||
bool IsWithinDraggableRegion(NSPoint point) const;
|
bool IsWithinDraggableRegion(NSPoint point) const;
|
||||||
|
|
|
@ -692,6 +692,21 @@ void NativeWindowMac::ShowDefinitionForSelection() {
|
||||||
rwhv->ShowDefinitionForSelection();
|
rwhv->ShowDefinitionForSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible) {
|
||||||
|
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
||||||
|
if (visible) {
|
||||||
|
collectionBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||||
|
} else {
|
||||||
|
collectionBehavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||||
|
}
|
||||||
|
[window_ setCollectionBehavior:collectionBehavior];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||||
|
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
||||||
|
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||||
|
}
|
||||||
|
|
||||||
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {
|
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {
|
||||||
if (!draggable_region_)
|
if (!draggable_region_)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -674,6 +674,23 @@ bool NativeWindowViews::IsMenuBarVisible() {
|
||||||
return menu_bar_visible_;
|
return menu_bar_visible_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible) {
|
||||||
|
window_->SetVisibleOnAllWorkspaces(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
|
||||||
|
#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() {
|
||||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +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;
|
||||||
|
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||||
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
|
|
||||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||||
|
|
||||||
|
|
|
@ -586,6 +586,20 @@ can still bring up the menu bar by pressing the single `Alt` key.
|
||||||
|
|
||||||
Returns whether the menu bar is visible.
|
Returns whether the menu bar is visible.
|
||||||
|
|
||||||
|
### BrowserWindow.setVisibleOnAllWorkspaces(visible)
|
||||||
|
|
||||||
|
* `visible` Boolean
|
||||||
|
|
||||||
|
Sets whether the window should be visible on all workspaces.
|
||||||
|
|
||||||
|
**Note:** This API does nothing on Windows.
|
||||||
|
|
||||||
|
### BrowserWindow.isVisibleOnAllWorkspaces()
|
||||||
|
|
||||||
|
Returns whether the window is visible on all workspaces.
|
||||||
|
|
||||||
|
**Note:** This API always return false on Windows.
|
||||||
|
|
||||||
## Class: WebContents
|
## Class: WebContents
|
||||||
|
|
||||||
A `WebContents` is responsible for rendering and controlling a web page.
|
A `WebContents` is responsible for rendering and controlling a web page.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue