SetBatch causes different graphics output for pngs

I’m afraid TCanvas::SetWindowSize is completely unreliable (it can misbehave even in interactive mode).
When I try (ROOT 5.34 and 6.04.02):

{
  Int_t w = 800;
  Int_t h = 600;
  TCanvas *c;
  gROOT->SetBatch(kFALSE);
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  delete c;
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetCanvasSize(w, h);
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  delete c;
  gROOT->SetBatch(kTRUE);
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  delete c;
  c = new TCanvas("c", "c", w, h); c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
  c->SetCanvasSize(w, h);
  c->Modified(); c->Update();
  std::cout << c->GetWw() << " " << c->GetWh() << std::endl;
}

I sometimes get:

798 573
800 600 SetWindowSize WORKS in interactive mode
798 573
800 600 SetCanvasSize WORKS in interactive mode
796 572
796 572 !!! SetWindowSize FAILS in batch mode !!!
796 572
800 600 SetCanvasSize WORKS in batch mode

and sometimes:

798 573
798 573 !!! SetWindowSize FAILS in interactive mode !!!
798 573
800 600 SetCanvasSize WORKS in interactive mode
796 572
796 572 !!! SetWindowSize FAILS in batch mode !!!
796 572
800 600 SetCanvasSize WORKS in batch mode

BTW. I can switch from interactive to batch mode, but not the other way (I get “Warning in TCanvas::ResizePad: c width changed from 0 to 10” if I try it).

JIRA: sft.its.cern.ch/jira/browse/ROOT-7552