As far as I can tell from your question, you want your window to have same distance from all sides of screen, that means it's always in the center. to be more clear, center of window and center of the screen should both have same coordinates. window has 3 panels, and all panels are squares with same size, so we can guess `window.width` is 3 times larger than `window.height`. you also want some padding, so there is some raw value for both width and height of window. let's say these raw values are equal to 85% of screen width and height respectively. using `window.width = 3*window.height` we can compute a new value for both width and height of window. the last step is to use minimum value from these generated values for width or height. here is a pseudo code: w1 = screen.width * 85% h1 = screen.height * 85% w2 = h1 * 3 h2 = w1 / 3 window.width = min(w1,w2) window.height = min(h1,h2) window.topleft = (screen.width - window.width / 2, screen.height - window.height / 2) window.bottomright = (scree.width + window.width / 2, screen.height + window.height / 2)