Add SetVisibleOnAllWorkspaces/IsVisibleOnAllWorkspaces API.
These two APIs are only available on OS X/Linux platforms.
This commit is contained in:
parent
1804466334
commit
476b61322f
8 changed files with 74 additions and 0 deletions
|
@ -424,6 +424,16 @@ void Window::ShowDefinitionForSelection() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
void Window::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
return window_->SetVisibleOnAllWorkspaces(visible);
|
||||
}
|
||||
|
||||
bool Window::IsVisibleOnAllWorkspaces() {
|
||||
return window_->IsVisibleOnAllWorkspaces();
|
||||
}
|
||||
#endif
|
||||
|
||||
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
|
||||
return WebContents::CreateFrom(isolate, window_->GetWebContents());
|
||||
}
|
||||
|
@ -494,6 +504,12 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
|
||||
.SetMethod("setMenuBarVisibility", &Window::SetMenuBarVisibility)
|
||||
.SetMethod("isMenuBarVisible", &Window::IsMenuBarVisible)
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
.SetMethod("setVisibleOnAllWorkspaces",
|
||||
&Window::SetVisibleOnAllWorkspaces)
|
||||
.SetMethod("isVisibleOnAllWorkspaces",
|
||||
&Window::IsVisibleOnAllWorkspaces)
|
||||
#endif
|
||||
#if defined(OS_MACOSX)
|
||||
.SetMethod("showDefinitionForSelection",
|
||||
&Window::ShowDefinitionForSelection)
|
||||
|
|
|
@ -130,6 +130,11 @@ class Window : public mate::EventEmitter,
|
|||
void ShowDefinitionForSelection();
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
#endif
|
||||
|
||||
// APIs for WebContents.
|
||||
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
||||
mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
|
||||
|
|
|
@ -280,6 +280,13 @@ bool NativeWindow::IsMenuBarVisible() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void NativeWindow::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
}
|
||||
|
||||
bool NativeWindow::IsVisibleOnAllWorkspaces() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NativeWindow::HasModalDialog() {
|
||||
return has_dialog_attached_;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
virtual void SetMenuBarVisibility(bool visible);
|
||||
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.
|
||||
//
|
||||
// Should be called by platform code when user want to close the window.
|
||||
|
|
|
@ -77,6 +77,9 @@ class NativeWindowMac : public NativeWindow {
|
|||
const std::string& description) override;
|
||||
void ShowDefinitionForSelection() override;
|
||||
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
// Returns true if |point| in local Cocoa coordinate system falls within
|
||||
// the draggable region.
|
||||
bool IsWithinDraggableRegion(NSPoint point) const;
|
||||
|
@ -112,6 +115,8 @@ class NativeWindowMac : public NativeWindow {
|
|||
|
||||
bool is_kiosk_;
|
||||
|
||||
bool is_visible_on_all_workspaces_;
|
||||
|
||||
NSInteger attention_request_id_; // identifier from requestUserAttention
|
||||
|
||||
// The presentation options before entering kiosk mode.
|
||||
|
|
|
@ -310,6 +310,7 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
|||
const mate::Dictionary& options)
|
||||
: NativeWindow(web_contents, options),
|
||||
is_kiosk_(false),
|
||||
is_visible_on_all_workspaces_(false),
|
||||
attention_request_id_(0) {
|
||||
int width = 800, height = 600;
|
||||
options.Get(switches::kWidth, &width);
|
||||
|
@ -692,6 +693,21 @@ void NativeWindowMac::ShowDefinitionForSelection() {
|
|||
rwhv->ShowDefinitionForSelection();
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
||||
is_visible_on_all_workspaces_ = visible;
|
||||
if (visible) {
|
||||
collectionBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||
} else {
|
||||
collectionBehavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||
}
|
||||
[window_ setCollectionBehavior:collectionBehavior];
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||
return is_visible_on_all_workspaces_;
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {
|
||||
if (!draggable_region_)
|
||||
return false;
|
||||
|
|
|
@ -150,6 +150,9 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
|
|||
menu_bar_autohide_(false),
|
||||
menu_bar_visible_(false),
|
||||
menu_bar_alt_pressed_(false),
|
||||
#if defined(OS_LINUX)
|
||||
is_visible_on_all_workspaces_(false),
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
is_minimized_(false),
|
||||
#endif
|
||||
|
@ -674,6 +677,15 @@ bool NativeWindowViews::IsMenuBarVisible() {
|
|||
return menu_bar_visible_;
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetVisibleOnAllWorkspaces(bool visible) {
|
||||
is_visible_on_all_workspaces_ = visible;
|
||||
window_->SetVisibleOnAllWorkspaces(visible);
|
||||
}
|
||||
|
||||
bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
|
||||
return is_visible_on_all_workspaces_;
|
||||
}
|
||||
|
||||
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||
}
|
||||
|
|
|
@ -81,6 +81,11 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetMenuBarVisibility(bool visible) override;
|
||||
bool IsMenuBarVisible() override;
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
#endif
|
||||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||
|
||||
SkRegion* draggable_region() const { return draggable_region_.get(); }
|
||||
|
@ -149,6 +154,10 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool menu_bar_visible_;
|
||||
bool menu_bar_alt_pressed_;
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
bool is_visible_on_all_workspaces_;
|
||||
#endif
|
||||
|
||||
#if defined(USE_X11)
|
||||
scoped_ptr<GlobalMenuBarX11> global_menu_bar_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue