# 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:** 5\
**Page:** 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”).

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 18, 2017, 12:11pm UTC](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226/2 "2017-09-18T12:11:36Z")

</div>

Thanks for your input.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [October 2, 2017, 12:11pm UTC](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226/3 "2017-10-02T12:11:42Z")

</div>

Closed on October 2, 2017, 12:11pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [October 5, 2017, 11:33am UTC](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226/4 "2017-10-05T11:33:49Z")

</div>

After applying your patch always get:

```auto
Processing canvas_size.C...
798 575
800 600
798 575
800 600
796 572
800 600
796 572
800 600

```

running [canvas\_size.C](https://root-forum.cern.ch/uploads/default/original/2X/f/fa4c4a33d2062d393df387323694c23967793e05.C) (1.2 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 24, 2017, 2:20pm UTC](https://root-forum.cern.ch/t/tcanvas-setwindowsize-extension-proposal/26226/5 "2017-11-24T14:20:41Z")

</div>

Patch applied: [https://github.com/root-project/root/pull/1138](https://github.com/root-project/root/pull/1138)
