Commit aaca8b7d authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

add boilerplate for keeping track of toplevel Pd canvases in the GUI. While...

add boilerplate for keeping track of toplevel Pd canvases in the GUI. While the GUI knows all the open windows, it can't tell the difference between a Pd toplevel and a subpatch. I'm not sure why the difference is important, but this interface supplies that info to the GUI.
parent e823604b
......@@ -537,6 +537,18 @@ function menu_send(name) {
exports.menu_send = menu_send;
function gui_set_toplevel_window_list(dummy, attr_array) {
// We receive an array in the form:
// ["Name", "address", etc.]
// where "address" is the cid (x123456etc.)
// We don't do anything with it at the moment,
// but they could be added to the "Windows" menu
// if desired. (Pd Vanilla doesn't do this, but
// Pd-l2ork (and possibly Pd-extended) did.
// the "dummy" parameter is just to work around a bug in the gui_vmess API
}
function menu_quit() {
pdsend("pd verifyquit");
}
......
......@@ -67,46 +67,28 @@ static t_symbol *canvas_newdirectory = &s_;
static int canvas_newargc;
static t_atom *canvas_newargv;
static void glist_doupdatewindowlist(t_glist *gl, char *sbuf)
/* maintain the list of visible toplevels for the GUI's "windows" menu */
void canvas_updatewindowlist( void)
{
t_gobj *g;
t_canvas *x;
if (glist_amreloadingabstractions) /* not if we're in a reload */
return;
if (!gl->gl_owner)
gui_start_vmess("gui_set_toplevel_window_list", "s", "dummy");
gui_start_array();
for (x = canvas_list; x; x = x->gl_next)
{
/* this is a canvas; if we have a window, put on "windows" list */
t_canvas *canvas = (t_canvas *)gl;
if (canvas->gl_havewindow)
if (!x->gl_owner)
{
if (strlen(sbuf) + strlen(gl->gl_name->s_name) + 100 <= 1024)
/* this is a canvas; if we have a window, put on "windows" list */
if (x->gl_havewindow)
{
char tbuf[1024];
sprintf(tbuf, "{{%s} .x%lx} ", gl->gl_name->s_name,
(t_int)canvas);
strcat(sbuf, tbuf);
gui_s(x->gl_name->s_name);
gui_x((long unsigned int)x);
}
}
}
for (g = gl->gl_list; g; g = g->g_next)
{
if (pd_class(&g->g_pd) == canvas_class)
glist_doupdatewindowlist((t_glist *)g, sbuf);
}
return;
}
/* maintain the list of visible toplevels for the GUI's "windows" menu */
void canvas_updatewindowlist( void)
{
t_canvas *x;
char sbuf[1024];
strcpy(sbuf, "set menu_windowlist {");
/* find all root canvases */
for (x = canvas_list; x; x = x->gl_next)
glist_doupdatewindowlist(x, sbuf);
/* next line updates the window menu state before -postcommand tries it */
strcat(sbuf, "}\npdtk_fixwindowmenu\n");
sys_gui(sbuf);
gui_end_array();
gui_end_vmess();
}
/* add a glist the list of "root" canvases (toplevels without parents.) */
......
......@@ -886,6 +886,16 @@ void gui_s(const char *s)
gui_array_tail = 0;
}
void gui_x(long unsigned int i)
{
if (gui_array_head && !gui_array_tail)
sys_vgui("\"x%.6lx\"", i);
else
sys_vgui(",\"x%.6lx\"", i);
gui_array_head = 0;
gui_array_tail = 0;
}
void gui_end_array(void)
{
sys_gui("]");
......
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