diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 74a93d90c4da13ea0555ea9ef3d55538d6e90e7f..54dcace4ecb2c840b5277f597030b6e57111ff65 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -927,6 +927,7 @@ function translate_form() { // It provides us with our canvas id from the C side. Once we have it // we can create the menu and register event callbacks function register_window_id(cid, attr_array) { + var kludge_title; // We create the window menus and popup menu before doing anything else // to ensure that we don't try to set the svg size before these are done. // Otherwise we might set the svg size to the window viewport, only to have @@ -950,6 +951,21 @@ function register_window_id(cid, attr_array) { // default. But if this changes we need to set its menu item checkbox // accordingly here //set_cord_inspector_checkbox(); + + // One final kludge-- because window creation is asyncronous, we may + // have gotten a dirty flag before the window was created. In that case + // we check the title_queue to see if our title now contains an asterisk + // (which is the visual cue for "dirty") + + // Two possibilities for handling this better: + // have a representation of canvas attys in pdgui.js (editmode, dirty, etc.) + // or + // send those attys from Pd after mapping the canvas + kludge_title = pdgui.query_title_queue(cid); + if (kludge_title) { + nw.Window.get().title = kludge_title; + } + pdgui.free_title_queue(cid); } function create_popup_menu(name) { diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index f962121b80933ac735a9112886d30fc6efb47000..204b628831245ef5fa39ec64933567a14f7ce251 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -892,6 +892,7 @@ var scroll = {}, doscroll = {}, last_loaded, loading = {}, + title_queue= {}, // ugly kluge to work around an ugly race condition popup_menu = {}; var patchwin = {}; // object filled with cid: [Window object] pairs @@ -995,9 +996,25 @@ exports.format_window_title = format_window_title; // (and maybe in other situations) function gui_canvas_set_title(cid, name, args, dir, dirty_flag) { var title = format_window_title(name, dirty_flag, args, dir); - patchwin[cid].title = title; + if (patchwin[cid]) { + patchwin[cid].title = title; + } else { + title_queue[cid] = title; + } +} + +function query_title_queue(cid) { + return title_queue[cid]; } +exports.query_title_queue = query_title_queue; + +function free_title_queue(cid) { + title_queue[cid] = null; +} + +exports.free_title_queue = free_title_queue; + function window_is_loading(cid) { return loading[cid]; } diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 79cb8badb6af7aed04f5c375d29f8b996a7ec7de..632913107672d8340f898b18cc9f675825b31b52 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -690,7 +690,7 @@ void canvas_dirty(t_canvas *x, t_floatarg n) if ((unsigned)n != x2->gl_dirty) { x2->gl_dirty = n; - if (x2->gl_havewindow && glist_isvisible(x2)) + if (x2->gl_havewindow) canvas_reflecttitle(x2); } }