remove method transferred to set with null

This commit is contained in:
gellert 2016-11-10 11:59:25 +01:00 committed by Kevin Sawicki
parent 16253fe708
commit 2cf30c0d63
7 changed files with 35 additions and 33 deletions

View file

@ -786,12 +786,16 @@ bool Window::IsVisibleOnAllWorkspaces() {
return window_->IsVisibleOnAllWorkspaces(); return window_->IsVisibleOnAllWorkspaces();
} }
void Window::SetVibrancy(const std::string& type) { void Window::SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args) {
window_->SetVibrancy(type); std::string type;
}
void Window::RemoveVibrancy() { if (value->IsNull()) {
window_->RemoveVibrancy(); window_->SetVibrancy(std::string());
} else if (mate::ConvertFromV8(isolate(), value, &type)) {
window_->SetVibrancy(type);
} else {
args->ThrowError("Must pass a string or null");
}
} }
int32_t Window::ID() const { int32_t Window::ID() const {
@ -910,7 +914,6 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("isVisibleOnAllWorkspaces", .SetMethod("isVisibleOnAllWorkspaces",
&Window::IsVisibleOnAllWorkspaces) &Window::IsVisibleOnAllWorkspaces)
.SetMethod("setVibrancy", &Window::SetVibrancy) .SetMethod("setVibrancy", &Window::SetVibrancy)
.SetMethod("removeVibrancy", &Window::RemoveVibrancy)
#if defined(OS_WIN) #if defined(OS_WIN)
.SetMethod("hookWindowMessage", &Window::HookWindowMessage) .SetMethod("hookWindowMessage", &Window::HookWindowMessage)
.SetMethod("isWindowMessageHooked", &Window::IsWindowMessageHooked) .SetMethod("isWindowMessageHooked", &Window::IsWindowMessageHooked)

View file

@ -196,8 +196,7 @@ class Window : public mate::TrackableObject<Window>,
void SetVisibleOnAllWorkspaces(bool visible); void SetVisibleOnAllWorkspaces(bool visible);
bool IsVisibleOnAllWorkspaces(); bool IsVisibleOnAllWorkspaces();
void SetVibrancy(const std::string& type); void SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args);
void RemoveVibrancy();
int32_t ID() const; int32_t ID() const;
v8::Local<v8::Value> WebContents(v8::Isolate* isolate); v8::Local<v8::Value> WebContents(v8::Isolate* isolate);

View file

@ -340,6 +340,9 @@ void NativeWindow::SetParentWindow(NativeWindow* parent) {
parent_ = parent; parent_ = parent;
} }
void NativeWindow::SetVibrancy(const std::string& filename) {
}
void NativeWindow::FocusOnWebView() { void NativeWindow::FocusOnWebView() {
web_contents()->GetRenderViewHost()->GetWidget()->Focus(); web_contents()->GetRenderViewHost()->GetWidget()->Focus();
} }

View file

@ -162,8 +162,7 @@ class NativeWindow : public base::SupportsUserData,
virtual bool IsVisibleOnAllWorkspaces() = 0; virtual bool IsVisibleOnAllWorkspaces() = 0;
// Vibrancy API // Vibrancy API
virtual void SetVibrancy(const std::string& type) = 0; virtual void SetVibrancy(const std::string& type);
virtual void RemoveVibrancy() = 0;
// Webview APIs. // Webview APIs.
virtual void FocusOnWebView(); virtual void FocusOnWebView();

View file

@ -93,7 +93,6 @@ class NativeWindowMac : public NativeWindow,
void SetVisibleOnAllWorkspaces(bool visible) override; void SetVisibleOnAllWorkspaces(bool visible) override;
bool IsVisibleOnAllWorkspaces() override; bool IsVisibleOnAllWorkspaces() override;
void SetVibrancy(const std::string& type) override; void SetVibrancy(const std::string& type) override;
void RemoveVibrancy() override;
// content::RenderWidgetHost::InputEventObserver: // content::RenderWidgetHost::InputEventObserver:
void OnInputEvent(const blink::WebInputEvent& event) override; void OnInputEvent(const blink::WebInputEvent& event) override;

View file

@ -1208,18 +1208,27 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
void NativeWindowMac::SetVibrancy(const std::string& type) { void NativeWindowMac::SetVibrancy(const std::string& type) {
if (!(base::mac::IsOSMavericks() || base::mac::IsOSYosemiteOrLater())) return; if (!(base::mac::IsOSMavericks() || base::mac::IsOSYosemiteOrLater())) return;
NSVisualEffectView *vview = (NSVisualEffectView *)vibrant_view_; if (type.empty()) {
if (vview == nil) { if (vibrant_view_ == nil) return;
vview = [[NSVisualEffectView alloc] initWithFrame:
[[window_ contentView] bounds]];
vibrant_view_ = (NSView *)vview;
[vview setAutoresizingMask: [vibrant_view_ removeFromSuperview];
vibrant_view_ = nil;
return;
}
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view_;
if (effect_view == nil) {
effect_view = [[NSVisualEffectView alloc] initWithFrame:
[[window_ contentView] bounds]];
vibrant_view_ = (NSView*)effect_view;
[effect_view setAutoresizingMask:
NSViewWidthSizable | NSViewHeightSizable]; NSViewWidthSizable | NSViewHeightSizable];
[vview setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; [effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
[vview setState:NSVisualEffectStateActive]; [effect_view setState:NSVisualEffectStateActive];
[[window_ contentView] addSubview:vview [[window_ contentView] addSubview:effect_view
positioned:NSWindowBelow positioned:NSWindowBelow
relativeTo:nil]; relativeTo:nil];
} }
@ -1252,14 +1261,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
} }
} }
[vview setMaterial:vibrancyType]; [effect_view setMaterial:vibrancyType];
}
void NativeWindowMac::RemoveVibrancy() {
if (vibrant_view_ == nil) return;
[vibrant_view_ removeFromSuperview];
vibrant_view_ = nil;
} }
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) { void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {

View file

@ -1198,10 +1198,7 @@ Returns `BrowserWindow[]` - All child windows.
`selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See `selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See
the [macOS documentation][vibrancy-docs] for more details. the [macOS documentation][vibrancy-docs] for more details.
Adds a vibrancy effect to the browser window. Adds a vibrancy effect to the browser window. Passing `null` or an empty string
will remove the vibrancy effect on the window.
[vibrancy-docs]: https://developer.apple.com/reference/appkit/nsvisualeffectview?language=objc [vibrancy-docs]: https://developer.apple.com/reference/appkit/nsvisualeffectview?language=objc
#### `win.removeVibrancy()` _macOS_
Removes the vibrancy effect on the window.