fix: linux, custom client, incoming only, resizable (#8005)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-05-10 16:40:29 +08:00
committed by GitHub
parent 6e78037770
commit 69b11e8dc6
5 changed files with 39 additions and 19 deletions

View File

@@ -55,6 +55,12 @@ var isMobile = isAndroid || isIOS;
var version = '';
int androidVersion = 0;
// Only used on Linux.
// `windowManager.setResizable(false)` will reset the window size to the default size on Linux.
// https://stackoverflow.com/questions/8193613/gtk-window-resize-disable-without-going-back-to-default
// So we need to use this flag to enable/disable resizable.
bool _linuxWindowResizable = true;
/// only available for Windows target
int windowsBuildNumber = 0;
DesktopType? desktopType;
@@ -1572,7 +1578,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
// `await windowManager.isMaximized()` will always return true
// if is not resizable. The reason is unknown.
//
// `windowManager.setResizable(!bind.isIncomingOnly());` in main.dart
// `setResizable(!bind.isIncomingOnly());` in main.dart
isMaximized =
bind.isIncomingOnly() ? false : await windowManager.isMaximized();
position = await windowManager.getPosition();
@@ -3234,7 +3240,9 @@ Widget buildVirtualWindowFrame(BuildContext context, Widget child) {
return Obx(
() => Container(
decoration: BoxDecoration(
color: isMainDesktopWindow ? Colors.transparent : Theme.of(context).colorScheme.background,
color: isMainDesktopWindow
? Colors.transparent
: Theme.of(context).colorScheme.background,
border: Border.all(
color: Theme.of(context).dividerColor,
width: stateGlobal.windowBorderWidth.value,
@@ -3258,4 +3266,18 @@ Widget buildVirtualWindowFrame(BuildContext context, Widget child) {
);
}
get windowEdgeSize => isLinux && bind.isIncomingOnly() ? 0.0 : kWindowEdgeSize;
get windowEdgeSize => isLinux && _linuxWindowResizable ? 0.0 : kWindowEdgeSize;
// `windowManager.setResizable(false)` will reset the window size to the default size on Linux and then set unresizable.
// See _linuxWindowResizable for more details.
// So we use `setResizable()` instead of `windowManager.setResizable()`.
//
// We can only call `windowManager.setResizable(false)` if we need the default size on Linux.
setResizable(bool resizable) {
if (isLinux) {
_linuxWindowResizable = resizable;
stateGlobal.refreshResizeEdgeSize();
} else {
windowManager.setResizable(resizable);
}
}