Skip to content

Commit 2020b17

Browse files
committed
Merge commit 'fbefe51ee62199a60ddbd5823134697da81526d0' into nw12
Conflicts: src/nw_version.h
2 parents 7a645c5 + fbefe51 commit 2020b17

22 files changed

+222
-10
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
0.11.3 / 12-16-2014
2+
===================
3+
- new method in 'new-win-policy' event handler to control the options for new popup windows
4+
- Fix: nw methods cannot be called from normal frames
5+
- Extend Tray click event with position (Thanks to Marco Fabbri) (#1874)
6+
- [OSX] Fix Window.focus() not taking focus (#2724)
7+
- Add API methods and support for styling of icons (Tray, MenuItem) under Mac OS X (Yosemite) Dark Mode (#2775)
8+
- [OSX] Fix alticon property of Tray not being updated properly (#703)
9+
- Add Window.setVisibleOnAllWorkspaces API (#2722)
10+
- Fix #2469: Changed Window.open to ignore slashes in parameters
11+
- fix crash in window.open in some cases
12+
113
0.11.2 / 11-26-2014
214
===================
315
- Support window transparency (#132, Thanks to Jefry Tedjokusumo)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ It's created and developed in the Intel Open Source Technology Center.
1616

1717
* Apps written in modern HTML5, CSS3, JS and WebGL.
1818
* Complete support for [Node.js APIs](http://nodejs.org/api/) and all its [third party modules](https://npmjs.org).
19-
* Good performance: Node and WebKit runs in the same thread: Function calls are made straightforward; objects are in the same heap and can just reference each other;
19+
* Good performance: Node and WebKit run in the same thread: Function calls are made straightforward; objects are in the same heap and can just reference each other;
2020
* Easy to package and distribute apps.
2121
* Available on Linux, Mac OS X and Windows
2222

2323
## Downloads
24-
* **v0.11.2:** (Nov 26, 2014, based off of Node v0.11.13, Chromium 38.0.2125.104): [release notes](https://groups.google.com/d/msg/node-webkit/hpG-AgsATTI/Oc-qhC3rMnkJ)
24+
* **v0.11.3:** (Dec 16, 2014, based off of Node v0.11.13, Chromium 38.0.2125.104): [release notes](https://groups.google.com/d/msg/node-webkit/7zl5_LcPhFk/R3YjrZUqepIJ)
2525

26-
* Linux: [32bit](http://dl.node-webkit.org/v0.11.2/node-webkit-v0.11.2-linux-ia32.tar.gz) / [64bit](http://dl.node-webkit.org/v0.11.2/node-webkit-v0.11.2-linux-x64.tar.gz)
27-
* Windows: [32bit](http://dl.node-webkit.org/v0.11.2/node-webkit-v0.11.2-win-ia32.zip) / [64bit](http://dl.node-webkit.org/v0.11.2/node-webkit-v0.11.2-win-x64.zip)
28-
* Mac 10.7+: [32bit](http://dl.node-webkit.org/v0.11.2/node-webkit-v0.11.2-osx-ia32.zip) / [64bit](http://dl.node-webkit.org/v0.11.2/node-webkit-v0.11.2-osx-x64.zip)
26+
* Linux: [32bit](http://dl.node-webkit.org/v0.11.3/node-webkit-v0.11.3-linux-ia32.tar.gz) / [64bit](http://dl.node-webkit.org/v0.11.3/node-webkit-v0.11.3-linux-x64.tar.gz)
27+
* Windows: [32bit](http://dl.node-webkit.org/v0.11.3/node-webkit-v0.11.3-win-ia32.zip) / [64bit](http://dl.node-webkit.org/v0.11.3/node-webkit-v0.11.3-win-x64.zip)
28+
* Mac 10.7+: [32bit](http://dl.node-webkit.org/v0.11.3/node-webkit-v0.11.3-osx-ia32.zip) / [64bit](http://dl.node-webkit.org/v0.11.3/node-webkit-v0.11.3-osx-x64.zip)
2929

3030
* **0.8.6:** (Apr 18, 2014, based off of Node v0.10.22, Chrome 30.0.1599.66) **If your native Node module works only with Node v0.10, then you should use node-webkit v0.8.x, which is also a maintained branch. [More info](https://groups.google.com/d/msg/node-webkit/2OJ1cEMPLlA/09BvpTagSA0J)**
3131
[release notes](https://groups.google.com/d/msg/node-webkit/CLPkgfV-i7s/hwkkQuJ1kngJ)

src/api/bindings_common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using blink::WebView;
4040
namespace {
4141
RenderView* GetRenderView(v8::Handle<v8::Context> ctx) {
4242
WebLocalFrame* frame = WebLocalFrame::frameForContext(ctx);
43-
if (!frame)
43+
if (!frame || !frame->isNodeJS())
4444
return NULL;
4545

4646
WebView* view = frame->view();

src/api/dispatcher_bindings.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,13 @@ void DispatcherBindings::CallStaticMethod(
453453
// static
454454
void DispatcherBindings::CrashRenderer(
455455
const v8::FunctionCallbackInfo<v8::Value>& args) {
456+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
457+
RenderView* render_view = GetCurrentRenderView();
458+
if (!render_view) {
459+
args.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate,
460+
"Unable to get render view in CallObjectMethod"))));
461+
return;
462+
}
456463
int* ptr = NULL;
457464
*ptr = 1;
458465
}

src/api/menuitem/menuitem.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ void MenuItem::Call(const std::string& method,
5050
std::string icon;
5151
arguments.GetString(0, &icon);
5252
SetIcon(icon);
53+
} else if (method == "SetIconIsTemplate") {
54+
bool isTemplate;
55+
arguments.GetBoolean(0, &isTemplate);
56+
SetIconIsTemplate(isTemplate);
5357
} else if (method == "SetTooltip") {
5458
std::string tooltip;
5559
arguments.GetString(0, &tooltip);

src/api/menuitem/menuitem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ class MenuItem : public Base {
8282
void SetChecked(bool checked);
8383
void SetSubmenu(Menu* sub_menu);
8484

85+
// Template icon works only on Mac OS X
86+
void SetIconIsTemplate(bool isTemplate);
87+
8588
#if defined(OS_MACOSX)
8689
std::string type_;
8790

8891
NSMenuItem* menu_item_;
8992
MenuItemDelegate* delegate_;
93+
bool iconIsTemplate;
9094

9195
#elif defined(OS_WIN) || defined(OS_LINUX)
9296
friend class MenuDelegate;

src/api/menuitem/menuitem.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ function MenuItem(option) {
4646
option.icon = nw.getAbsolutePath(option.icon);
4747
}
4848

49+
if (option.hasOwnProperty('iconIsTemplate'))
50+
option.iconIsTemplate = Boolean(option.iconIsTemplate);
51+
else
52+
option.iconIsTemplate = true;
53+
4954
if (option.hasOwnProperty('tooltip'))
5055
option.tooltip = String(option.tooltip);
5156

@@ -116,6 +121,14 @@ MenuItem.prototype.__defineSetter__('icon', function(val) {
116121
this.handleSetter('icon', 'SetIcon', String, real_path);
117122
});
118123

124+
MenuItem.prototype.__defineGetter__('iconIsTemplate', function() {
125+
return this.handleGetter('iconIsTemplate');
126+
});
127+
128+
MenuItem.prototype.__defineSetter__('iconIsTemplate', function(val) {
129+
this.handleSetter('iconIsTemplate', 'SetIconIsTemplate', Boolean, val);
130+
});
131+
119132
MenuItem.prototype.__defineGetter__('tooltip', function() {
120133
return this.handleGetter('tooltip');
121134
});

src/api/menuitem/menuitem_gtk.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ void MenuItem::SetIcon(const std::string& icon) {
124124
}
125125
}
126126

127+
void MenuItem::SetIconIsTemplate(bool isTemplate) {
128+
}
129+
127130
void MenuItem::SetTooltip(const std::string& tooltip) {
128131
gtk_widget_set_tooltip_text(menu_item_, tooltip.c_str());
129132
}

src/api/menuitem/menuitem_mac.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
if (option.GetBoolean("enabled", &enabled))
7272
SetEnabled(enabled);
7373

74+
bool isTemplate;
75+
if (option.GetBoolean("iconIsTemplate", &isTemplate))
76+
SetIconIsTemplate(isTemplate);
77+
7478
std::string icon;
7579
if (option.GetString("icon", &icon) && !icon.empty())
7680
SetIcon(icon);
@@ -131,13 +135,20 @@
131135
if (!icon.empty()) {
132136
NSImage* image = [[NSImage alloc]
133137
initWithContentsOfFile:[NSString stringWithUTF8String:icon.c_str()]];
138+
[image setTemplate:iconIsTemplate];
134139
[menu_item_ setImage:image];
135140
[image release];
136141
} else {
137142
[menu_item_ setImage:nil];
138143
}
139144
}
140145

146+
void MenuItem::SetIconIsTemplate(bool isTemplate) {
147+
iconIsTemplate = isTemplate;
148+
if ([menu_item_ image] != nil)
149+
[[menu_item_ image] setTemplate:isTemplate];
150+
}
151+
141152
void MenuItem::SetTooltip(const std::string& tooltip) {
142153
[menu_item_ setToolTip:[NSString stringWithUTF8String:tooltip.c_str()]];
143154
}

src/api/menuitem/menuitem_views.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ void MenuItem::SetIcon(const std::string& icon) {
134134
package->GetImage(base::FilePath::FromUTF8Unsafe(icon), &icon_);
135135
}
136136

137+
void MenuItem::SetIconIsTemplate(bool isTemplate) {
138+
}
139+
137140
void MenuItem::SetTooltip(const std::string& tooltip) {
138141
tooltip_ = base::UTF8ToUTF16(tooltip);
139142
if (menu_)

src/api/tray/tray.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Tray::Tray(int id,
3737
if (option.GetString("title", &title))
3838
SetTitle(title);
3939

40+
bool areTemplates;
41+
if (option.GetBoolean("iconsAreTemplates", &areTemplates))
42+
SetIconsAreTemplates(areTemplates);
43+
4044
std::string icon;
4145
if (option.GetString("icon", &icon) && !icon.empty())
4246
SetIcon(icon);
@@ -47,7 +51,7 @@ Tray::Tray(int id,
4751

4852
std::string tooltip;
4953
if (option.GetString("tooltip", &tooltip))
50-
SetTitle(tooltip);
54+
SetTooltip(tooltip);
5155

5256
int menu_id;
5357
if (option.GetInteger("menu", &menu_id))
@@ -74,6 +78,10 @@ void Tray::Call(const std::string& method,
7478
std::string alticon;
7579
arguments.GetString(0, &alticon);
7680
SetAltIcon(alticon);
81+
} else if (method == "SetIconsAreTemplates") {
82+
bool areTemplates;
83+
arguments.GetBoolean(0, &areTemplates);
84+
SetIconsAreTemplates(areTemplates);
7785
} else if (method == "SetTooltip") {
7886
std::string tooltip;
7987
arguments.GetString(0, &tooltip);

src/api/tray/tray.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ class Tray : public Base {
6464
void Destroy();
6565
void SetTitle(const std::string& title);
6666
void SetIcon(const std::string& icon_path);
67-
void SetTooltip(const std::string& title);
67+
void SetTooltip(const std::string& tooltip);
6868
void SetMenu(Menu* menu);
6969
void Remove();
7070
// Alternate icons only work with Macs
7171
void SetAltIcon(const std::string& alticon_path);
72+
// Template icons only work with Macs
73+
void SetIconsAreTemplates(bool areTemplates);
7274

7375
#if defined(OS_MACOSX)
7476
__block NSStatusItem* status_item_;
7577
MacTrayObserver* status_observer_;
78+
bool iconsAreTemplates;
7679
#elif 0
7780
GtkStatusIcon* status_item_;
7881

src/api/tray/tray.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ function Tray(option) {
4242
option.alticon = nw.getAbsolutePath(option.alticon);
4343
}
4444

45+
if (option.hasOwnProperty('iconsAreTemplates'))
46+
option.iconsAreTemplates = Boolean(option.iconsAreTemplates);
47+
else
48+
option.iconsAreTemplates = true;
49+
4550
if (option.hasOwnProperty('tooltip'))
4651
option.tooltip = String(option.tooltip);
4752

@@ -100,7 +105,15 @@ Tray.prototype.__defineSetter__('icon', function(val) {
100105
Tray.prototype.__defineSetter__('alticon', function(val) {
101106
v8_util.getHiddenValue(this, 'option').shadowAlticon = String(val);
102107
var real_path = val == '' ? '' : nw.getAbsolutePath(val);
103-
this.handleSetter('alticon', 'SetAlticon', String, real_path);
108+
this.handleSetter('alticon', 'SetAltIcon', String, real_path);
109+
});
110+
111+
Tray.prototype.__defineGetter__('iconsAreTemplates', function() {
112+
return this.handleGetter('iconsAreTemplates');
113+
});
114+
115+
Tray.prototype.__defineSetter__('iconsAreTemplates', function(val) {
116+
this.handleSetter('iconsAreTemplates', 'SetIconsAreTemplates', Boolean, val);
104117
});
105118

106119
Tray.prototype.__defineGetter__('tooltip', function() {

src/api/tray/tray_aura.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "content/nw/src/api/menu/menu.h"
3131
#include "content/nw/src/nw_package.h"
3232
#include "content/nw/src/nw_shell.h"
33+
#include "ui/gfx/screen.h"
3334
#include "ui/gfx/image/image.h"
3435

3536
namespace nwapi {
@@ -47,6 +48,12 @@ class TrayObserver : public StatusIconObserver {
4748

4849
virtual void OnStatusIconClicked() override {
4950
base::ListValue args;
51+
base::DictionaryValue* data = new base::DictionaryValue;
52+
gfx::Point cursor_pos(
53+
gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
54+
data->SetInteger("x", cursor_pos.x());
55+
data->SetInteger("y", cursor_pos.y());
56+
args.Append(data);
5057
tray_->dispatcher_host()->SendEvent(tray_, "click", args);
5158
}
5259

@@ -107,4 +114,7 @@ void Tray::Remove() {
107114
void Tray::SetAltIcon(const std::string& alticon_path) {
108115
}
109116

117+
void Tray::SetIconsAreTemplates(bool areTemplates) {
118+
}
119+
110120
} // namespace nwapi

src/api/tray/tray_gtk.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,7 @@ void Tray::OnPopupMenu(GtkWidget* widget, guint button, guint time) {
8383
void Tray::SetAltIcon(const std::string& alticon_path) {
8484
}
8585

86+
void Tray::SetIconsAreTemplates(bool areTemplates) {
87+
}
88+
8689
} // namespace nwapi

src/api/tray/tray_mac.mm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "base/values.h"
2424
#import <Cocoa/Cocoa.h>
25+
#include "ui/gfx/screen.h"
2526
#include "content/nw/src/api/dispatcher_host.h"
2627
#include "content/nw/src/api/menu/menu.h"
2728

@@ -40,6 +41,15 @@ - (void)setBacking:(nwapi::Tray*)newTray {
4041
}
4142
- (void)onClick:(id)sender {
4243
base::ListValue args;
44+
base::DictionaryValue* data = new base::DictionaryValue;
45+
// Get the position of the frame of the NSStatusItem
46+
NSPoint pos = ([[[NSApp currentEvent] window] frame]).origin;
47+
// Flip coordinates to gfx (0,0 in top-left corner) using primary screen.
48+
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
49+
pos.y = NSMaxY([screen frame]) - pos.y;
50+
data->SetInteger("x", pos.x);
51+
data->SetInteger("y", pos.y);
52+
args.Append(data);
4353
tray_->dispatcher_host()->SendEvent(tray_,"click",args);
4454
}
4555
@end
@@ -65,13 +75,19 @@ - (void)onClick:(id)sender {
6575
}
6676

6777
void Tray::SetTitle(const std::string& title) {
78+
// note: this is kind of mad but the first time we set the title property
79+
// we have to call setTitle twice or it won't get the right dimensions
80+
if ([status_item_ title] != nil) {
81+
[status_item_ setTitle:[NSString stringWithUTF8String:title.c_str()]];
82+
}
6883
[status_item_ setTitle:[NSString stringWithUTF8String:title.c_str()]];
6984
}
7085

7186
void Tray::SetIcon(const std::string& icon) {
7287
if (!icon.empty()) {
7388
NSImage* image = [[NSImage alloc]
7489
initWithContentsOfFile:[NSString stringWithUTF8String:icon.c_str()]];
90+
[image setTemplate:iconsAreTemplates];
7591
[status_item_ setImage:image];
7692
[image release];
7793
} else {
@@ -83,13 +99,24 @@ - (void)onClick:(id)sender {
8399
if (!alticon.empty()) {
84100
NSImage* image = [[NSImage alloc]
85101
initWithContentsOfFile:[NSString stringWithUTF8String:alticon.c_str()]];
102+
[image setTemplate:iconsAreTemplates];
86103
[status_item_ setAlternateImage:image];
87104
[image release];
88105
} else {
89106
[status_item_ setAlternateImage:nil];
90107
}
91108
}
92109

110+
void Tray::SetIconsAreTemplates(bool areTemplates) {
111+
iconsAreTemplates = areTemplates;
112+
if ([status_item_ image] != nil) {
113+
[[status_item_ image] setTemplate:areTemplates];
114+
}
115+
if ([status_item_ alternateImage] != nil) {
116+
[[status_item_ alternateImage] setTemplate:areTemplates];
117+
}
118+
}
119+
93120
void Tray::SetTooltip(const std::string& tooltip) {
94121
[status_item_ setToolTip:[NSString stringWithUTF8String:tooltip.c_str()]];
95122
}

src/browser/native_window_mac.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ - (void)drawRect:(NSRect)dirtyRect {
482482
}
483483

484484
void NativeWindowCocoa::Focus(bool focus) {
485+
NSApplication *myApp = [NSApplication sharedApplication];
486+
[myApp activateIgnoringOtherApps:YES];
485487
if (focus && [window() isVisible])
486488
[window() makeKeyAndOrderFront:nil];
487489
else

src/mac/app-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>0.11.2</string>
22+
<string>0.11.4</string>
2323
<key>NSPrincipalClass</key>
2424
<string>NSApplication</string>
2525
<key>LSMinimumSystemVersion</key>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<script>
3+
var gui = require('nw.gui');
4+
5+
var win = gui.Window.get();
6+
7+
// mimicks tray menu behaviour, disappears when losing focus
8+
win.on('blur', function() {
9+
win.hide();
10+
});
11+
</script>
12+
<body>
13+
<p>A custom tray menu</p>
14+
<p><button onclick="win.hide();">Close Menu</button></p>
15+
<p><button onclick="gui.App.closeAllWindows();">Close App</button></p>
16+
</body>
17+
</html>
3.26 KB
Loading

0 commit comments

Comments
 (0)