@@ -417,15 +417,36 @@ void Instance::initialisePd(String& pdlua_version)
417417 }
418418 case hash (" canvas_title" ): {
419419 auto * inst = static_cast <Instance*>(instance);
420- auto const * glist = reinterpret_cast <t_canvas*>(argv->a_w .w_gpointer );
421- auto const * title = atom_getsymbol (argv + 1 );
420+ auto * glist = reinterpret_cast <t_canvas*>(argv->a_w .w_gpointer );
421+ auto title = SmallString ( atom_getsymbol (argv + 1 )-> s_name );
422422 int isDirty = atom_getfloat (argv + 2 );
423423
424+ int argc = 0 ;
425+ t_atom* argv = nullptr ;
426+
427+ canvas_setcurrent (glist);
428+ canvas_getargs (&argc, &argv);
429+ canvas_unsetcurrent (glist);
430+
431+ if (argc) {
432+ title += " (" ;
433+ for (int i = 0 ; i < argc; i++) {
434+ char namebuf[MAXPDSTRING];
435+ atom_string (&argv[i], namebuf, MAXPDSTRING);
436+ title += String::fromUTF8 (namebuf);
437+ if (i != argc - 1 )
438+ title += " " ;
439+ }
440+ title += " )" ;
441+ }
442+
443+ title = title.isEmpty () ? " Untitled Patcher" : title;
444+
424445 MessageManager::callAsync ([instance = juce::WeakReference (inst), glist, title, isDirty] {
425446 if (auto * pd = static_cast <PluginProcessor*>(instance.get ())) {
426447 for (auto const & patch : pd->patches ) {
427448 if (patch->ptr .getRaw <t_canvas>() == glist) {
428- patch->updateTitle (SmallString ( title-> s_name ) , isDirty);
449+ patch->updateTitle (title, isDirty);
429450 }
430451 }
431452 for (auto * editor : pd->getEditors ())
0 commit comments