Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
nerrons
purr-data
Commits
80f458ad
Commit
80f458ad
authored
Feb 05, 2017
by
Jonathan Wilkes
Browse files
Merge branch 'aggraef/purr-data-fix-osx-startup'
parents
f173818f
60c4d642
Changes
2
Hide whitespace changes
Inline
Side-by-side
pd/nw/index.js
View file @
80f458ad
...
@@ -3,9 +3,15 @@ var gui = require("nw.gui");
...
@@ -3,9 +3,15 @@ var gui = require("nw.gui");
var
pdgui
=
require
(
"
./pdgui.js
"
);
var
pdgui
=
require
(
"
./pdgui.js
"
);
var
pd_menus
=
require
(
"
./pd_menus.js
"
);
var
pd_menus
=
require
(
"
./pd_menus.js
"
);
// we're using pwd in fileDialog. If you start Pd by clicking the app bundle
// We're using the following pwd variable as the default dir in which various
// in OSX, the PWD environment variable doesn't exist. In that case we use
// file dialogs open, so we need to initialize it in some way. The following
// HOME instead.
// provides a reasonable default (use the PWD if it's available, otherwise
// fall back to HOME, or HOMEPATH on Windows). This will be updated later by
// the engine through pdgui.gui_set_cwd() once the engine has completed its
// startup.
// If you start Pd by clicking the app bundle in OSX, the PWD environment
// variable doesn't exist. In that case we use HOME instead.
var
pwd
=
process
.
env
.
PWD
!==
undefined
?
process
.
env
.
PWD
:
process
.
env
.
HOME
;
var
pwd
=
process
.
env
.
PWD
!==
undefined
?
process
.
env
.
PWD
:
process
.
env
.
HOME
;
// Windows doesn't have either of the environment variables above, so we
// Windows doesn't have either of the environment variables above, so we
...
@@ -35,7 +41,7 @@ function set_vars(win) {
...
@@ -35,7 +41,7 @@ function set_vars(win) {
pd_engine_id
=
gui
.
App
.
argv
[
4
];
pd_engine_id
=
gui
.
App
.
argv
[
4
];
}
else
{
}
else
{
// If we're starting Pd, this is the first port number to try. (We'll
// If we're starting Pd, this is the first port number to try. (We'll
// increment it if that port happens to be taken.
// increment it if that port happens to be taken.
)
port_no
=
5400
;
port_no
=
5400
;
}
}
pdgui
.
set_port
(
port_no
);
pdgui
.
set_port
(
port_no
);
...
@@ -89,8 +95,7 @@ function connect() {
...
@@ -89,8 +95,7 @@ function connect() {
pdgui
.
connect_as_client
();
pdgui
.
connect_as_client
();
}
else
{
}
else
{
// create a tcp server, then spawn Pd with "-guiport" flag and port
// create a tcp server, then spawn Pd with "-guiport" flag and port
gui_path
=
window
.
location
.
pathname
;
gui_path
=
process
.
cwd
();
gui_path
=
gui_path
.
substr
(
0
,
gui_path
.
lastIndexOf
(
'
/
'
));
// On OSX, if the user double-clicks a pd file we get a single
// On OSX, if the user double-clicks a pd file we get a single
// argument prefixed with "file://". If so, we parse it and
// argument prefixed with "file://". If so, we parse it and
// feed it to the Pd instance as an argument to the "-open" flag
// feed it to the Pd instance as an argument to the "-open" flag
...
@@ -283,7 +288,7 @@ function add_events() {
...
@@ -283,7 +288,7 @@ function add_events() {
// Selecting multiple files and clicking "Open" will trigger
// Selecting multiple files and clicking "Open" will trigger
// a separate "open" event for each file, so luckily we don't
// a separate "open" event for each file, so luckily we don't
// have to parse them.
// have to parse them.
pdgui
.
menu_open
(
decodeURI
(
argv_string
.
slice
(
7
)));
pdgui
.
menu_open
(
decodeURI
(
argv_string
.
slice
(
7
)));
}
else
{
}
else
{
// Otherwise we assume that the Pd process tried to
// Otherwise we assume that the Pd process tried to
// open the GUI, supplying us with a port number and
// open the GUI, supplying us with a port number and
...
...
pd/nw/pdgui.js
View file @
80f458ad
...
@@ -1095,19 +1095,9 @@ function external_doc_open(url) {
...
@@ -1095,19 +1095,9 @@ function external_doc_open(url) {
exports
.
external_doc_open
=
external_doc_open
;
exports
.
external_doc_open
=
external_doc_open
;
function
gui_set_cwd
(
dummy
,
cwd
)
{
function
gui_set_cwd
(
dummy
,
cwd
)
{
// The check for "darwin" is a quick workaround for getting
if
(
cwd
!==
"
.
"
)
{
// the OSX App bundle to start the pwd in the user's working directory
// instead of deep inside the App bundle itself. However, this may
// become a problem when people try to install Purr Data "Linux"-style,
// that is, install it system-wide from the command line instead of
// in an App bundle.
// Also, there is a general problem that we're setting the pwd from
// two different places-- index.js in set_vars() and s_inter.c with
// this call. That's unnecessarily complex and hard to follow. It
// should be simplified
if
(
cwd
!==
"
.
"
&&
process
.
platform
!==
"
darwin
"
)
{
pwd
=
cwd
;
pwd
=
cwd
;
post
(
"
working directory is
"
+
cwd
);
}
}
}
}
...
@@ -1442,7 +1432,7 @@ function spawn_pd(gui_path, port, file_to_open) {
...
@@ -1442,7 +1432,7 @@ function spawn_pd(gui_path, port, file_to_open) {
if
(
platform
===
"
darwin
"
)
{
if
(
platform
===
"
darwin
"
)
{
// OSX -- this is currently tailored to work with an app bundle. It
// OSX -- this is currently tailored to work with an app bundle. It
// hasn't been tested with a system install of pd-l2ork
// hasn't been tested with a system install of pd-l2ork
pd_binary
=
path
.
join
(
"
bin
"
,
"
pd-l2ork
"
);
pd_binary
=
path
.
join
(
gui_path
,
"
bin
"
,
"
pd-l2ork
"
);
if
(
file_to_open
)
{
if
(
file_to_open
)
{
flags
.
push
(
"
-open
"
,
file_to_open
);
flags
.
push
(
"
-open
"
,
file_to_open
);
}
}
...
@@ -1451,6 +1441,13 @@ function spawn_pd(gui_path, port, file_to_open) {
...
@@ -1451,6 +1441,13 @@ function spawn_pd(gui_path, port, file_to_open) {
flags
.
push
(
"
-nrt
"
);
// for some reason realtime causes watchdog to die
flags
.
push
(
"
-nrt
"
);
// for some reason realtime causes watchdog to die
}
}
post
(
"
binary is
"
+
pd_binary
);
post
(
"
binary is
"
+
pd_binary
);
// AG: It isn't nice that we change the cwd halfway through the startup
// here, but since the GUI launches the engine if we come here (that's how
// it works on the Mac), we *really* want to launch the engine in the
// user's home directory and not in some random subdir of the OSX app
// bundle. Note that to make that work, the pd-l2ork executable needs to
// be invoked using an absolute path (see above).
process
.
chdir
(
process
.
env
.
HOME
);
var
child
=
cp
.
spawn
(
pd_binary
,
flags
,
{
var
child
=
cp
.
spawn
(
pd_binary
,
flags
,
{
stdio
:
"
inherit
"
,
stdio
:
"
inherit
"
,
detached
:
true
detached
:
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment