google / flutter-desktop-embedding

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

[window_size] Add title bar height to window info #838

Closed aloisdeniel closed 3 years ago

aloisdeniel commented 3 years ago

I would like to know how big is the title bar since it is included in window size. Since each version of an operating system has a different behaviour it is difficult to deal with it.

final info = await getWindowInfo();
print('${info.barHeight}');

For the context, I want to have a window of a certain ratio, based on a device frame :

image

stuartmorgan commented 3 years ago

Adding a content rect to PlatformWindow seems reasonable. (Although I believe you could figure this out for the standard case of a windows containing nothing but a full-content-area Flutter view with the current API by getting the current window's information and comparing that to the size from MediaQuery.)

aloisdeniel commented 3 years ago

Thanks for the answer.

You're right, something like this should do the trick :

 final windowBarHeight = info.frame.height -
            (ui.window.physicalSize.height / ui.window.devicePixelRatio);
stuartmorgan commented 3 years ago

Per the updated scope of this plugin, this isn't something that will be added. I would encourage you to review the multi-window design doc linked from that README and leave feedback if the proposed APIs wouldn't address your use case.