fix: linux, custom client, incoming only, resizable (#8005)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
6e78037770
commit
69b11e8dc6
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,7 @@ const kDefaultScrollDuration = Duration(milliseconds: 50);
|
||||
const kDefaultMouseWheelThrottleDuration = Duration(milliseconds: 50);
|
||||
const kFullScreenEdgeSize = 0.0;
|
||||
const kMaximizeEdgeSize = 0.0;
|
||||
// Do not use kWindowEdgeSize directly. Use `windowEdgeSize` in `common.dart` instead.
|
||||
final kWindowEdgeSize = isWindows ? 1.0 : 5.0;
|
||||
final kWindowBorderWidth = isLinux ? 1.0 : 0.0;
|
||||
const kDesktopMenuPadding = EdgeInsets.only(left: 12.0, right: 3.0);
|
||||
|
@ -57,10 +57,10 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
|
||||
tabController.onSelected = (key) {
|
||||
if (key == kTabLabelHomePage) {
|
||||
windowManager.setSize(getIncomingOnlyHomeSize());
|
||||
windowManager.setResizable(false);
|
||||
setResizable(false);
|
||||
} else {
|
||||
windowManager.setSize(getIncomingOnlySettingsSize());
|
||||
windowManager.setResizable(true);
|
||||
setResizable(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -144,12 +144,8 @@ void runMainApp(bool startService) async {
|
||||
}
|
||||
windowManager.setOpacity(1);
|
||||
windowManager.setTitle(getWindowName());
|
||||
// `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
|
||||
if (!isLinux) {
|
||||
windowManager.setResizable(!bind.isIncomingOnly());
|
||||
}
|
||||
// For Linux, we set the edge size to 0 to disable resize. See `get windowEdgeSize` in common.dart.
|
||||
// Do not use `windowManager.setResizable()` here.
|
||||
setResizable(!bind.isIncomingOnly());
|
||||
});
|
||||
}
|
||||
|
||||
@ -243,7 +239,7 @@ void runConnectionManagerScreen() async {
|
||||
} else {
|
||||
await showCmWindow(isStartup: true);
|
||||
}
|
||||
windowManager.setResizable(false);
|
||||
setResizable(false);
|
||||
// Start the uni links handler and redirect links to Native, not for Flutter.
|
||||
listenUniLinks(handleByFlutter: false);
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ class StateGlobal {
|
||||
if (!_fullscreen.isTrue) {
|
||||
if (isMaximized.value != v) {
|
||||
isMaximized.value = v;
|
||||
_resizeEdgeSize.value =
|
||||
isMaximized.isTrue ? kMaximizeEdgeSize : windowEdgeSize;
|
||||
refreshResizeEdgeSize();
|
||||
}
|
||||
if (!isMacOS) {
|
||||
_windowBorderWidth.value = v ? 0 : kWindowBorderWidth;
|
||||
@ -71,11 +70,7 @@ class StateGlobal {
|
||||
if (_fullscreen.value != v) {
|
||||
_fullscreen.value = v;
|
||||
_showTabBar.value = !_fullscreen.value;
|
||||
_resizeEdgeSize.value = fullscreen.isTrue
|
||||
? kFullScreenEdgeSize
|
||||
: isMaximized.isTrue
|
||||
? kMaximizeEdgeSize
|
||||
: windowEdgeSize;
|
||||
refreshResizeEdgeSize();
|
||||
print(
|
||||
"fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
|
||||
_windowBorderWidth.value = fullscreen.isTrue ? 0 : kWindowBorderWidth;
|
||||
@ -96,6 +91,12 @@ class StateGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
refreshResizeEdgeSize() => _resizeEdgeSize.value = fullscreen.isTrue
|
||||
? kFullScreenEdgeSize
|
||||
: isMaximized.isTrue
|
||||
? kMaximizeEdgeSize
|
||||
: windowEdgeSize;
|
||||
|
||||
String getInputSource({bool force = false}) {
|
||||
if (force || _inputSource.isEmpty) {
|
||||
_inputSource = bind.mainGetInputSource();
|
||||
|
Loading…
Reference in New Issue
Block a user