From c39b138ec32809a8b13b0585527512c039e51b39 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Wed, 21 Sep 2016 18:03:00 -0400 Subject: [PATCH] keep zfactor for lts nw.js version which gets used for Windows --- pd/nw/pdgui.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 995c589e5..cf1a90b29 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -3345,7 +3345,8 @@ exports.add_popup = add_popup; // Kludge to get popup coords to fit the browser's zoom level. As of v0.16.1 // it appears nw.js fixed the bug that required this kludge. Leave it here -// for a few versions as a quick fix just in case there's a regression. +// for now because we're using lts v0.14 for the Windows binaries because +// Windows XP support will be dropped after that. function zoom_kludge(zoom_level) { var zfactor; switch(zoom_level) { @@ -3374,11 +3375,13 @@ function gui_canvas_popup(cid, xpos, ypos, canprop, canopen, isobject) { var win_left = patchwin[cid].window.document.body.scrollLeft, win_top = patchwin[cid].window.document.body.scrollTop, zoom_level = patchwin[cid].zoomLevel, // these were used to work - zfactor = zoom_kludge(zoom_level), // around an old nw.js popup pos - // bug. It seems to be fixed now. + zfactor, // around an old nw.js popup pos + // bug. Now it's only necessary + // on Windows, which uses v.0.14 svg_view_box = patchwin[cid].window.document.getElementById("patchsvg") .getAttribute("viewBox").split(" "); // need top-left svg origin + zfactor = process.platform === "win32" ? zoom_kludge(zoom_level) : 1; // Set the global popup x/y so they can be retrieved by the relevant // document's event handler popup_coords[0] = xpos; @@ -3394,16 +3397,16 @@ function gui_canvas_popup(cid, xpos, ypos, canprop, canopen, isobject) { // We need to round win_left and win_top because the popup menu // interface expects an int. Otherwise the popup position gets wonky // when you zoom and scroll... - xpos = xpos - Math.floor(win_left); - ypos = ypos - Math.floor(win_top); + xpos = Math.floor(xpos * zfactor) - Math.floor(win_left * zfactor); + ypos = Math.floor(ypos * zfactor) - Math.floor(win_top * zfactor); // Now subtract the x and y offset for the top left corner of the svg. // We need to do this because a Pd canvas can have objects with negative // coordinates. Thus the SVG viewbox will have negative values for the // top left corner, and those must be subtracted from xpos/ypos to get // the proper window coordinates. - xpos -= svg_view_box[0]; - ypos -= svg_view_box[1]; + xpos -= Math.floor(svg_view_box[0] * zfactor); + ypos -= Math.floor(svg_view_box[1] * zfactor); popup_coords[2] = xpos + patchwin[cid].x; popup_coords[3] = ypos + patchwin[cid].y; -- GitLab