From 82c35e6445bf2b5aea412aad6f5cadce13d571b0 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 17 Jun 2020 16:01:57 -0400
Subject: [PATCH] Cosmetic fixes to respond to changes to nw 0.46.2 behavior.
 Namely, fixed main purr-data window starting location and size and windows
 now restore where they are supposed to. Also disabled debugging output.

---
 pd/nw/index.js     | 10 +++++++++-
 pd/nw/package.json |  5 ++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/pd/nw/index.js b/pd/nw/index.js
index 6e9da613c..4bce91ec3 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -399,9 +399,17 @@ function nw_create_window(cid, type, width, height, xpos, ypos, attr_array) {
     var eval_string = "register_window_id(" +
                       JSON.stringify(cid) + ", " +
                       JSON.stringify(attr_array) + ");";
+    //pdgui.post("x=" + xpos + " y=" + ypos);
+    var pos;
+    if (xpos == 0 && ypos == 0) {
+        pos = "center";
+    } else {
+        pos = "null";
+    }
     gui.Window.open(my_file, {
         title: my_title,
-        position: "center",
+        // ico@vt.edu: position in 0.46.2 overrides x and y below
+        position: pos,
         focus: true,
         width: width,
         // We add 23 as a kludge to account for the menubar at the top of
diff --git a/pd/nw/package.json b/pd/nw/package.json
index b87c61f3c..9f4e110d6 100644
--- a/pd/nw/package.json
+++ b/pd/nw/package.json
@@ -4,6 +4,9 @@
   "main": "index.html",
   "chromium-args": "--proxy-server=http://127.0.0.1 --password-store=basic",
   "window": {
-    "icon": "./purr.png"
+    "icon": "./purr.png",
+    "position": "center",
+    "width": 540,
+    "height": 440
   }
 }
-- 
GitLab