Commit 27d57e4c authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix #119: store canvas title for later use. This will properly display the...

fix #119: store canvas title for later use. This will properly display the title for a dirty canvas in the case where the Pd patch is mutated with a loadbang (and properly other cases, too)
parent b967ea30
......@@ -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) {
......
......@@ -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];
}
......
......@@ -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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment