Skip to content

Commit a039741

Browse files
authored
fix: win10, border (rustdesk#10753)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
1 parent 2a0e8c1 commit a039741

7 files changed

Lines changed: 94 additions & 27 deletions

File tree

flutter/lib/common.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,8 @@ bool get kUseCompatibleUiMode =>
25662566
isWindows &&
25672567
const [WindowsTarget.w7].contains(windowsBuildNumber.windowsVersion);
25682568

2569+
bool get isWin10 => windowsBuildNumber.windowsVersion == WindowsTarget.w10;
2570+
25692571
class ServerConfig {
25702572
late String idServer;
25712573
late String relayServer;
@@ -3638,3 +3640,59 @@ extension WorkaroundFreezeLinuxMint on Widget {
36383640
}
36393641
}
36403642
}
3643+
3644+
// Don't use `extension` here, the border looks weird if using `extension` in my test.
3645+
Widget workaroundWindowBorder(BuildContext context, Widget child) {
3646+
if (!isWin10) {
3647+
return child;
3648+
}
3649+
3650+
final isLight = Theme.of(context).brightness == Brightness.light;
3651+
final borderColor = isLight ? Colors.black87 : Colors.grey;
3652+
final width = isLight ? 0.5 : 0.1;
3653+
3654+
getBorderWidget(Widget child) {
3655+
return Obx(() =>
3656+
(stateGlobal.isMaximized.isTrue || stateGlobal.fullscreen.isTrue)
3657+
? Offstage()
3658+
: child);
3659+
}
3660+
3661+
final List<Widget> borders = [
3662+
getBorderWidget(Container(
3663+
color: borderColor,
3664+
height: width + 0.1,
3665+
))
3666+
];
3667+
if (kWindowType == WindowType.Main && !isLight) {
3668+
borders.addAll([
3669+
getBorderWidget(Align(
3670+
alignment: Alignment.topLeft,
3671+
child: Container(
3672+
color: borderColor,
3673+
width: width,
3674+
),
3675+
)),
3676+
getBorderWidget(Align(
3677+
alignment: Alignment.topRight,
3678+
child: Container(
3679+
color: borderColor,
3680+
width: width,
3681+
),
3682+
)),
3683+
getBorderWidget(Align(
3684+
alignment: Alignment.bottomCenter,
3685+
child: Container(
3686+
color: borderColor,
3687+
height: width,
3688+
),
3689+
)),
3690+
]);
3691+
}
3692+
return Stack(
3693+
children: [
3694+
child,
3695+
...borders,
3696+
],
3697+
);
3698+
}

flutter/lib/consts.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ const kFullScreenEdgeSize = 0.0;
248248
const kMaximizeEdgeSize = 0.0;
249249
// Do not use kWindowResizeEdgeSize directly. Use `windowResizeEdgeSize` in `common.dart` instead.
250250
const kWindowResizeEdgeSize = 5.0;
251-
const kWindowBorderWidth = 1.0;
251+
final kWindowBorderWidth = isWindows ? 0.0 : 1.0;
252252
const kDesktopMenuPadding = EdgeInsets.only(left: 12.0, right: 3.0);
253253
const kFrameBorderRadius = 12.0;
254254
const kFrameClipRRectBorderRadius = 12.0;

flutter/lib/desktop/pages/file_manager_tab_page.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
103103
));
104104
final tabWidget = isLinux
105105
? buildVirtualWindowFrame(context, child)
106-
: Container(
107-
decoration: BoxDecoration(
108-
border: Border.all(color: MyTheme.color(context).border!)),
109-
child: child,
110-
);
106+
: workaroundWindowBorder(
107+
context,
108+
Container(
109+
decoration: BoxDecoration(
110+
border: Border.all(color: MyTheme.color(context).border!)),
111+
child: child,
112+
));
111113
return isMacOS || kUseCompatibleUiMode
112114
? tabWidget
113115
: SubWindowDragToResizeArea(

flutter/lib/desktop/pages/port_forward_tab_page.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
118118
backgroundColor: Theme.of(context).colorScheme.background,
119119
body: child),
120120
)
121-
: Container(
122-
decoration: BoxDecoration(
123-
border: Border.all(color: MyTheme.color(context).border!)),
124-
child: child,
125-
);
121+
: workaroundWindowBorder(
122+
context,
123+
Container(
124+
decoration: BoxDecoration(
125+
border: Border.all(color: MyTheme.color(context).border!)),
126+
child: child,
127+
));
126128
return isMacOS || kUseCompatibleUiMode
127129
? tabWidget
128130
: Obx(

flutter/lib/desktop/pages/remote_tab_page.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,16 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
212212
);
213213
final tabWidget = isLinux
214214
? buildVirtualWindowFrame(context, child)
215-
: Obx(() => Container(
216-
decoration: BoxDecoration(
217-
border: Border.all(
218-
color: MyTheme.color(context).border!,
219-
width: stateGlobal.windowBorderWidth.value),
220-
),
221-
child: child,
222-
));
215+
: workaroundWindowBorder(
216+
context,
217+
Obx(() => Container(
218+
decoration: BoxDecoration(
219+
border: Border.all(
220+
color: MyTheme.color(context).border!,
221+
width: stateGlobal.windowBorderWidth.value),
222+
),
223+
child: child,
224+
)));
223225
return isMacOS || kUseCompatibleUiMode
224226
? tabWidget
225227
: Obx(() => SubWindowDragToResizeArea(

flutter/lib/desktop/pages/server_page.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ class _DesktopServerPageState extends State<DesktopServerPage>
8888
);
8989
return isLinux
9090
? buildVirtualWindowFrame(context, body)
91-
: Container(
92-
decoration: BoxDecoration(
93-
border:
94-
Border.all(color: MyTheme.color(context).border!)),
95-
child: body,
96-
);
91+
: workaroundWindowBorder(
92+
context,
93+
Container(
94+
decoration: BoxDecoration(
95+
border:
96+
Border.all(color: MyTheme.color(context).border!)),
97+
child: body,
98+
));
9799
},
98100
),
99101
);

flutter/lib/main.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,10 @@ class _AppState extends State<App> with WidgetsBindingObserver {
489489
child = keyListenerBuilder(context, child);
490490
}
491491
if (isLinux) {
492-
child = buildVirtualWindowFrame(context, child);
492+
return buildVirtualWindowFrame(context, child);
493+
} else {
494+
return workaroundWindowBorder(context, child);
493495
}
494-
return child;
495496
},
496497
),
497498
);

0 commit comments

Comments
 (0)