#include "TCanvas.h"
#include "TF1.h"
#include "TApplication.h"
#include <iostream>
using namespace std;
int main() {
auto A = new TApplication("a", 0,0);
auto c = new TCanvas("c","",1400,1200);
auto f = new TF1("f","sin(x)/x", 0., 4.);
f->Draw();
c->Modified();
c->Update();
cout << "aqui" << endl;
c->Print("a.png");
c->WaitPrimitive();
}
In your macro one just waits when some (not any) action performed on the pad.
For instance - click on axis returns from waiting but click on the frame or title not.
But method WaitPrimitive potentially can do much more.
I will try to implement something with correspondent behavior on web canvas - but not identical.