google / flutter-desktop-embedding

Experimental plugins for Flutter for Desktop
Apache License 2.0
7.1k stars 604 forks source link

DPI scale reactor needed #911

Closed BillyH24 closed 1 year ago

BillyH24 commented 1 year ago

Is this request within the scope of this project?

Which plugin is this request about?

window_size

Describe the request

It seems the setWindowMinSize or other methods would not take the dpi setting as a scale factor, so when I set the minimum width to 375, the actual minimum width would be 298.4 because I have set the scaling setting to 125% on my desktop. 298.4 (actual) * 1.25 = ~375 (expected)

I know the createAndShow method in win32_window.cpp (main flutter) would get the dpi of the monitor and take it as the scale factor. (However, I am unfamiliar with cpp, so I am not sure how to make it work here as well)

stuartmorgan commented 1 year ago

CreateAndShow uses logical pixels, which is why it scales, whereas this plugin's APIs use screen coordinates. You can do the scaling yourself on the Dart side using the screen's scaleFactor.

While it would likely be easier to use from a Dart perspective to have APIs based on logical pixels (and if I were redesigning the plugin from scratch I would probably have it work entirely in Flutter-based sizes), per the README new API will not be added to this plugin, so closing.