I'm confused about the Window size Parameter... I ...
# compose-desktop
s
I'm confused about the Window size Parameter... I want to open my Windows in Full HD, but the Window has a completely different size... ?
1
i
Window size uses density-independent pixels. It means width=800 means 1600 pixels with DPI=2.0 (on high-retina displays on macOs). It is more explicit in the new window API, as there we specify
800.dp
, not just
800
s
I thought so, but if I define a width of 1280 and screenshot the resulting window it's 1664 pixels. My scale is 2.0 regarding to LocalDensity.currrent
How can I specify that in dp using the new API? I don't see that in the tutorial.
i
See this You need to pass size argument:
Copy code
val state = rememberWindowState(size = WindowSize(800.dp, 600.dp))
Probably we need to add this information to the tutorial 🤔
🙏 1
s
Ok, thank you 🙂
Maybe that's a bug because using the new API results in the same display resolutions on macOS. I defined 1920/2 als my wished Window size and the resulting size is 2144
i
But it the same as in the old API So, if you have 1664 pixels window on screenshot with width=1280 and LocalDensity.current=2.0, probably something somewhere doesn't work as expected. Either in Compose, or in the screenshot tool. This width is measured on a screenshot of the entire screen, or on a screenshot of just single window?
s
single window screenshot
Using macOS Screenshot tool
i
Try to make a screenshot of the entire screen and calculate size manually - relative to the width of the screenshot
I defined 1920/2 als my wished Window size and the resulting size is 2144
Note that, window has horizontal insets (border and shadow). The size of the window includes them
To know what insets are, you can use Swing interop:
window.insets
(they are in density-independent pixels too)
s
Ok, thank you. That helped me a lot. And yes, you are right. I have some tooling problem. I wasn't aware that the Screenshots made with macOS build-in app have a lot of padding for the shadows.
Didn't expect that. So everything is fine and I switched to the new API. Thank you again
🎉 1