I stumbled about a strange behaviour when creating a new TCanvas, in my case in a Linux Mint Virtual Box in a Windows 11 host. When I e.g. create the TCanvas with
thanks for the hint. As far as I understand the possible pixel differences described in the reference are just due to the windows decoration. However, it is not the case that my margins are 100px wide, but the graphics area itself is scaled incorrectly.
When creating the windows as described above I get from ‘inspect’ the following numbers:
fWindowWidth 720 Width of window (including borders, etc.)
fWindowHeight 738 Height of window (including menubar, borders, etc.)
fCw 718 Width of the canvas along X (pixels)
fCh 696 Height of the canvas along Y (pixels)
After I called gPad->GetCanvas()->SetWindowSize(500,500); I see
fWindowWidth 500 Width of window (including borders, etc.)
fWindowHeight 500 Height of window (including menubar, borders, etc.)
fCw 498 Width of the canvas along X (pixels)
fCh 458 Height of the canvas along Y (pixels)
which are the expected dimensions right from the beginning.
it has 502 x 524 and 500 x 482 (the latter not being 500 x 500!) afterwards. Now the funny thing: If I execute the resize over and over again, it wiggles between to the original 500 x 518 / 498 x 476 and the reset 502 x 524 and 500 x 482 forth and back.
Using the function c1.SetCanvasSize(500,500) led to scroll bars on both windows axis. Finally I got these to vanish with ‘c1.SetWindowSize(502,558)’. Using the ‘inspect’ tool gives me for this setting dimensions of 500 x 518 / 500 x 500.
Yeah… canvas size, together with zooming a TGraph, is one of those things where you say… how can ROOT make it so difficult to define such standard things, and so easy to process 10 TB of data in 5 seconds.
For the time being I’m fine with switching off the Canvas.UseScreenFactor in .rootrc. But it nevertheless might be worth to take a look to the code to make it more predictable.
Not all operations can be performed synchronous with web canvas - therefore its real dimensions (window and canvas size) will be set only after next TCanvas::Update() call.
I want to fix implementation for normal canvas that real canvas sizes are returned by TCanvas::GetWw() and TCanvas::GetWh() methods.