diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 81bc3b11688a9fec434140bcb0d270326a19828e..f257712bdef18b9057c009167a0999b34afc023d 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -986,7 +986,7 @@ function gui_canvas_new(cid, width, height, geometry, editmode, name, dir, dirty
     geometry = geometry.slice(1);   // remove the leading "+"
     geometry = geometry.split("+"); // x/y screen offset (in pixels)
     // Keep patches on the visible screen
-    var xpos = Math.min(Number(geometry[0]), window.screen.height - width); 
+    var xpos = Math.min(Number(geometry[0]), window.screen.width - width); 
     var ypos = Math.min(Number(geometry[1]), window.screen.height - height); 
     xpos = Math.max(xpos, 0);
     ypos = Math.max(ypos, 0);