# TCanvas::SetWindowSize extension proposal

**URL:** <https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226>\
**Category:** ROOT\
**Created:** [September 15, 2017, 6:15pm UTC](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226 "2017-09-15T18:15:42Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 15, 2017, 6:15pm UTC](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226/1 "2017-09-15T18:15:42Z")

</div>

The [TCanvas::SetCanvasSize](https://root.cern.ch/doc/master/classTCanvas.html#a16f9b72909f2b5e3b3faaea4eaf80501) method [works in interactive and batch modes](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/8) while the [TCanvas::SetWindowSize](https://root.cern.ch/doc/master/classTCanvas.html#a03de689513900a38d3c8e45c30194501) [works in interactive mode only](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/8).

So, I would like to propose that the [TCanvas::SetWindowSize](https://root.cern.ch/doc/master/classTCanvas.html#a03de689513900a38d3c8e45c30194501) is modified into (it will then work in both modes, too):

```auto
void SetWindowSize(UInt_t ww, UInt_t wh) { if (fBatch) SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2); else if (fCanvasImp) fCanvasImp->SetWindowSize(ww, wh); }

```

BTW. Wonder why “SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2)”? Well, that’s because the [TCanvas](https://root.cern.ch/doc/master/classTCanvas.html) shows the typical usage “c-\>SetWindowSize(w + (w - c-\>GetWw()), h + (h - c-\>GetWh()));”, so we need to “recalculate” parameters’ values (in order to get the requested original “w” and “h”).

---

_[View the full topic](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226)._
