Set TCanvas size in batch mode

It sets proper canvas size, but the canvas size is not stored in the saved C file.
This is issue with storing mechanism, because the canvas is created with window size and not canvas, and in batch mode there is no window, so there is nothing to resize…

I tried doing something like this but this is also not satisfying me (look for trick):

{
    Double_t w = 400;
    Double_t h = 400;

    auto can = new TCanvas("can_size", "can_size", w, h);

    printf("1. Ww = %d  Wh = %d    WindowWidth = %d  WindowHeight = %d\n",
           can->GetWw(), can->GetWh(), can->GetWindowWidth(), can->GetWindowHeight());

    Double_t w2 = 800;
    Double_t h2 = 800;

    if (gROOT->IsBatch()) {
        printf("BATCH MODE\n");

        can->SetCanvasSize(w2, h2);

        // TRICK STARTS HERE
        Int_t ww, wh; UInt_t winw, winh;
        can->GetCanvasPar(ww, wh, winw, winh);
        winw = w2;
        winh = h2;

        can->SaveAs("can_size_batch.C");
        can->SaveAs("can_size_batch.png");
    } else {
        printf("GRAPH MODE\n");

        can->SetWindowSize(w2 + (w - can->GetWw()), h2 + (h - can->GetWh()));

        can->SaveAs("can_size_graph.C");
        can->SaveAs("can_size_graph.png");
    }

    printf("2. Ww = %d  Wh = %d    WindowWidth = %d  WindowHeight = %d\n",
           can->GetWw(), can->GetWh(), can->GetWindowWidth(), can->GetWindowHeight());
}

because the saved sizes are:

TCanvas *can_size = new TCanvas("can_size", "can_size", 1, 1, 804, 804);      // BATCH MODE
TCanvas *can_size = new TCanvas("can_size", "can_size", 3000, 331, 802, 829); // WINDOW MODE

But I am working on PR which will fix that. Perhaps today I will put draft into github.