Make calculateCanvasSize window-free