Merge pull request #2791 from fufesou/refact/adjust_window
do not show adjust window when scale adaptive
This commit is contained in:
commit
c7fd38ed23
@ -956,77 +956,77 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
|||||||
dismissOnClicked: true,
|
dismissOnClicked: true,
|
||||||
));
|
));
|
||||||
displayMenu.insert(3, MenuEntryDivider<String>());
|
displayMenu.insert(3, MenuEntryDivider<String>());
|
||||||
}
|
|
||||||
|
|
||||||
if (_isWindowCanBeAdjusted(remoteCount)) {
|
if (_isWindowCanBeAdjusted(remoteCount)) {
|
||||||
displayMenu.insert(
|
displayMenu.insert(
|
||||||
0,
|
0,
|
||||||
MenuEntryDivider<String>(),
|
MenuEntryDivider<String>(),
|
||||||
);
|
);
|
||||||
displayMenu.insert(
|
displayMenu.insert(
|
||||||
0,
|
0,
|
||||||
MenuEntryButton<String>(
|
MenuEntryButton<String>(
|
||||||
childBuilder: (TextStyle? style) => Container(
|
childBuilder: (TextStyle? style) => Container(
|
||||||
child: Text(
|
child: Text(
|
||||||
translate('Adjust Window'),
|
translate('Adjust Window'),
|
||||||
style: style,
|
style: style,
|
||||||
)),
|
)),
|
||||||
proc: () {
|
proc: () {
|
||||||
() async {
|
() async {
|
||||||
await _updateScreen();
|
await _updateScreen();
|
||||||
if (_screen != null) {
|
if (_screen != null) {
|
||||||
_setFullscreen(false);
|
_setFullscreen(false);
|
||||||
double scale = _screen!.scaleFactor;
|
double scale = _screen!.scaleFactor;
|
||||||
final wndRect =
|
final wndRect =
|
||||||
await WindowController.fromWindowId(windowId).getFrame();
|
await WindowController.fromWindowId(windowId).getFrame();
|
||||||
final mediaSize = MediaQueryData.fromWindow(ui.window).size;
|
final mediaSize = MediaQueryData.fromWindow(ui.window).size;
|
||||||
// On windows, wndRect is equal to GetWindowRect and mediaSize is equal to GetClientRect.
|
// On windows, wndRect is equal to GetWindowRect and mediaSize is equal to GetClientRect.
|
||||||
// https://stackoverflow.com/a/7561083
|
// https://stackoverflow.com/a/7561083
|
||||||
double magicWidth =
|
double magicWidth =
|
||||||
wndRect.right - wndRect.left - mediaSize.width * scale;
|
wndRect.right - wndRect.left - mediaSize.width * scale;
|
||||||
double magicHeight =
|
double magicHeight =
|
||||||
wndRect.bottom - wndRect.top - mediaSize.height * scale;
|
wndRect.bottom - wndRect.top - mediaSize.height * scale;
|
||||||
|
|
||||||
final canvasModel = widget.ffi.canvasModel;
|
final canvasModel = widget.ffi.canvasModel;
|
||||||
final width =
|
final width =
|
||||||
(canvasModel.getDisplayWidth() * canvasModel.scale +
|
(canvasModel.getDisplayWidth() * canvasModel.scale +
|
||||||
canvasModel.windowBorderWidth * 2) *
|
canvasModel.windowBorderWidth * 2) *
|
||||||
scale +
|
scale +
|
||||||
magicWidth;
|
magicWidth;
|
||||||
final height =
|
final height =
|
||||||
(canvasModel.getDisplayHeight() * canvasModel.scale +
|
(canvasModel.getDisplayHeight() * canvasModel.scale +
|
||||||
canvasModel.tabBarHeight +
|
canvasModel.tabBarHeight +
|
||||||
canvasModel.windowBorderWidth * 2) *
|
canvasModel.windowBorderWidth * 2) *
|
||||||
scale +
|
scale +
|
||||||
magicHeight;
|
magicHeight;
|
||||||
double left = wndRect.left + (wndRect.width - width) / 2;
|
double left = wndRect.left + (wndRect.width - width) / 2;
|
||||||
double top = wndRect.top + (wndRect.height - height) / 2;
|
double top = wndRect.top + (wndRect.height - height) / 2;
|
||||||
|
|
||||||
Rect frameRect = _screen!.frame;
|
Rect frameRect = _screen!.frame;
|
||||||
if (!isFullscreen) {
|
if (!isFullscreen) {
|
||||||
frameRect = _screen!.visibleFrame;
|
frameRect = _screen!.visibleFrame;
|
||||||
|
}
|
||||||
|
if (left < frameRect.left) {
|
||||||
|
left = frameRect.left;
|
||||||
|
}
|
||||||
|
if (top < frameRect.top) {
|
||||||
|
top = frameRect.top;
|
||||||
|
}
|
||||||
|
if ((left + width) > frameRect.right) {
|
||||||
|
left = frameRect.right - width;
|
||||||
|
}
|
||||||
|
if ((top + height) > frameRect.bottom) {
|
||||||
|
top = frameRect.bottom - height;
|
||||||
|
}
|
||||||
|
await WindowController.fromWindowId(windowId)
|
||||||
|
.setFrame(Rect.fromLTWH(left, top, width, height));
|
||||||
}
|
}
|
||||||
if (left < frameRect.left) {
|
}();
|
||||||
left = frameRect.left;
|
},
|
||||||
}
|
padding: padding,
|
||||||
if (top < frameRect.top) {
|
dismissOnClicked: true,
|
||||||
top = frameRect.top;
|
),
|
||||||
}
|
);
|
||||||
if ((left + width) > frameRect.right) {
|
}
|
||||||
left = frameRect.right - width;
|
|
||||||
}
|
|
||||||
if ((top + height) > frameRect.bottom) {
|
|
||||||
top = frameRect.bottom - height;
|
|
||||||
}
|
|
||||||
await WindowController.fromWindowId(windowId)
|
|
||||||
.setFrame(Rect.fromLTWH(left, top, width, height));
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
},
|
|
||||||
padding: padding,
|
|
||||||
dismissOnClicked: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Show Codec Preference
|
/// Show Codec Preference
|
||||||
|
Loading…
x
Reference in New Issue
Block a user