Screen Size Returned From getParentWidth() and getParentHeight()


#1

Calling getParentWidth() and getParentHeight() from my MainContentComponent return values somewhat less than the dimensions reported by MS Windows 7 or MS Windows 10. For example, when my screen is set to a resolution of 1920 x 1080 the returned width x height from getParentWidth() and getParentHeight() is 1536 x 837. I’ve done this on several different machines and they all have similar, but not identical, discrepancies. Shouldn’t these numbers reported by getParentWidth() and getParentHeight() match the resolution reported by Windows?


#2

I think the desktop size reported by the system is reduced from the original resolution by unusable space, e.g. for title bar, task bar, dock etc.
If you go directly to the Desktop::Displays class, you can specify, if you want the available spaces with or without the pre-occupied space:
Desktop::Displays::getRectangleList (bool userAreasOnly) const

HTH


#3

Thank you for your response, Daniel. Getting the (width x height) using getRectangleList(userAreasOnly=true) returns (1536 x 837) and getting them using getRectangleList(userAreasOnly=false) returns (1536 x 864) so the “user area only” height is smaller but neither set of values comes close to the resolution reported by windows (1920 x 1080). If I set the size of my window using setSize (1536, 837), the window takes up the entire (1920 x 1080) screen. Interestingly, the (1536 x 864) numbers are exactly 80% of the (1920 x 1080) resolution numbers so I think this is telling me something but I don’t know what.


#4

Ah I see. You are right, there is a UI scale factor, and now that you mention it, I think windows sets it default to 125% for a long time.
I avoided that topic, I tend to create my UIs resizable and scale everything proportionally. That way the user can decide, what size he/she needs.
Maybe with that search term you find more information, or somebody else might chime in and give more precise advice…