mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-11 23:11:01 +03:00
Compare commits
403 Commits
1.4.5
...
fix-textur
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24a16d9a30 | ||
|
|
8fc82d04ac | ||
|
|
c6c001a15e | ||
|
|
7da2bbe6ac | ||
|
|
c5adac828b | ||
|
|
7c23e1f4b9 | ||
|
|
c4fd7d692d | ||
|
|
dfca2c1b8f | ||
|
|
10bcf976f7 | ||
|
|
63822048df | ||
|
|
1d09760ef7 | ||
|
|
23256e6ac1 | ||
|
|
ff07ff7f13 | ||
|
|
947cb3f17b | ||
|
|
d407db9fae | ||
|
|
594e63805c | ||
|
|
7c23fd3073 | ||
|
|
2915076642 | ||
|
|
11190fa54e | ||
|
|
d057fe14b2 | ||
|
|
4234b99029 | ||
|
|
6fd96dda6e | ||
|
|
429c8c6711 | ||
|
|
9a81c8a138 | ||
|
|
ddad47925c | ||
|
|
f5ab01f8bd | ||
|
|
cc85685b96 | ||
|
|
7eb9150116 | ||
|
|
ef3a57580f | ||
|
|
402ed07b0c | ||
|
|
3cf32e7066 | ||
|
|
6f1eb164d6 | ||
|
|
4389687d9d | ||
|
|
a84bad4639 | ||
|
|
e6dd925ab0 | ||
|
|
d752823b8c | ||
|
|
2f8822ec7a | ||
|
|
ffe20bb297 | ||
|
|
a5018a022b | ||
|
|
6c69faaa1c | ||
|
|
b19f1ef76f | ||
|
|
807e05ea9a | ||
|
|
e0254d997e | ||
|
|
006b9737e4 | ||
|
|
5aeb4cf945 | ||
|
|
c6c53f094a | ||
|
|
e63df74715 | ||
|
|
9aeb54cf33 | ||
|
|
3442648afe | ||
|
|
8545b5ed98 | ||
|
|
72c052cb9a | ||
|
|
12f2de5959 | ||
|
|
a6708f40e7 | ||
|
|
85a5fefab8 | ||
|
|
d412d19872 | ||
|
|
4dd8e20392 | ||
|
|
dabdbf73bb | ||
|
|
d6ea170061 | ||
|
|
eefd22b205 | ||
|
|
5882346caa | ||
|
|
b1fad7bbed | ||
|
|
57456f0b52 | ||
|
|
cefff781d4 | ||
|
|
ad9dac1001 | ||
|
|
b4af82157b | ||
|
|
beaa754299 | ||
|
|
929e989f17 | ||
|
|
1c2dd71891 | ||
|
|
5b4d6baf47 | ||
|
|
7696b0ee51 | ||
|
|
20ab5ab0ad | ||
|
|
c01300be20 | ||
|
|
5f015c9da1 | ||
|
|
082a5a2a4e | ||
|
|
61f0944990 | ||
|
|
96e2a330b8 | ||
|
|
5abf4e9724 | ||
|
|
cf2b28faf9 | ||
|
|
bdb38c4730 | ||
|
|
fa418cace6 | ||
|
|
94a2a2bb4a | ||
|
|
865fe71c46 | ||
|
|
137298e05a | ||
|
|
685a89a171 | ||
|
|
12b5cc7f72 | ||
|
|
480e9e8234 | ||
|
|
29e1852a68 | ||
|
|
8314335b31 | ||
|
|
acb9f63e1d | ||
|
|
005a8b4a04 | ||
|
|
e2149974cc | ||
|
|
6c578292e8 | ||
|
|
28930c0463 | ||
|
|
37141afece | ||
|
|
493b14ba78 | ||
|
|
cf1de4de62 | ||
|
|
9fdb8410d3 | ||
|
|
a2b79462ab | ||
|
|
dce221be5a | ||
|
|
9d1ab3fba3 | ||
|
|
b3bd18845d | ||
|
|
435f6ec61d | ||
|
|
0497814004 | ||
|
|
4b1ef9e20d | ||
|
|
10d5250d23 | ||
|
|
2ee580d49d | ||
|
|
4a54029cac | ||
|
|
001848bf2f | ||
|
|
989bf80fe8 | ||
|
|
78b5f47668 | ||
|
|
97e9e44faa | ||
|
|
ff226f6d80 | ||
|
|
0cbdb6ffb3 | ||
|
|
b8117c5c34 | ||
|
|
a69614d464 | ||
|
|
58ee593e26 | ||
|
|
09bc9056c9 | ||
|
|
0c6df924d1 | ||
|
|
456817b4f4 | ||
|
|
16570ee34f | ||
|
|
2b40c61d8e | ||
|
|
dcc64cdeae | ||
|
|
2747d3d8b4 | ||
|
|
3c574a4182 | ||
|
|
311d4708e5 | ||
|
|
5cf4323d07 | ||
|
|
3976701ac6 | ||
|
|
9ded8d6ab2 | ||
|
|
cd2fff0655 | ||
|
|
10f61ffdc2 | ||
|
|
d72952bf93 | ||
|
|
a7c55db9ac | ||
|
|
bff47e2b81 | ||
|
|
3d478c4935 | ||
|
|
a658e987b7 | ||
|
|
7c8b0adc1e | ||
|
|
a732ebc3e1 | ||
|
|
30c0867e40 | ||
|
|
8f50ea64dc | ||
|
|
0797ebb695 | ||
|
|
c9391fb894 | ||
|
|
8a955888bf | ||
|
|
36e812e550 | ||
|
|
8baa995c7a | ||
|
|
f4a0535289 | ||
|
|
6665242edf | ||
|
|
3cdf1cce54 | ||
|
|
88ae00ba73 | ||
|
|
7c26575dbd | ||
|
|
93d064a9b0 | ||
|
|
bf206dc309 | ||
|
|
6d116cf1c9 | ||
|
|
1fc33218dc | ||
|
|
b73e5bbfa0 | ||
|
|
78533e428e | ||
|
|
cc7fe4efdc | ||
|
|
84af60c07e | ||
|
|
6426269d41 | ||
|
|
7c41f993fe | ||
|
|
0c86d46162 | ||
|
|
e87797418f | ||
|
|
78a3a2aeb9 | ||
|
|
e18cf7a245 | ||
|
|
50d5823ef5 | ||
|
|
518296f257 | ||
|
|
3217125dd3 | ||
|
|
00032854eb | ||
|
|
d99ddf6816 | ||
|
|
32c6e32e04 | ||
|
|
c55b1f3359 | ||
|
|
fabeae4180 | ||
|
|
5eed50961d | ||
|
|
bed0976eb9 | ||
|
|
70d92d9b07 | ||
|
|
fb4ba31504 | ||
|
|
152c5c71b1 | ||
|
|
fa369365a5 | ||
|
|
7345366ba7 | ||
|
|
6151ea7128 | ||
|
|
440ab26b69 | ||
|
|
caadd72ab2 | ||
|
|
d59d543ec1 | ||
|
|
58d1109510 | ||
|
|
9c52e25a6a | ||
|
|
62a44c5a09 | ||
|
|
e5fa40e903 | ||
|
|
8177083992 | ||
|
|
4bfd8e9f61 | ||
|
|
81e7d27ec8 | ||
|
|
f3fc0b5ac2 | ||
|
|
fb7bca436b | ||
|
|
c19a0ceba2 | ||
|
|
1f26e452fc | ||
|
|
0af6b7ede9 | ||
|
|
6ad56075d6 | ||
|
|
b81ae6c894 | ||
|
|
546e9f1702 | ||
|
|
bb51c6aa42 | ||
|
|
78e8134ad5 | ||
|
|
bc2c36215d | ||
|
|
377547fa11 | ||
|
|
472c4fc03a | ||
|
|
9f8f726f12 | ||
|
|
701a9c6cdc | ||
|
|
0d40cf2101 | ||
|
|
dd265dadd7 | ||
|
|
fe5a8cb2ad | ||
|
|
b6caa1a7b2 | ||
|
|
55c9707639 | ||
|
|
d8808baa83 | ||
|
|
1978020d27 | ||
|
|
0e4b91b8d7 | ||
|
|
9c831dc59b | ||
|
|
b757e97c11 | ||
|
|
9df486a689 | ||
|
|
72d27c3c47 | ||
|
|
6c20fc936d | ||
|
|
5439ec38b6 | ||
|
|
8b8a64f870 | ||
|
|
92509f8e8a | ||
|
|
0221634a4d | ||
|
|
9d1f86fbc6 | ||
|
|
f29dec7b13 | ||
|
|
d5d0b01266 | ||
|
|
5abae617dc | ||
|
|
52d62da002 | ||
|
|
253d632709 | ||
|
|
383a5c3478 | ||
|
|
d4a1430c27 | ||
|
|
bfd31d21e4 | ||
|
|
590296b297 | ||
|
|
ee8cc0c06b | ||
|
|
99b565ef40 | ||
|
|
1e6a3dc644 | ||
|
|
5b7ad339b8 | ||
|
|
7308c448f1 | ||
|
|
c8ba99d1a1 | ||
|
|
5ea6714db8 | ||
|
|
3a1622e8b5 | ||
|
|
38f1300717 | ||
|
|
03e351ac61 | ||
|
|
6cb323725b | ||
|
|
5d0533f0d4 | ||
|
|
e0c5e1483e | ||
|
|
47e4c65d8e | ||
|
|
9bc1ce52af | ||
|
|
348d1b46e1 | ||
|
|
1a41b3ac11 | ||
|
|
b239535009 | ||
|
|
5fd20f808c | ||
|
|
803ac8cc4e | ||
|
|
4a50bc6fc2 | ||
|
|
e8a1b7fe21 | ||
|
|
ac124c0680 | ||
|
|
91aff3ffd1 | ||
|
|
642c281ad0 | ||
|
|
1e9c4d04f1 | ||
|
|
9f817714fe | ||
|
|
091f2c6135 | ||
|
|
91de51290d | ||
|
|
68fa0466c8 | ||
|
|
28e303576c | ||
|
|
2d41b3e80d | ||
|
|
ffd2d26c1a | ||
|
|
a8dc6fc632 | ||
|
|
771cb4ebd7 | ||
|
|
2f694c0eb2 | ||
|
|
8dea347a21 | ||
|
|
0cf3e8ed40 | ||
|
|
9d3bc7d9e6 | ||
|
|
e0427bdc77 | ||
|
|
9cf1338dc4 | ||
|
|
4e30ee8d1c | ||
|
|
cca6a5fe12 | ||
|
|
9e4b7fca4d | ||
|
|
d135c58ead | ||
|
|
de194417d4 | ||
|
|
d01ce3173f | ||
|
|
010a54d1c9 | ||
|
|
f557fc94fa | ||
|
|
f02cd9c0f6 | ||
|
|
170516572e | ||
|
|
285e29d2dc | ||
|
|
aab34b2338 | ||
|
|
ad1e5330e9 | ||
|
|
ca4647ddd6 | ||
|
|
7004acae46 | ||
|
|
899dd46f5b | ||
|
|
dba5fea66f | ||
|
|
c457b0e7d3 | ||
|
|
c0da4a6645 | ||
|
|
9d8df6a226 | ||
|
|
02da7132e7 | ||
|
|
e3b6e4eaf0 | ||
|
|
0388d00ad3 | ||
|
|
1e2d2c5146 | ||
|
|
96797742f2 | ||
|
|
682e347be0 | ||
|
|
b3f43f55c1 | ||
|
|
016a0b1141 | ||
|
|
fd7bcf54bd | ||
|
|
db3f5fe816 | ||
|
|
0d3016fcd8 | ||
|
|
1abc897c45 | ||
|
|
ab64a32f30 | ||
|
|
52b66e71d1 | ||
|
|
41ab5bbdd8 | ||
|
|
732b250815 | ||
|
|
157dbdc543 | ||
|
|
6ba23683d5 | ||
|
|
80a5865db3 | ||
|
|
9cb6f38aea | ||
|
|
cd7e3e4505 | ||
|
|
1833cb0655 | ||
|
|
e4208aa9cf | ||
|
|
bb3501a4f9 | ||
|
|
4abdb2e08b | ||
|
|
d49ae493b2 | ||
|
|
394079833e | ||
|
|
12d6789c2e | ||
|
|
34803f8e9b | ||
|
|
fd43184406 | ||
|
|
3cc3315081 | ||
|
|
6aee70fa18 | ||
|
|
82a9fd1540 | ||
|
|
dc760d6ca8 | ||
|
|
eb239501bc | ||
|
|
0016033937 | ||
|
|
50c62d5eac | ||
|
|
91ac48912e | ||
|
|
272a6604cd | ||
|
|
8a889d3ebb | ||
|
|
17a3f2ae52 | ||
|
|
6c3515588f | ||
|
|
4d2d2118a2 | ||
|
|
483fe80308 | ||
|
|
34ceeac36e | ||
|
|
20f11018ce | ||
|
|
9345fb754a | ||
|
|
779b7aaf02 | ||
|
|
b268aa1061 | ||
|
|
40f86fa639 | ||
|
|
980bc11e68 | ||
|
|
85db677982 | ||
|
|
2842315b1d | ||
|
|
6c541f7bfd | ||
|
|
067fab2b73 | ||
|
|
de6bf9dc7e | ||
|
|
54eae37038 | ||
|
|
0118e16132 | ||
|
|
626a091f55 | ||
|
|
4fa5e99e65 | ||
|
|
5ee9dcf42d | ||
|
|
6306f83316 | ||
|
|
96075fdf49 | ||
|
|
8c6dcf53a6 | ||
|
|
e1b1a927b8 | ||
|
|
1e6bfa7bb1 | ||
|
|
79ef4c4501 | ||
|
|
5f3ceef592 | ||
|
|
1a90e6b6c7 | ||
|
|
f112d097dc | ||
|
|
45cab7f808 | ||
|
|
216ec9d52b | ||
|
|
56a8f6b97b | ||
|
|
c76d10a438 | ||
|
|
f05f2178e5 | ||
|
|
226d7417b2 | ||
|
|
b0c8e65c6e | ||
|
|
4ae577c3c4 | ||
|
|
204e81a700 | ||
|
|
1f35830570 | ||
|
|
6b334f2977 | ||
|
|
0dc3c12aa5 | ||
|
|
ceffcce20e | ||
|
|
e4b06dadf5 | ||
|
|
087eb55299 | ||
|
|
341eb0c671 | ||
|
|
43b39102a4 | ||
|
|
be4bbd018d | ||
|
|
21a7cef98a | ||
|
|
a6724b1c07 | ||
|
|
7437593ee7 | ||
|
|
f21829b075 | ||
|
|
b4f60e6057 | ||
|
|
b9ebddff0c | ||
|
|
a2243484a3 | ||
|
|
c4a9835ae5 | ||
|
|
92ad279324 | ||
|
|
7276025cf9 | ||
|
|
9808d585cf | ||
|
|
dab9ed711c | ||
|
|
b27a93fc77 | ||
|
|
e3f66973b7 | ||
|
|
21529d6ca2 | ||
|
|
775b0a3c93 | ||
|
|
070d4d029f | ||
|
|
5355702e9c | ||
|
|
a97997952d | ||
|
|
b0c12bd86b | ||
|
|
82fcab26b1 | ||
|
|
f3bbcc4f55 | ||
|
|
98362eaca0 |
@@ -2,6 +2,8 @@
|
|||||||
rustflags = ["-Ctarget-feature=+crt-static"]
|
rustflags = ["-Ctarget-feature=+crt-static"]
|
||||||
[target.i686-pc-windows-msvc]
|
[target.i686-pc-windows-msvc]
|
||||||
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-args=/NODEFAULTLIB:MSVCRT"]
|
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-args=/NODEFAULTLIB:MSVCRT"]
|
||||||
|
[target.aarch64-pc-windows-msvc]
|
||||||
|
rustflags = ["-Ctarget-feature=+crt-static"]
|
||||||
[target.'cfg(target_os="macos")']
|
[target.'cfg(target_os="macos")']
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"-C", "link-args=-sectcreate __CGPreLoginApp __cgpreloginapp /dev/null",
|
"-C", "link-args=-sectcreate __CGPreLoginApp __cgpreloginapp /dev/null",
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
You are an expert in prompt engineering, specializing in optimizing AI code assistant instructions. Your task is to analyze and improve the instructions for Claude Code.
|
|
||||||
Follow these steps carefully:
|
|
||||||
|
|
||||||
1. Analysis Phase:
|
|
||||||
Review the chat history in your context window.
|
|
||||||
|
|
||||||
Then, examine the current Claude instructions, commands and config
|
|
||||||
<claude_instructions>
|
|
||||||
/CLAUDE.md
|
|
||||||
/.claude/commands/*
|
|
||||||
**/CLAUDE.md
|
|
||||||
.claude/settings.json
|
|
||||||
.claude/settings.local.json
|
|
||||||
</claude_instructions>
|
|
||||||
|
|
||||||
Analyze the chat history, instructions, commands and config to identify areas that could be improved. Look for:
|
|
||||||
- Inconsistencies in Claude's responses
|
|
||||||
- Misunderstandings of user requests
|
|
||||||
- Areas where Claude could provide more detailed or accurate information
|
|
||||||
- Opportunities to enhance Claude's ability to handle specific types of queries or tasks
|
|
||||||
- New commands or improvements to a commands name, function or response
|
|
||||||
- Permissions and MCPs we've approved locally that we should add to the config, especially if we've added new tools or require them for the command to work
|
|
||||||
|
|
||||||
2. Interaction Phase:
|
|
||||||
Present your findings and improvement ideas to the human. For each suggestion:
|
|
||||||
a) Explain the current issue you've identified
|
|
||||||
b) Propose a specific change or addition to the instructions
|
|
||||||
c) Describe how this change would improve Claude's performance
|
|
||||||
|
|
||||||
Wait for feedback from the human on each suggestion before proceeding. If the human approves a change, move it to the implementation phase. If not, refine your suggestion or move on to the next idea.
|
|
||||||
|
|
||||||
3. Implementation Phase:
|
|
||||||
For each approved change:
|
|
||||||
a) Clearly state the section of the instructions you're modifying
|
|
||||||
b) Present the new or modified text for that section
|
|
||||||
c) Explain how this change addresses the issue identified in the analysis phase
|
|
||||||
|
|
||||||
4. Output Format:
|
|
||||||
Present your final output in the following structure:
|
|
||||||
|
|
||||||
<analysis>
|
|
||||||
[List the issues identified and potential improvements]
|
|
||||||
</analysis>
|
|
||||||
|
|
||||||
<improvements>
|
|
||||||
[For each approved improvement:
|
|
||||||
1. Section being modified
|
|
||||||
2. New or modified instruction text
|
|
||||||
3. Explanation of how this addresses the identified issue]
|
|
||||||
</improvements>
|
|
||||||
|
|
||||||
<final_instructions>
|
|
||||||
[Present the complete, updated set of instructions for Claude, incorporating all approved changes]
|
|
||||||
</final_instructions>
|
|
||||||
|
|
||||||
Remember, your goal is to enhance Claude's performance and consistency while maintaining the core functionality and purpose of the AI assistant. Be thorough in your analysis, clear in your explanations, and precise in your implementations.
|
|
||||||
140
.github/patches/apply_flutter_3.44_source_patches.sh
vendored
Normal file
140
.github/patches/apply_flutter_3.44_source_patches.sh
vendored
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Applies the Flutter 3.44-only source/pubspec changes on the fly, in CI only.
|
||||||
|
#
|
||||||
|
# Windows arm64 needs Flutter >= 3.44 (the first stable release shipping an arm64 Dart SDK +
|
||||||
|
# engine), which renamed DialogTheme/TabBarTheme -> *Data and needs newer extended_text/
|
||||||
|
# google_fonts. Every other platform is still on Flutter 3.24.5, where the old names/versions
|
||||||
|
# are required, so these changes are kept OUT of the committed sources and applied here instead.
|
||||||
|
#
|
||||||
|
# Used by BOTH the Windows arm64 build (flutter-build.yml) and its dedicated bridge artifact
|
||||||
|
# (bridge.yml) so they share an identical 3.44 source state -- the generated *.freezed.dart must
|
||||||
|
# compile against the same Flutter/freezed version the arm64 build resolves.
|
||||||
|
#
|
||||||
|
# Remove this script (and commit the changes) once upstream bumps Flutter across the board.
|
||||||
|
#
|
||||||
|
# Run from the repository root. sed is used (not a git-apply patch) because the checked-out
|
||||||
|
# sources are CRLF on the windows-11-arm runner; the substitutions below are anchor-free and
|
||||||
|
# therefore CRLF-safe.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly NO_MATCHES=0
|
||||||
|
readonly SINGLE_MATCH=1
|
||||||
|
readonly THEME_MATCHES=2
|
||||||
|
|
||||||
|
has_exact_count() {
|
||||||
|
local -r expected_count="$1"
|
||||||
|
local -r pattern="$2"
|
||||||
|
local -r file="$3"
|
||||||
|
local actual_count
|
||||||
|
[[ -r "$file" ]] || return 1
|
||||||
|
actual_count="$(grep -cF "$pattern" "$file" || true)"
|
||||||
|
[[ "$actual_count" -eq "$expected_count" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# The target background-color line must directly follow DialogThemeData in the selected range.
|
||||||
|
has_dialog_background_in_theme_range() {
|
||||||
|
local -r start_pattern="$1"
|
||||||
|
local -r end_pattern="$2"
|
||||||
|
local -r target_pattern="$3"
|
||||||
|
local -r file="$4"
|
||||||
|
awk -v start_pattern="$start_pattern" \
|
||||||
|
-v end_pattern="$end_pattern" \
|
||||||
|
-v target_pattern="$target_pattern" '
|
||||||
|
index($0, start_pattern) {
|
||||||
|
in_theme = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
in_theme && index($0, end_pattern) {
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
in_theme && index($0, "dialogTheme: DialogThemeData(") {
|
||||||
|
if (getline > 0) {
|
||||||
|
line = $0
|
||||||
|
sub(/\r$/, "", line)
|
||||||
|
sub(/^[[:space:]]+/, "", line)
|
||||||
|
matched = line == target_pattern
|
||||||
|
}
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
exit matched ? 0 : 1
|
||||||
|
}
|
||||||
|
' "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_patch_inputs() {
|
||||||
|
if [[ ! -f flutter/lib/common.dart || ! -r flutter/lib/common.dart ]]; then
|
||||||
|
echo "Flutter 3.44 source patch input is missing or unreadable: flutter/lib/common.dart" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ! -f flutter/pubspec.yaml || ! -r flutter/pubspec.yaml ]]; then
|
||||||
|
echo "Flutter 3.44 source patch input is missing or unreadable: flutter/pubspec.yaml" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_complete_patch_state() {
|
||||||
|
has_exact_count "$THEME_MATCHES" 'dialogTheme: DialogThemeData(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$THEME_MATCHES" 'tabBarTheme: const TabBarThemeData(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$SINGLE_MATCH" 'backgroundColor: Colors.white,' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$SINGLE_MATCH" 'backgroundColor: Color(0xFF18191E),' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$SINGLE_MATCH" 'extended_text: 15.0.2' flutter/pubspec.yaml &&
|
||||||
|
has_exact_count "$SINGLE_MATCH" 'google_fonts: ^8.1.0' flutter/pubspec.yaml &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'dialogTheme: DialogTheme(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'tabBarTheme: const TabBarTheme(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'extended_text: 14.0.0' flutter/pubspec.yaml &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'google_fonts: ^6.2.1' flutter/pubspec.yaml &&
|
||||||
|
has_dialog_background_in_theme_range 'static ThemeData lightTheme = ThemeData(' \
|
||||||
|
'static ThemeData darkTheme = ThemeData(' 'backgroundColor: Colors.white,' \
|
||||||
|
flutter/lib/common.dart &&
|
||||||
|
has_dialog_background_in_theme_range 'static ThemeData darkTheme = ThemeData(' \
|
||||||
|
'scrollbarTheme: scrollbarThemeDark,' 'backgroundColor: Color(0xFF18191E),' \
|
||||||
|
flutter/lib/common.dart
|
||||||
|
}
|
||||||
|
|
||||||
|
is_unpatched_state() {
|
||||||
|
has_exact_count "$THEME_MATCHES" 'dialogTheme: DialogTheme(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$THEME_MATCHES" 'tabBarTheme: const TabBarTheme(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$SINGLE_MATCH" 'extended_text: 14.0.0' flutter/pubspec.yaml &&
|
||||||
|
has_exact_count "$SINGLE_MATCH" 'google_fonts: ^6.2.1' flutter/pubspec.yaml &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'dialogTheme: DialogThemeData(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'tabBarTheme: const TabBarThemeData(' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'backgroundColor: Colors.white,' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'backgroundColor: Color(0xFF18191E),' flutter/lib/common.dart &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'extended_text: 15.0.2' flutter/pubspec.yaml &&
|
||||||
|
has_exact_count "$NO_MATCHES" 'google_fonts: ^8.1.0' flutter/pubspec.yaml
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! validate_patch_inputs; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_complete_patch_state; then
|
||||||
|
echo "Flutter 3.44 source patches already applied."
|
||||||
|
git --no-pager diff -- flutter/lib/common.dart flutter/pubspec.yaml
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_unpatched_state; then
|
||||||
|
echo "Flutter 3.44 source patches are partially applied or their anchors have drifted." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ThemeData API renames (Flutter 3.27+):
|
||||||
|
sed -i 's/dialogTheme: DialogTheme(/dialogTheme: DialogThemeData(/g' flutter/lib/common.dart
|
||||||
|
sed -i 's/tabBarTheme: const TabBarTheme(/tabBarTheme: const TabBarThemeData(/g' flutter/lib/common.dart
|
||||||
|
sed -i '/static ThemeData lightTheme = ThemeData(/,/static ThemeData darkTheme = ThemeData(/s/dialogTheme: DialogThemeData(/dialogTheme: DialogThemeData(\
|
||||||
|
backgroundColor: Colors.white,/' flutter/lib/common.dart
|
||||||
|
sed -i '/static ThemeData darkTheme = ThemeData(/,/scrollbarTheme: scrollbarThemeDark,/s/dialogTheme: DialogThemeData(/dialogTheme: DialogThemeData(\
|
||||||
|
backgroundColor: Color(0xFF18191E),/' flutter/lib/common.dart
|
||||||
|
# Dependency bumps required by the newer Dart/Flutter:
|
||||||
|
sed -i 's/extended_text: 14.0.0/extended_text: 15.0.2/' flutter/pubspec.yaml
|
||||||
|
sed -i 's/google_fonts: \^6.2.1/google_fonts: ^8.1.0/' flutter/pubspec.yaml
|
||||||
|
|
||||||
|
# Fail loudly if any expected substitution did not produce the complete state.
|
||||||
|
if ! is_complete_patch_state; then
|
||||||
|
echo "Flutter 3.44 source patches did not produce the expected state." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git --no-pager diff -- flutter/lib/common.dart flutter/pubspec.yaml
|
||||||
51
.github/patches/apply_flutter_3.44_web_patches.sh
vendored
Executable file
51
.github/patches/apply_flutter_3.44_web_patches.sh
vendored
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Prepares a web build on Flutter 3.44.x. Companion to
|
||||||
|
# apply_flutter_3.44_source_patches.sh (which it runs first): the web target
|
||||||
|
# additionally needs qr_code_scanner's web implementation patched for the
|
||||||
|
# dart:ui platformViewRegistry removal, and flutter/web/fonts refreshed with
|
||||||
|
# the font paths the 3.44 engine requests for offline/air-gapped support
|
||||||
|
# (rustdesk-server-pro#996; see flutter/web/fonts/sync_fonts.py).
|
||||||
|
#
|
||||||
|
# Run from the repository root with Flutter 3.44.x on PATH, then build:
|
||||||
|
# bash .github/patches/apply_flutter_3.44_web_patches.sh
|
||||||
|
# (cd flutter && flutter build web --release) # or ./web/js/flutter_build.py
|
||||||
|
#
|
||||||
|
# Idempotent. To undo the source changes locally:
|
||||||
|
# git checkout -- flutter/lib/common.dart flutter/pubspec.yaml flutter/pubspec.lock
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
flutter --version | grep -q "Flutter 3\.44\." || {
|
||||||
|
echo "Flutter 3.44.x must be on PATH; found:" >&2
|
||||||
|
flutter --version | grep "^Flutter" >&2 || true
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shared 3.44 source/pubspec patches own their complete-state validation.
|
||||||
|
bash .github/patches/apply_flutter_3.44_source_patches.sh
|
||||||
|
|
||||||
|
# Populate the pub cache with the 3.44 dependency resolution.
|
||||||
|
(cd flutter && flutter pub get)
|
||||||
|
|
||||||
|
# qr_code_scanner 1.0.1 (unmaintained) reads platformViewRegistry from
|
||||||
|
# dart:ui, which Flutter 3.44 removed; point it at dart:ui_web instead. The
|
||||||
|
# patched file also compiles on Flutter 3.24 (dart:ui_web exists there), so
|
||||||
|
# mutating the shared pub cache is safe for other local builds.
|
||||||
|
QR_WEB="${PUB_CACHE:-$HOME/.pub-cache}/hosted/pub.dev/qr_code_scanner-1.0.1/lib/src/web/flutter_qr_web.dart"
|
||||||
|
if ! grep -qF "dart:ui_web" "$QR_WEB"; then
|
||||||
|
sed -i.bak "s|import 'dart:ui' as ui;|import 'dart:ui' as ui; import 'dart:ui_web' as ui_web;|" "$QR_WEB"
|
||||||
|
rm -f "$QR_WEB.bak"
|
||||||
|
fi
|
||||||
|
if grep -qF "ui.platformViewRegistry" "$QR_WEB"; then
|
||||||
|
sed -i.bak "s|ui\.platformViewRegistry|ui_web.platformViewRegistry|g" "$QR_WEB"
|
||||||
|
rm -f "$QR_WEB.bak"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Mirror the fonts this engine version requests into flutter/web/fonts.
|
||||||
|
python3 flutter/web/fonts/sync_fonts.py
|
||||||
|
|
||||||
|
# Fail loudly if any expected state is missing:
|
||||||
|
grep -qF "import 'dart:ui' as ui; import 'dart:ui_web' as ui_web;" "$QR_WEB"
|
||||||
|
grep -qF "ui_web.platformViewRegistry" "$QR_WEB"
|
||||||
|
grep -qF 'google_fonts: ^8.1.0' flutter/pubspec.yaml
|
||||||
|
|
||||||
|
echo "Flutter 3.44 web patches applied."
|
||||||
40
.github/workflows/bridge.yml
vendored
40
.github/workflows/bridge.yml
vendored
@@ -7,7 +7,6 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_EXPAND_VERSION: "1.0.95"
|
CARGO_EXPAND_VERSION: "1.0.95"
|
||||||
FLUTTER_VERSION: "3.22.3"
|
|
||||||
FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
|
FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
|
||||||
RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
|
RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
|
||||||
|
|
||||||
@@ -18,14 +17,25 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
job:
|
job:
|
||||||
|
# Default bridge for every platform still on Flutter 3.24.5 (generated with 3.22.3).
|
||||||
- {
|
- {
|
||||||
target: x86_64-unknown-linux-gnu,
|
target: x86_64-unknown-linux-gnu,
|
||||||
os: ubuntu-22.04,
|
os: ubuntu-22.04,
|
||||||
extra-build-args: "",
|
extra-build-args: "",
|
||||||
|
flutter-version: "3.22.3",
|
||||||
|
artifact-name: "bridge-artifact",
|
||||||
|
}
|
||||||
|
# Dedicated bridge for the Windows arm64 build (Flutter 3.44); runs in parallel.
|
||||||
|
- {
|
||||||
|
target: x86_64-unknown-linux-gnu,
|
||||||
|
os: ubuntu-22.04,
|
||||||
|
extra-build-args: "",
|
||||||
|
flutter-version: "3.44.8",
|
||||||
|
artifact-name: "bridge-artifact-flutter-3.44",
|
||||||
}
|
}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source code
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@@ -49,28 +59,28 @@ jobs:
|
|||||||
wget
|
wget
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@v1
|
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ env.RUST_VERSION }}
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
targets: ${{ matrix.job.target }}
|
targets: ${{ matrix.job.target }}
|
||||||
components: "rustfmt"
|
components: "rustfmt"
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||||
with:
|
with:
|
||||||
prefix-key: bridge-${{ matrix.job.os }}
|
prefix-key: bridge-${{ matrix.job.os }}
|
||||||
|
|
||||||
- name: Cache Bridge
|
- name: Cache Bridge
|
||||||
id: cache-bridge
|
id: cache-bridge
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3
|
||||||
with:
|
with:
|
||||||
path: /tmp/flutter_rust_bridge
|
path: /tmp/flutter_rust_bridge
|
||||||
key: vcpkg-${{ matrix.job.arch }}
|
key: bridge-${{ matrix.job.flutter-version }}
|
||||||
|
|
||||||
- name: Install flutter
|
- name: Install flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
|
||||||
with:
|
with:
|
||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
flutter-version: ${{ matrix.job.flutter-version }}
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Install flutter rust bridge deps
|
- name: Install flutter rust bridge deps
|
||||||
@@ -78,7 +88,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cargo install cargo-expand --version ${{ env.CARGO_EXPAND_VERSION }} --locked
|
cargo install cargo-expand --version ${{ env.CARGO_EXPAND_VERSION }} --locked
|
||||||
cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid" --locked
|
cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid" --locked
|
||||||
pushd flutter && sed -i -e 's/extended_text: 14.0.0/extended_text: 13.0.0/g' pubspec.yaml && flutter pub get && popd
|
if [[ "${{ matrix.job.flutter-version }}" == "3.22.3" ]]; then
|
||||||
|
# Default Flutter 3.22.3: extended_text 14 needs a newer Dart, so downgrade for resolution.
|
||||||
|
sed -i -e 's/extended_text: 14.0.0/extended_text: 13.0.0/g' flutter/pubspec.yaml
|
||||||
|
else
|
||||||
|
# Flutter 3.44 bridge for Windows arm64: match that build's source/pubspec state so the
|
||||||
|
# generated *.freezed.dart compiles against the same Flutter/freezed it resolves.
|
||||||
|
bash .github/patches/apply_flutter_3.44_source_patches.sh
|
||||||
|
fi
|
||||||
|
pushd flutter && flutter pub get && popd
|
||||||
|
|
||||||
- name: Run flutter rust bridge
|
- name: Run flutter rust bridge
|
||||||
run: |
|
run: |
|
||||||
@@ -86,9 +104,9 @@ jobs:
|
|||||||
cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h
|
cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||||
with:
|
with:
|
||||||
name: bridge-artifact
|
name: ${{ matrix.job.artifact-name }}
|
||||||
path: |
|
path: |
|
||||||
./src/bridge_generated.rs
|
./src/bridge_generated.rs
|
||||||
./src/bridge_generated.io.rs
|
./src/bridge_generated.io.rs
|
||||||
|
|||||||
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@@ -29,13 +29,13 @@ jobs:
|
|||||||
# name: Ensure 'cargo fmt' has been run
|
# name: Ensure 'cargo fmt' has been run
|
||||||
# runs-on: ubuntu-20.04
|
# runs-on: ubuntu-20.04
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions-rs/toolchain@v1
|
# - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1
|
||||||
# with:
|
# with:
|
||||||
# toolchain: stable
|
# toolchain: stable
|
||||||
# default: true
|
# default: true
|
||||||
# profile: minimal
|
# profile: minimal
|
||||||
# components: rustfmt
|
# components: rustfmt
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||||
# - run: cargo fmt -- --check
|
# - run: cargo fmt -- --check
|
||||||
|
|
||||||
# min_version:
|
# min_version:
|
||||||
@@ -43,24 +43,24 @@ jobs:
|
|||||||
# runs-on: ubuntu-20.04
|
# runs-on: ubuntu-20.04
|
||||||
# steps:
|
# steps:
|
||||||
# - name: Checkout source code
|
# - name: Checkout source code
|
||||||
# uses: actions/checkout@v3
|
# uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||||
# with:
|
# with:
|
||||||
# submodules: recursive
|
# submodules: recursive
|
||||||
|
|
||||||
# - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
|
# - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
|
||||||
# uses: actions-rs/toolchain@v1
|
# uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1
|
||||||
# with:
|
# with:
|
||||||
# toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
|
# toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
|
||||||
# default: true
|
# default: true
|
||||||
# profile: minimal # minimal component installation (ie, no documentation)
|
# profile: minimal # minimal component installation (ie, no documentation)
|
||||||
# components: clippy
|
# components: clippy
|
||||||
# - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
|
# - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
|
||||||
# uses: actions-rs/cargo@v1
|
# uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
|
||||||
# with:
|
# with:
|
||||||
# command: clippy
|
# command: clippy
|
||||||
# args: --locked --all-targets --all-features -- --allow clippy::unknown_clippy_lints
|
# args: --locked --all-targets --all-features -- --allow clippy::unknown_clippy_lints
|
||||||
# - name: Run tests
|
# - name: Run tests
|
||||||
# uses: actions-rs/cargo@v1
|
# uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
|
||||||
# with:
|
# with:
|
||||||
# command: test
|
# command: test
|
||||||
# args: --locked
|
# args: --locked
|
||||||
@@ -81,14 +81,15 @@ jobs:
|
|||||||
# - { target: x86_64-apple-darwin , os: macos-10.15 }
|
# - { target: x86_64-apple-darwin , os: macos-10.15 }
|
||||||
# - { target: x86_64-pc-windows-gnu , os: windows-2022 }
|
# - { target: x86_64-pc-windows-gnu , os: windows-2022 }
|
||||||
# - { target: x86_64-pc-windows-msvc , os: windows-2022 }
|
# - { target: x86_64-pc-windows-msvc , os: windows-2022 }
|
||||||
|
# - { target: aarch64-pc-windows-msvc , os: windows-11-arm }
|
||||||
- { target: x86_64-unknown-linux-gnu , os: ubuntu-24.04 }
|
- { target: x86_64-unknown-linux-gnu , os: ubuntu-24.04 }
|
||||||
# - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
|
# - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
|
||||||
steps:
|
steps:
|
||||||
- name: Free Disk Space (Ubuntu)
|
- name: Free Disk Space (Ubuntu)
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
# jlumbroso/free-disk-space@main is used in .github\workflows\flutter-build.yml
|
# jlumbroso/free-disk-space@v1.3.1 is used in .github\workflows\flutter-build.yml
|
||||||
# But pinning to a specific version to avoid unexpected issues is preferred.
|
# But pinning to a specific version to avoid unexpected issues is preferred.
|
||||||
uses: jlumbroso/free-disk-space@v1.3.1
|
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
|
||||||
with:
|
with:
|
||||||
tool-cache: false
|
tool-cache: false
|
||||||
android: true
|
android: true
|
||||||
@@ -99,14 +100,14 @@ jobs:
|
|||||||
swap-storage: false
|
swap-storage: false
|
||||||
|
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||||
|
|
||||||
- name: Checkout source code
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ jobs:
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
- name: Setup vcpkg with Github Actions binary cache
|
- name: Setup vcpkg with Github Actions binary cache
|
||||||
uses: lukka/run-vcpkg@v11
|
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
|
||||||
with:
|
with:
|
||||||
vcpkgDirectory: /opt/artifacts/vcpkg
|
vcpkgDirectory: /opt/artifacts/vcpkg
|
||||||
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
||||||
@@ -156,7 +157,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@v1
|
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
targets: ${{ matrix.job.target }}
|
targets: ${{ matrix.job.target }}
|
||||||
@@ -172,10 +173,10 @@ jobs:
|
|||||||
cargo -V
|
cargo -V
|
||||||
rustc -V
|
rustc -V
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
|
||||||
with:
|
with:
|
||||||
use-cross: ${{ matrix.job.use-cross }}
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
command: build
|
command: build
|
||||||
@@ -243,7 +244,7 @@ jobs:
|
|||||||
echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT
|
echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
|
||||||
with:
|
with:
|
||||||
use-cross: ${{ matrix.job.use-cross }}
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
command: test
|
command: test
|
||||||
|
|||||||
4
.github/workflows/clear-cache.yml
vendored
4
.github/workflows/clear-cache.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clear cache
|
- name: Clear cache
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
console.log("About to clear")
|
console.log("About to clear")
|
||||||
@@ -30,7 +30,7 @@ jobs:
|
|||||||
console.log("Clear completed")
|
console.log("Clear completed")
|
||||||
|
|
||||||
- name: Purge cache # Above seems not clear thouroughly, so add this to double clear
|
- name: Purge cache # Above seems not clear thouroughly, so add this to double clear
|
||||||
uses: MyAlbum/purge-cache@v2
|
uses: MyAlbum/purge-cache@881eb5957687193fa612bf74c0042adc78ea5e54 # v2
|
||||||
with:
|
with:
|
||||||
accessed: true # Purge caches by their last accessed time (default)
|
accessed: true # Purge caches by their last accessed time (default)
|
||||||
created: false # Purge caches by their created time (default)
|
created: false # Purge caches by their created time (default)
|
||||||
|
|||||||
2
.github/workflows/fdroid.yml
vendored
2
.github/workflows/fdroid.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Publish RustDesk version file
|
- name: Publish RustDesk version file
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
tag_name: "fdroid-version"
|
tag_name: "fdroid-version"
|
||||||
|
|||||||
679
.github/workflows/flutter-build.yml
vendored
679
.github/workflows/flutter-build.yml
vendored
File diff suppressed because it is too large
Load Diff
36
.github/workflows/playground.yml
vendored
36
.github/workflows/playground.yml
vendored
@@ -17,7 +17,7 @@ env:
|
|||||||
TAG_NAME: "nightly"
|
TAG_NAME: "nightly"
|
||||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
VCPKG_COMMIT_ID: "120deac3062162151622ca4860575a33844ba10b"
|
VCPKG_COMMIT_ID: "120deac3062162151622ca4860575a33844ba10b"
|
||||||
VERSION: "1.4.5"
|
VERSION: "1.4.9"
|
||||||
NDK_VERSION: "r26d"
|
NDK_VERSION: "r26d"
|
||||||
#signing keys env variable checks
|
#signing keys env variable checks
|
||||||
ANDROID_SIGNING_KEY: "${{ secrets.ANDROID_SIGNING_KEY }}"
|
ANDROID_SIGNING_KEY: "${{ secrets.ANDROID_SIGNING_KEY }}"
|
||||||
@@ -79,21 +79,21 @@ jobs:
|
|||||||
}
|
}
|
||||||
steps:
|
steps:
|
||||||
- name: Export GitHub Actions cache environment variables
|
- name: Export GitHub Actions cache environment variables
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||||
|
|
||||||
- name: Checkout source code
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||||
with:
|
with:
|
||||||
ref: ${{ matrix.job.ref }}
|
ref: ${{ matrix.job.ref }}
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Import the codesign cert
|
- name: Import the codesign cert
|
||||||
if: env.MACOS_P12_BASE64 != null
|
if: env.MACOS_P12_BASE64 != null
|
||||||
uses: apple-actions/import-codesign-certs@v1
|
uses: apple-actions/import-codesign-certs@253ddeeac23f2bdad1646faac5c8c2832e800071 # v1
|
||||||
with:
|
with:
|
||||||
p12-file-base64: ${{ secrets.MACOS_P12_BASE64 }}
|
p12-file-base64: ${{ secrets.MACOS_P12_BASE64 }}
|
||||||
p12-password: ${{ secrets.MACOS_P12_PASSWORD }}
|
p12-password: ${{ secrets.MACOS_P12_PASSWORD }}
|
||||||
@@ -107,7 +107,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Import notarize key
|
- name: Import notarize key
|
||||||
if: env.MACOS_P12_BASE64 != null
|
if: env.MACOS_P12_BASE64 != null
|
||||||
uses: timheuer/base64-to-file@v1.2
|
uses: timheuer/base64-to-file@adaa40c0c581f276132199d4cf60afa07ce60eac # v1.2
|
||||||
with:
|
with:
|
||||||
# https://gregoryszorc.com/docs/apple-codesign/stable/apple_codesign_rcodesign.html#notarizing-and-stapling
|
# https://gregoryszorc.com/docs/apple-codesign/stable/apple_codesign_rcodesign.html#notarizing-and-stapling
|
||||||
fileName: rustdesk.json
|
fileName: rustdesk.json
|
||||||
@@ -129,19 +129,19 @@ jobs:
|
|||||||
brew install llvm create-dmg nasm pkg-config
|
brew install llvm create-dmg nasm pkg-config
|
||||||
|
|
||||||
- name: Install flutter
|
- name: Install flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
|
||||||
with:
|
with:
|
||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version: ${{ matrix.job.flutter }}
|
flutter-version: ${{ matrix.job.flutter }}
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@v1
|
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ env.RUST_VERSION }}
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
targets: ${{ matrix.job.target }}
|
targets: ${{ matrix.job.target }}
|
||||||
components: "rustfmt"
|
components: "rustfmt"
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||||
with:
|
with:
|
||||||
prefix-key: ${{ matrix.job.os }}
|
prefix-key: ${{ matrix.job.os }}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ jobs:
|
|||||||
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --c-output ./flutter/macos/Runner/bridge_generated.h
|
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --c-output ./flutter/macos/Runner/bridge_generated.h
|
||||||
|
|
||||||
- name: Setup vcpkg with Github Actions binary cache
|
- name: Setup vcpkg with Github Actions binary cache
|
||||||
uses: lukka/run-vcpkg@v11
|
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
|
||||||
with:
|
with:
|
||||||
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ jobs:
|
|||||||
$VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed"
|
$VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed"
|
||||||
|
|
||||||
- name: Restore from cache and install vcpkg
|
- name: Restore from cache and install vcpkg
|
||||||
uses: lukka/run-vcpkg@v7
|
uses: lukka/run-vcpkg@8a5116de2b552d6fc8894e9774aacaf2e5db4823 # v7 2026-05-26
|
||||||
if: false
|
if: false
|
||||||
with:
|
with:
|
||||||
setupOnly: true
|
setupOnly: true
|
||||||
@@ -222,7 +222,7 @@ jobs:
|
|||||||
done
|
done
|
||||||
|
|
||||||
- name: Publish DMG package
|
- name: Publish DMG package
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
tag_name: ${{ env.TAG_NAME }}
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
@@ -247,7 +247,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source code
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
|
||||||
with:
|
with:
|
||||||
ref: ${{ matrix.job.ref }}
|
ref: ${{ matrix.job.ref }}
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
@@ -290,13 +290,13 @@ jobs:
|
|||||||
wget
|
wget
|
||||||
|
|
||||||
- name: Install flutter
|
- name: Install flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
|
||||||
with:
|
with:
|
||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@v1
|
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ env.RUST_VERSION }}
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
components: "rustfmt"
|
components: "rustfmt"
|
||||||
@@ -310,14 +310,14 @@ jobs:
|
|||||||
pushd flutter ; flutter pub get ; popd
|
pushd flutter ; flutter pub get ; popd
|
||||||
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
|
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
|
||||||
|
|
||||||
- uses: nttld/setup-ndk@v1
|
- uses: nttld/setup-ndk@ed92fe6cadad69be94a966a7ee3271275e62f779 # v1
|
||||||
id: setup-ndk
|
id: setup-ndk
|
||||||
with:
|
with:
|
||||||
ndk-version: ${{ env.NDK_VERSION }}
|
ndk-version: ${{ env.NDK_VERSION }}
|
||||||
add-to-path: true
|
add-to-path: true
|
||||||
|
|
||||||
- name: Setup vcpkg with Github Actions binary cache
|
- name: Setup vcpkg with Github Actions binary cache
|
||||||
uses: lukka/run-vcpkg@v11
|
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
|
||||||
with:
|
with:
|
||||||
vcpkgDirectory: /opt/artifacts/vcpkg
|
vcpkgDirectory: /opt/artifacts/vcpkg
|
||||||
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
||||||
@@ -395,7 +395,7 @@ jobs:
|
|||||||
mkdir -p signed-apk; pushd signed-apk
|
mkdir -p signed-apk; pushd signed-apk
|
||||||
mv ../rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.apk ./rustdesk-test-${{ matrix.job.ref }}-${{ matrix.job.ndk }}.apk
|
mv ../rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.apk ./rustdesk-test-${{ matrix.job.ref }}-${{ matrix.job.ndk }}.apk
|
||||||
|
|
||||||
- uses: r0adkll/sign-android-release@v1
|
- uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 # v1
|
||||||
name: Sign app APK
|
name: Sign app APK
|
||||||
if: env.ANDROID_SIGNING_KEY != null
|
if: env.ANDROID_SIGNING_KEY != null
|
||||||
id: sign-rustdesk
|
id: sign-rustdesk
|
||||||
@@ -410,7 +410,7 @@ jobs:
|
|||||||
BUILD_TOOLS_VERSION: "30.0.2"
|
BUILD_TOOLS_VERSION: "30.0.2"
|
||||||
|
|
||||||
- name: Publish signed apk package
|
- name: Publish signed apk package
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
tag_name: ${{ env.TAG_NAME }}
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
|
|||||||
@@ -39,22 +39,21 @@ jobs:
|
|||||||
build_output_dir: RustDeskTempTopMostWindow/WindowInjection/${{ inputs.platform }}/${{ inputs.configuration }}
|
build_output_dir: RustDeskTempTopMostWindow/WindowInjection/${{ inputs.platform }}/${{ inputs.configuration }}
|
||||||
steps:
|
steps:
|
||||||
- name: Add MSBuild to PATH
|
- name: Add MSBuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v2
|
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
|
||||||
|
|
||||||
- name: Download the source code
|
- name: Download the source code
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/rustdesk-org/RustDeskTempTopMostWindow RustDeskTempTopMostWindow
|
git clone https://github.com/rustdesk-org/RustDeskTempTopMostWindow RustDeskTempTopMostWindow
|
||||||
|
|
||||||
# Build. commit 53b548a5398624f7149a382000397993542ad796 is tag v0.3
|
|
||||||
- name: Build the project
|
- name: Build the project
|
||||||
run: |
|
run: |
|
||||||
cd RustDeskTempTopMostWindow && git checkout 53b548a5398624f7149a382000397993542ad796
|
cd RustDeskTempTopMostWindow && git checkout ecd8d6a139eee76845ea66423fb739af450fda90
|
||||||
msbuild ${{ env.project_path }} -p:Configuration=${{ inputs.configuration }} -p:Platform=${{ inputs.platform }} /p:TargetVersion=${{ inputs.target_version }}
|
msbuild ${{ env.project_path }} -p:Configuration=${{ inputs.configuration }} -p:Platform=${{ inputs.platform }} /p:TargetVersion=${{ inputs.target_version }}
|
||||||
|
|
||||||
- name: Archive build artifacts
|
- name: Archive build artifacts
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||||
if: ${{ inputs.upload-artifact }}
|
if: ${{ inputs.upload-artifact }}
|
||||||
with:
|
with:
|
||||||
name: topmostwindow-artifacts
|
name: topmostwindow-artifacts-${{ inputs.platform }}
|
||||||
path: |
|
path: |
|
||||||
./${{ env.build_output_dir }}/WindowInjection.dll
|
./${{ env.build_output_dir }}/WindowInjection.dll
|
||||||
|
|||||||
71
.github/workflows/update-webpki-roots.yml
vendored
Normal file
71
.github/workflows/update-webpki-roots.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
name: Update webpki-roots
|
||||||
|
|
||||||
|
# Weekly refresh of the compiled-in TLS root certificates (the webpki-roots
|
||||||
|
# crate, a snapshot of the Mozilla root store). Roots are otherwise frozen at
|
||||||
|
# whatever Cargo.lock pins, so old builds miss newly added CAs and keep
|
||||||
|
# removed (distrusted) ones. Changes go through a PR on purpose: added or
|
||||||
|
# removed roots should be reviewed, not silently baked into releases.
|
||||||
|
#
|
||||||
|
# Note: PRs created with the default GITHUB_TOKEN do not trigger other
|
||||||
|
# workflows (GitHub limitation). Close and reopen the PR, or push to its
|
||||||
|
# branch, to run CI on it.
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 3 * * 1"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# A manual dispatch overlapping the weekly run would race it force-pushing
|
||||||
|
# the same branch; queue instead of overlapping, and never cancel a run
|
||||||
|
# that may have already pushed.
|
||||||
|
concurrency:
|
||||||
|
group: update-webpki-roots
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
env:
|
||||||
|
BRANCH: auto-update-webpki-roots
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||||
|
|
||||||
|
- name: Update webpki-roots in all lockfiles
|
||||||
|
id: update
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
git ls-files -z '*Cargo.lock' | while IFS= read -r -d '' lock; do
|
||||||
|
dir=$(dirname "$lock")
|
||||||
|
for v in $(sed -n '/name = "webpki-roots"/{n;s/.*version = "\(.*\)"/\1/p;}' "$lock" | sort -u); do
|
||||||
|
echo "updating webpki-roots@$v in $dir"
|
||||||
|
(cd "$dir" && cargo update -p "webpki-roots@$v")
|
||||||
|
done
|
||||||
|
done
|
||||||
|
if git diff --quiet -- '*Cargo.lock'; then
|
||||||
|
echo "changed=0" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "changed=1" >> "$GITHUB_OUTPUT"
|
||||||
|
git --no-pager diff -- '*Cargo.lock'
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create pull request
|
||||||
|
if: steps.update.outputs.changed == '1'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git checkout -B "$BRANCH"
|
||||||
|
git add -- '*Cargo.lock'
|
||||||
|
git commit -m "chore: update webpki-roots to latest Mozilla root store"
|
||||||
|
git push -f origin "$BRANCH"
|
||||||
|
if [ -z "$(gh pr list --head "$BRANCH" --state open --json number --jq '.[].number')" ]; then
|
||||||
|
gh pr create \
|
||||||
|
--title "chore: update webpki-roots to latest Mozilla root store" \
|
||||||
|
--body "Automated weekly refresh of the compiled-in TLS root certificates (webpki-roots). Please review the added/removed roots. CI does not run automatically on PRs created by GITHUB_TOKEN; close and reopen this PR to trigger it."
|
||||||
|
fi
|
||||||
15
.github/workflows/winget.yml
vendored
15
.github/workflows/winget.yml
vendored
@@ -1,15 +0,0 @@
|
|||||||
name: Publish to WinGet
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [released]
|
|
||||||
workflow_dispatch:
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: vedantmgoyal9/winget-releaser@main
|
|
||||||
with:
|
|
||||||
identifier: RustDesk.RustDesk
|
|
||||||
version: "1.4.5"
|
|
||||||
release-tag: "1.4.5"
|
|
||||||
token: ${{ secrets.WINGET_TOKEN }}
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env
|
||||||
libsciter-gtk.so
|
libsciter-gtk.so
|
||||||
src/ui/inline.rs
|
src/ui/inline.rs
|
||||||
extractor
|
extractor
|
||||||
@@ -55,3 +56,5 @@ vcpkg_installed
|
|||||||
flutter/lib/generated_plugin_registrant.dart
|
flutter/lib/generated_plugin_registrant.dart
|
||||||
libsciter.dylib
|
libsciter.dylib
|
||||||
flutter/web/
|
flutter/web/
|
||||||
|
# libdrmtap is cloned at build time by build.py (not a submodule)
|
||||||
|
/third_party/libdrmtap/
|
||||||
|
|||||||
105
AGENTS.md
Normal file
105
AGENTS.md
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# RustDesk Guide
|
||||||
|
|
||||||
|
## Project Layout
|
||||||
|
|
||||||
|
### Directory Structure
|
||||||
|
* `src/` Rust app
|
||||||
|
* `src/server/` audio / clipboard / input / video / network
|
||||||
|
* `src/platform/` platform-specific code
|
||||||
|
* `src/ui/` legacy Sciter UI (deprecated)
|
||||||
|
* `flutter/` current UI
|
||||||
|
* `libs/hbb_common/` config / proto / shared utils
|
||||||
|
* `libs/scrap/` screen capture
|
||||||
|
* `libs/enigo/` input control
|
||||||
|
* `libs/clipboard/` clipboard
|
||||||
|
* `libs/hbb_common/src/config.rs` all options
|
||||||
|
|
||||||
|
### Key Components
|
||||||
|
- **Remote Desktop Protocol**: Custom protocol implemented in `src/rendezvous_mediator.rs` for communicating with rustdesk-server
|
||||||
|
- **Screen Capture**: Platform-specific screen capture in `libs/scrap/`
|
||||||
|
- **Input Handling**: Cross-platform input simulation in `libs/enigo/`
|
||||||
|
- **Audio/Video Services**: Real-time audio/video streaming in `src/server/`
|
||||||
|
- **File Transfer**: Secure file transfer implementation in `libs/hbb_common/`
|
||||||
|
|
||||||
|
### UI Architecture
|
||||||
|
- **Legacy UI**: Sciter-based (deprecated) - files in `src/ui/`
|
||||||
|
- **Modern UI**: Flutter-based - files in `flutter/`
|
||||||
|
- Desktop: `flutter/lib/desktop/`
|
||||||
|
- Mobile: `flutter/lib/mobile/`
|
||||||
|
- Shared: `flutter/lib/common/` and `flutter/lib/models/`
|
||||||
|
|
||||||
|
## Rust Rules
|
||||||
|
|
||||||
|
* Avoid `unwrap()` / `expect()` in production code.
|
||||||
|
* Exceptions:
|
||||||
|
|
||||||
|
* tests;
|
||||||
|
* lock acquisition where failure means poisoning, not normal control flow.
|
||||||
|
* Otherwise prefer `Result` + `?` or explicit handling.
|
||||||
|
* Do not ignore errors silently.
|
||||||
|
* Avoid unnecessary `.clone()`.
|
||||||
|
* Prefer borrowing when practical.
|
||||||
|
* Do not add dependencies unless needed.
|
||||||
|
* Keep code simple and idiomatic.
|
||||||
|
|
||||||
|
## Tokio Rules
|
||||||
|
|
||||||
|
* Assume a Tokio runtime already exists.
|
||||||
|
* Never create nested runtimes.
|
||||||
|
* Never call `Runtime::block_on()` inside Tokio / async code.
|
||||||
|
* Do not hide runtime creation inside helpers or libraries.
|
||||||
|
* Do not hold locks across `.await`.
|
||||||
|
* Prefer `.await`, `tokio::spawn`, channels.
|
||||||
|
* Use `spawn_blocking` or dedicated threads for blocking work.
|
||||||
|
* Do not use `std::thread::sleep()` in async code.
|
||||||
|
|
||||||
|
## Editing Hygiene
|
||||||
|
|
||||||
|
* Change only what is required.
|
||||||
|
* Prefer the smallest valid diff.
|
||||||
|
* Do not refactor unrelated code.
|
||||||
|
* Do not make formatting-only changes.
|
||||||
|
* Keep naming/style consistent with nearby code.
|
||||||
|
|
||||||
|
### Comments
|
||||||
|
|
||||||
|
* Keep them short: one line by default, three at most.
|
||||||
|
* Say **why**, never what. If the code already says it, delete the comment.
|
||||||
|
* A comment must never be longer than the code it describes.
|
||||||
|
* Applies to YAML, shell and Python too, not just Rust.
|
||||||
|
|
||||||
|
### Be minimally invasive
|
||||||
|
|
||||||
|
* Prefer purely additive changes: layer new (`#[cfg]`-gated) blocks or new functions around existing code instead of restructuring it. The ideal diff for a fix adds lines and modifies/deletes none.
|
||||||
|
* Do not extract or reshape existing code just to enable your new code; look for a mechanism that leaves existing lines untouched (e.g. hide/show an existing object instead of refactoring its construction into a helper for rebuilding).
|
||||||
|
* Put new logic in self-contained functions in the module it belongs to (platform-specific logic in `src/platform/`, with `use` inside the function body to avoid churning shared import blocks). Call sites in shared files (`src/tray.rs`, `src/core_main.rs`, `src/server/connection.rs`, …) should be thin one-line hooks.
|
||||||
|
|
||||||
|
## Localization (`src/lang/*.rs`)
|
||||||
|
|
||||||
|
Each file is a `HashMap<key, translation>`. Layout:
|
||||||
|
|
||||||
|
* `template.rs` is the master list of every key. **Never edit it** as part of translation work.
|
||||||
|
* `en.rs` holds only the keys whose English display text differs from the key itself.
|
||||||
|
* Every other file (`de.rs`, `fr.rs`, …) carries the full key set; an untranslated entry has an empty value: `("key", "")`.
|
||||||
|
|
||||||
|
### Finding the English source for a key
|
||||||
|
|
||||||
|
When filling an empty entry, determine the source English text with this rule:
|
||||||
|
|
||||||
|
* If `key` exists in `en.rs` **with a non-empty value**, that value is the source text (look it up in `en.rs`).
|
||||||
|
* Otherwise the **key string itself is the source text** (the key is already plain English).
|
||||||
|
|
||||||
|
Then translate that source into the file's target language (infer the language from the file's existing non-empty entries / filename).
|
||||||
|
|
||||||
|
### Translation hygiene
|
||||||
|
|
||||||
|
* Only fill empty values. Never change keys, and never touch existing non-empty translations.
|
||||||
|
* Preserve placeholders (`{}`) and escape sequences (`\n`, `\"`) exactly as in the source.
|
||||||
|
* Do not translate brand or technical tokens: `RustDesk`, `Socks5`, `TLS`, `UAC`, `Wayland`, `X11`, `TCP`, `UDP`, `2FA`, `RDP`, `D3D`, etc.
|
||||||
|
* Copy URL values (e.g. `doc_*` keys) verbatim from `en.rs`.
|
||||||
|
|
||||||
|
### Adding new keys (feature work)
|
||||||
|
|
||||||
|
* New English-text keys use sentence case, not Title Case: `Use ID whitelisting`, **not** `Use ID Whitelisting`. Acronyms (ID, IP, 2FA…) stay uppercase. Legacy Title-Case keys (e.g. `Use IP Whitelisting`) stay as-is — do not rename them.
|
||||||
|
* Since the key itself is the English display text, a sentence-case key usually needs **no** `en.rs` entry; add one only when the display text must differ from the key (e.g. `*_tip` keys).
|
||||||
|
* Append each new key to `template.rs` (with `""`) and to every `src/lang/*.rs` file (translated, or `""` if unsure), at the end of the list.
|
||||||
92
CLAUDE.md
92
CLAUDE.md
@@ -1,91 +1 @@
|
|||||||
# CLAUDE.md
|
AGENTS.md
|
||||||
|
|
||||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
||||||
|
|
||||||
## Development Commands
|
|
||||||
|
|
||||||
### Build Commands
|
|
||||||
- `cargo run` - Build and run the desktop application (requires libsciter library)
|
|
||||||
- `python3 build.py --flutter` - Build Flutter version (desktop)
|
|
||||||
- `python3 build.py --flutter --release` - Build Flutter version in release mode
|
|
||||||
- `python3 build.py --hwcodec` - Build with hardware codec support
|
|
||||||
- `python3 build.py --vram` - Build with VRAM feature (Windows only)
|
|
||||||
- `cargo build --release` - Build Rust binary in release mode
|
|
||||||
- `cargo build --features hwcodec` - Build with specific features
|
|
||||||
|
|
||||||
### Flutter Mobile Commands
|
|
||||||
- `cd flutter && flutter build android` - Build Android APK
|
|
||||||
- `cd flutter && flutter build ios` - Build iOS app
|
|
||||||
- `cd flutter && flutter run` - Run Flutter app in development mode
|
|
||||||
- `cd flutter && flutter test` - Run Flutter tests
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
- `cargo test` - Run Rust tests
|
|
||||||
- `cd flutter && flutter test` - Run Flutter tests
|
|
||||||
|
|
||||||
### Platform-Specific Build Scripts
|
|
||||||
- `flutter/build_android.sh` - Android build script
|
|
||||||
- `flutter/build_ios.sh` - iOS build script
|
|
||||||
- `flutter/build_fdroid.sh` - F-Droid build script
|
|
||||||
|
|
||||||
## Project Architecture
|
|
||||||
|
|
||||||
### Directory Structure
|
|
||||||
- **`src/`** - Main Rust application code
|
|
||||||
- `src/ui/` - Legacy Sciter UI (deprecated, use Flutter instead)
|
|
||||||
- `src/server/` - Audio/clipboard/input/video services and network connections
|
|
||||||
- `src/client.rs` - Peer connection handling
|
|
||||||
- `src/platform/` - Platform-specific code
|
|
||||||
- **`flutter/`** - Flutter UI code for desktop and mobile
|
|
||||||
- **`libs/`** - Core libraries
|
|
||||||
- `libs/hbb_common/` - Video codec, config, network wrapper, protobuf, file transfer utilities
|
|
||||||
- `libs/scrap/` - Screen capture functionality
|
|
||||||
- `libs/enigo/` - Platform-specific keyboard/mouse control
|
|
||||||
- `libs/clipboard/` - Cross-platform clipboard implementation
|
|
||||||
|
|
||||||
### Key Components
|
|
||||||
- **Remote Desktop Protocol**: Custom protocol implemented in `src/rendezvous_mediator.rs` for communicating with rustdesk-server
|
|
||||||
- **Screen Capture**: Platform-specific screen capture in `libs/scrap/`
|
|
||||||
- **Input Handling**: Cross-platform input simulation in `libs/enigo/`
|
|
||||||
- **Audio/Video Services**: Real-time audio/video streaming in `src/server/`
|
|
||||||
- **File Transfer**: Secure file transfer implementation in `libs/hbb_common/`
|
|
||||||
|
|
||||||
### UI Architecture
|
|
||||||
- **Legacy UI**: Sciter-based (deprecated) - files in `src/ui/`
|
|
||||||
- **Modern UI**: Flutter-based - files in `flutter/`
|
|
||||||
- Desktop: `flutter/lib/desktop/`
|
|
||||||
- Mobile: `flutter/lib/mobile/`
|
|
||||||
- Shared: `flutter/lib/common/` and `flutter/lib/models/`
|
|
||||||
|
|
||||||
## Important Build Notes
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Requires vcpkg for C++ dependencies: `libvpx`, `libyuv`, `opus`, `aom`
|
|
||||||
- Set `VCPKG_ROOT` environment variable
|
|
||||||
- Download appropriate Sciter library for legacy UI support
|
|
||||||
|
|
||||||
### Ignore Patterns
|
|
||||||
When working with files, ignore these directories:
|
|
||||||
- `target/` - Rust build artifacts
|
|
||||||
- `flutter/build/` - Flutter build output
|
|
||||||
- `flutter/.dart_tool/` - Flutter tooling files
|
|
||||||
|
|
||||||
### Cross-Platform Considerations
|
|
||||||
- Windows builds require additional DLLs and virtual display drivers
|
|
||||||
- macOS builds need proper signing and notarization for distribution
|
|
||||||
- Linux builds support multiple package formats (deb, rpm, AppImage)
|
|
||||||
- Mobile builds require platform-specific toolchains (Android SDK, Xcode)
|
|
||||||
|
|
||||||
### Feature Flags
|
|
||||||
- `hwcodec` - Hardware video encoding/decoding
|
|
||||||
- `vram` - VRAM optimization (Windows only)
|
|
||||||
- `flutter` - Enable Flutter UI
|
|
||||||
- `unix-file-copy-paste` - Unix file clipboard support
|
|
||||||
- `screencapturekit` - macOS ScreenCaptureKit (macOS only)
|
|
||||||
|
|
||||||
### Config
|
|
||||||
All configurations or options are under `libs/hbb_common/src/config.rs` file, 4 types:
|
|
||||||
- Settings
|
|
||||||
- Local
|
|
||||||
- Display
|
|
||||||
- Built-in
|
|
||||||
|
|||||||
490
Cargo.lock
generated
490
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
33
Cargo.toml
33
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustdesk"
|
name = "rustdesk"
|
||||||
version = "1.4.5"
|
version = "1.4.9"
|
||||||
authors = ["rustdesk <info@rustdesk.com>"]
|
authors = ["rustdesk <info@rustdesk.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build= "build.rs"
|
build= "build.rs"
|
||||||
@@ -22,7 +22,6 @@ path = "src/service.rs"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
inline = []
|
inline = []
|
||||||
cli = []
|
|
||||||
use_samplerate = ["samplerate"]
|
use_samplerate = ["samplerate"]
|
||||||
use_rubato = ["rubato"]
|
use_rubato = ["rubato"]
|
||||||
use_dasp = ["dasp"]
|
use_dasp = ["dasp"]
|
||||||
@@ -31,6 +30,13 @@ default = ["use_dasp"]
|
|||||||
hwcodec = ["scrap/hwcodec"]
|
hwcodec = ["scrap/hwcodec"]
|
||||||
vram = ["scrap/vram"]
|
vram = ["scrap/vram"]
|
||||||
mediacodec = ["scrap/mediacodec"]
|
mediacodec = ["scrap/mediacodec"]
|
||||||
|
drm = ["scrap/drm"]
|
||||||
|
# The display wake, as its OWN compile gate on top of `drm`. Everything else in the drm backend
|
||||||
|
# READS (it captures a scanout); the wake WRITES, injecting one synthetic pointer event from the
|
||||||
|
# root service so a compositor that idle-disabled its outputs re-enables them. That is a different
|
||||||
|
# kind of operation and deserves a switch that can remove it from the binary entirely, without
|
||||||
|
# giving up DRM capture: `--features drm` builds the capture path with no wake code compiled in.
|
||||||
|
drm-wake = ["drm"]
|
||||||
plugin_framework = []
|
plugin_framework = []
|
||||||
linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"]
|
linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"]
|
||||||
unix-file-copy-paste = [
|
unix-file-copy-paste = [
|
||||||
@@ -62,8 +68,6 @@ dasp = { version = "0.11", features = ["signal", "interpolate-linear", "interpol
|
|||||||
rubato = { version = "0.12", optional = true }
|
rubato = { version = "0.12", optional = true }
|
||||||
samplerate = { version = "0.2", optional = true }
|
samplerate = { version = "0.2", optional = true }
|
||||||
uuid = { version = "1.3", features = ["v4"] }
|
uuid = { version = "1.3", features = ["v4"] }
|
||||||
clap = "4.2"
|
|
||||||
rpassword = "7.2"
|
|
||||||
num_cpus = "1.15"
|
num_cpus = "1.15"
|
||||||
bytes = { version = "1.4", features = ["serde"] }
|
bytes = { version = "1.4", features = ["serde"] }
|
||||||
default-net = "0.14"
|
default-net = "0.14"
|
||||||
@@ -76,14 +80,13 @@ crossbeam-queue = "0.3"
|
|||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
cidr-utils = "0.5"
|
cidr-utils = "0.5"
|
||||||
libloading = "0.8"
|
|
||||||
fon = "0.6"
|
fon = "0.6"
|
||||||
zip = "0.6"
|
zip = "0.6"
|
||||||
shutdown_hooks = "0.1"
|
shutdown_hooks = "0.1"
|
||||||
totp-rs = { version = "5.4", default-features = false, features = ["gen_secret", "otpauth"] }
|
totp-rs = { version = "5.4", default-features = false, features = ["gen_secret", "otpauth"] }
|
||||||
stunclient = "0.4"
|
stunclient = "0.4"
|
||||||
kcp-sys= { git = "https://github.com/rustdesk-org/kcp-sys"}
|
kcp-sys= { git = "https://github.com/rustdesk-org/kcp-sys"}
|
||||||
reqwest = { version = "0.12", features = ["blocking", "socks", "json", "native-tls", "rustls-tls", "rustls-tls-native-roots", "gzip"], default-features=false }
|
reqwest = { version = "0.12", features = ["blocking", "socks", "json", "native-tls", "rustls-tls", "rustls-tls-native-roots", "gzip", "zstd"], default-features=false }
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "linux"))'.dependencies]
|
[target.'cfg(not(target_os = "linux"))'.dependencies]
|
||||||
# https://github.com/rustdesk/rustdesk/discussions/10197, not use cpal on linux
|
# https://github.com/rustdesk/rustdesk/discussions/10197, not use cpal on linux
|
||||||
@@ -128,14 +131,18 @@ windows = { version = "0.61", features = [
|
|||||||
"Win32_Security_Authorization",
|
"Win32_Security_Authorization",
|
||||||
"Win32_Storage_FileSystem",
|
"Win32_Storage_FileSystem",
|
||||||
"Win32_System",
|
"Win32_System",
|
||||||
|
"Win32_System_Com",
|
||||||
"Win32_System_Diagnostics",
|
"Win32_System_Diagnostics",
|
||||||
"Win32_System_Diagnostics_ToolHelp",
|
"Win32_System_Diagnostics_ToolHelp",
|
||||||
"Win32_System_Environment",
|
"Win32_System_Environment",
|
||||||
"Win32_System_IO",
|
"Win32_System_IO",
|
||||||
"Win32_System_Memory",
|
"Win32_System_Memory",
|
||||||
"Win32_System_Pipes",
|
"Win32_System_Pipes",
|
||||||
|
"Win32_System_Registry",
|
||||||
|
"Win32_System_SystemInformation",
|
||||||
"Win32_System_Threading",
|
"Win32_System_Threading",
|
||||||
"Win32_UI_Shell",
|
"Win32_UI_Shell",
|
||||||
|
"Win32_UI_WindowsAndMessaging",
|
||||||
] }
|
] }
|
||||||
winreg = "0.11"
|
winreg = "0.11"
|
||||||
windows-service = "0.6"
|
windows-service = "0.6"
|
||||||
@@ -144,7 +151,6 @@ remote_printer = { path = "libs/remote_printer" }
|
|||||||
impersonate_system = { git = "https://github.com/rustdesk-org/impersonate-system" }
|
impersonate_system = { git = "https://github.com/rustdesk-org/impersonate-system" }
|
||||||
shared_memory = "0.12"
|
shared_memory = "0.12"
|
||||||
tauri-winrt-notification = "0.1"
|
tauri-winrt-notification = "0.1"
|
||||||
runas = "1.2"
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
objc = "0.2"
|
objc = "0.2"
|
||||||
@@ -161,7 +167,7 @@ piet-coregraphics = "0.6"
|
|||||||
foreign-types = "0.3"
|
foreign-types = "0.3"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
||||||
tray-icon = { git = "https://github.com/tauri-apps/tray-icon" }
|
tray-icon = { git = "https://github.com/tauri-apps/tray-icon", version = "0.21.3" }
|
||||||
tao = { git = "https://github.com/rustdesk-org/tao", branch = "dev" }
|
tao = { git = "https://github.com/rustdesk-org/tao", branch = "dev" }
|
||||||
image = "0.24"
|
image = "0.24"
|
||||||
|
|
||||||
@@ -177,6 +183,7 @@ bytemuck = "1.23"
|
|||||||
ttf-parser = "0.25"
|
ttf-parser = "0.25"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
libxdo-sys = "0.11"
|
||||||
psimple = { package = "libpulse-simple-binding", version = "2.27" }
|
psimple = { package = "libpulse-simple-binding", version = "2.27" }
|
||||||
pulse = { package = "libpulse-binding", version = "2.27" }
|
pulse = { package = "libpulse-binding", version = "2.27" }
|
||||||
rust-pulsectl = { git = "https://github.com/rustdesk-org/pulsectl" }
|
rust-pulsectl = { git = "https://github.com/rustdesk-org/pulsectl" }
|
||||||
@@ -207,8 +214,13 @@ android-wakelock = { git = "https://github.com/rustdesk-org/android-wakelock" }
|
|||||||
members = ["libs/scrap", "libs/hbb_common", "libs/enigo", "libs/clipboard", "libs/virtual_display", "libs/virtual_display/dylib", "libs/portable", "libs/remote_printer"]
|
members = ["libs/scrap", "libs/hbb_common", "libs/enigo", "libs/clipboard", "libs/virtual_display", "libs/virtual_display/dylib", "libs/portable", "libs/remote_printer"]
|
||||||
exclude = ["vdi/host", "examples/custom_plugin"]
|
exclude = ["vdi/host", "examples/custom_plugin"]
|
||||||
|
|
||||||
|
# Patch libxdo-sys to use a stub implementation that doesn't require libxdo
|
||||||
|
# This allows building and running on systems without libxdo installed (e.g., Wayland-only)
|
||||||
|
[patch.crates-io]
|
||||||
|
libxdo-sys = { path = "libs/libxdo-sys-stub" }
|
||||||
|
|
||||||
[package.metadata.winres]
|
[package.metadata.winres]
|
||||||
LegalCopyright = "Copyright © 2025 Purslane Ltd. All rights reserved."
|
LegalCopyright = "Copyright © 2026 Purslane Tech Pte. Ltd. All rights reserved."
|
||||||
ProductName = "RustDesk"
|
ProductName = "RustDesk"
|
||||||
FileDescription = "RustDesk Remote Desktop"
|
FileDescription = "RustDesk Remote Desktop"
|
||||||
OriginalFilename = "rustdesk.exe"
|
OriginalFilename = "rustdesk.exe"
|
||||||
@@ -240,3 +252,6 @@ panic = 'abort'
|
|||||||
strip = true
|
strip = true
|
||||||
#opt-level = 'z' # only have smaller size after strip
|
#opt-level = 'z' # only have smaller size after strip
|
||||||
rpath = true
|
rpath = true
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
debug = 1
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ RustDesk welcomes contribution from everyone. See [CONTRIBUTING.md](docs/CONTRIB
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
Desktop versions use Flutter or Sciter (deprecated) for GUI, this tutorial is for Sciter only, since it is easier and more friendly to start. Check out our [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) for building Flutter version.
|
Desktop versions use Flutter or Sciter (deprecated) for GUI. This tutorial is for Sciter only, since it is easier and more friendly to start. Check out our [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) for building the Flutter version.
|
||||||
|
|
||||||
Please download Sciter dynamic library yourself.
|
Please download Sciter dynamic library yourself.
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ AppDir:
|
|||||||
id: rustdesk
|
id: rustdesk
|
||||||
name: rustdesk
|
name: rustdesk
|
||||||
icon: rustdesk
|
icon: rustdesk
|
||||||
version: 1.4.5
|
version: 1.4.9
|
||||||
exec: usr/share/rustdesk/rustdesk
|
exec: usr/share/rustdesk/rustdesk
|
||||||
exec_args: $@
|
exec_args: $@
|
||||||
apt:
|
apt:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ AppDir:
|
|||||||
id: rustdesk
|
id: rustdesk
|
||||||
name: rustdesk
|
name: rustdesk
|
||||||
icon: rustdesk
|
icon: rustdesk
|
||||||
version: 1.4.5
|
version: 1.4.9
|
||||||
exec: usr/share/rustdesk/rustdesk
|
exec: usr/share/rustdesk/rustdesk
|
||||||
exec_args: $@
|
exec_args: $@
|
||||||
apt:
|
apt:
|
||||||
|
|||||||
551
build.py
551
build.py
@@ -1,23 +1,33 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import glob
|
||||||
|
import contextlib
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import zipfile
|
import zipfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import shutil
|
import shutil
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Captured at import, while cwd is still the repo root: before Python 3.9 the main script's __file__
|
||||||
|
# stays relative (bpo-20443), so abspath() re-resolves it against the cwd -- and the ubuntu18.04
|
||||||
|
# packaging container runs 3.6 and chdir's into flutter/ before it reaches the libdrmtap code.
|
||||||
|
REPO_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
windows = platform.platform().startswith('Windows')
|
windows = platform.platform().startswith('Windows')
|
||||||
osx = platform.platform().startswith(
|
osx = platform.platform().startswith(
|
||||||
'Darwin') or platform.platform().startswith("macOS")
|
'Darwin') or platform.platform().startswith("macOS")
|
||||||
hbb_name = 'rustdesk' + ('.exe' if windows else '')
|
hbb_name = 'rustdesk' + ('.exe' if windows else '')
|
||||||
exe_path = 'target/release/' + hbb_name
|
exe_path = 'target/release/' + hbb_name
|
||||||
if windows:
|
if windows:
|
||||||
flutter_build_dir = 'build/windows/x64/runner/Release/'
|
win_arch = 'arm64' if platform.machine().lower() in ('arm64', 'aarch64') else 'x64'
|
||||||
|
flutter_build_dir = f'build/windows/{win_arch}/runner/Release/'
|
||||||
elif osx:
|
elif osx:
|
||||||
flutter_build_dir = 'build/macos/Build/Products/Release/'
|
flutter_build_dir = 'build/macos/Build/Products/Release/'
|
||||||
else:
|
else:
|
||||||
@@ -129,6 +139,19 @@ def make_parser():
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='Build with unix file copy paste feature'
|
help='Build with unix file copy paste feature'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--drm',
|
||||||
|
action='store_true',
|
||||||
|
help='Linux only: build the DRM/KMS capture backend (bundles libdrmtap.so, '
|
||||||
|
'dlopen-ed in-process by the root service). Off by default.'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--print-features',
|
||||||
|
action='store_true',
|
||||||
|
help='Print the cargo feature list these flags select, and exit without building. For a '
|
||||||
|
'caller that runs its own cargo line and then packages with --skip-cargo: it can ask '
|
||||||
|
'for the list rather than repeat it, so the two cannot drift.'
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--skip-cargo',
|
'--skip-cargo',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@@ -172,7 +195,7 @@ def generate_build_script_for_docker():
|
|||||||
# flutter_rust_bridge
|
# flutter_rust_bridge
|
||||||
dart pub global activate ffigen --version 5.0.1
|
dart pub global activate ffigen --version 5.0.1
|
||||||
pushd /tmp && git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1 && popd
|
pushd /tmp && git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1 && popd
|
||||||
pushd /tmp/flutter_rust_bridge/frb_codegen && cargo install --path . && popd
|
pushd /tmp/flutter_rust_bridge/frb_codegen && cargo install --path . --locked && popd
|
||||||
pushd flutter && flutter pub get && popd
|
pushd flutter && flutter pub get && popd
|
||||||
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
|
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
|
||||||
# install vcpkg
|
# install vcpkg
|
||||||
@@ -271,6 +294,24 @@ def external_resources(flutter, args, res_dir):
|
|||||||
shutil.copytree(f, f'{flutter_build_dir_2}{f.stem}')
|
shutil.copytree(f, f'{flutter_build_dir_2}{f.stem}')
|
||||||
|
|
||||||
|
|
||||||
|
def linux_packaging_branch():
|
||||||
|
"""Which packaging path `main()` will take on THIS host.
|
||||||
|
|
||||||
|
MUST mirror the elif chain in main() (pacman / yum / zypper / else), and exists so `--drm` can
|
||||||
|
refuse a branch that is not drm-aware instead of silently producing a stock-named package with
|
||||||
|
the capture backend compiled in. Only the final `deb` branch reaches `build_flutter_deb`, which
|
||||||
|
is what bundles libdrmtap, renames the package, adds Conflicts/Provides and asserts the staged
|
||||||
|
binary really is a drm build.
|
||||||
|
"""
|
||||||
|
if os.path.isfile('/usr/bin/pacman'):
|
||||||
|
return 'pacman'
|
||||||
|
if os.path.isfile('/usr/bin/yum'):
|
||||||
|
return 'yum'
|
||||||
|
if os.path.isfile('/usr/bin/zypper'):
|
||||||
|
return 'zypper'
|
||||||
|
return 'deb'
|
||||||
|
|
||||||
|
|
||||||
def get_features(args):
|
def get_features(args):
|
||||||
features = ['inline'] if not args.flutter else []
|
features = ['inline'] if not args.flutter else []
|
||||||
if args.hwcodec:
|
if args.hwcodec:
|
||||||
@@ -281,6 +322,30 @@ def get_features(args):
|
|||||||
features.append('flutter')
|
features.append('flutter')
|
||||||
if args.unix_file_copy_paste:
|
if args.unix_file_copy_paste:
|
||||||
features.append('unix-file-copy-paste')
|
features.append('unix-file-copy-paste')
|
||||||
|
if args.drm:
|
||||||
|
# Say so rather than quietly handing back a stock build: the backend is Linux-only, so on
|
||||||
|
# any other host the flag cannot be honoured and the resulting binary would look like a
|
||||||
|
# DRM build without being one.
|
||||||
|
if windows or osx:
|
||||||
|
raise Exception('--drm is Linux only')
|
||||||
|
# And only on the deb branch. The other three Linux paths (pacman/yum/zypper) package
|
||||||
|
# straight from `target/release` without bundling libdrmtap, without the rename, without
|
||||||
|
# Conflicts/Provides and without assert_staged_binary_is_drm() -- so they would emit a
|
||||||
|
# package NAMED `rustdesk` carrying the consent-bypass backend and the root-side uinput
|
||||||
|
# injection. The separate package name is the informed consent this feature rests on, so
|
||||||
|
# refuse rather than ship a stock-named build of it.
|
||||||
|
branch = linux_packaging_branch()
|
||||||
|
if branch != 'deb':
|
||||||
|
raise Exception(
|
||||||
|
f'--drm is only supported on the deb packaging path; this host would package via '
|
||||||
|
f'{branch}, which cannot bundle libdrmtap or name the package distinctly')
|
||||||
|
features.append('drm')
|
||||||
|
# The display wake is its own compile gate on top of `drm`, and the unattended package is
|
||||||
|
# exactly where it belongs: that variant exists to reach a machine nobody is sitting at,
|
||||||
|
# and a machine whose screen went dark is the case it is for. Dropping `drm-wake` from
|
||||||
|
# this line builds the same capture backend with no wake code in the binary at all.
|
||||||
|
# It is ALSO switchable at runtime; see OPTION_ENABLE_DRM_DISPLAY_WAKE.
|
||||||
|
features.append('drm-wake')
|
||||||
if osx:
|
if osx:
|
||||||
if args.screencapturekit:
|
if args.screencapturekit:
|
||||||
features.append('screencapturekit')
|
features.append('screencapturekit')
|
||||||
@@ -299,7 +364,7 @@ Version: %s
|
|||||||
Architecture: %s
|
Architecture: %s
|
||||||
Maintainer: rustdesk <info@rustdesk.com>
|
Maintainer: rustdesk <info@rustdesk.com>
|
||||||
Homepage: https://rustdesk.com
|
Homepage: https://rustdesk.com
|
||||||
Depends: libgtk-3-0, libxcb-randr0, libxdo3, libxfixes3, libxcb-shape0, libxcb-xfixes0, libasound2, libsystemd0, curl, libva2, libva-drm2, libva-x11-2, libgstreamer-plugins-base1.0-0, libpam0g, gstreamer1.0-pipewire%s
|
Depends: libgtk-3-0t64 | libgtk-3-0, libxcb-randr0, libxdo3 | libxdo4, libxfixes3, libxcb-shape0, libxcb-xfixes0, libasound2t64 | libasound2, libsystemd0, curl, libva2, libva-drm2, libva-x11-2, libgstreamer-plugins-base1.0-0, libpam0g, gstreamer1.0-pipewire%s
|
||||||
Recommends: libayatana-appindicator3-1
|
Recommends: libayatana-appindicator3-1
|
||||||
Description: A remote control software.
|
Description: A remote control software.
|
||||||
|
|
||||||
@@ -315,9 +380,325 @@ def ffi_bindgen_function_refactor():
|
|||||||
'sed -i "s/ffi.NativeFunction<ffi.Bool Function(DartPort/ffi.NativeFunction<ffi.Uint8 Function(DartPort/g" flutter/lib/generated_bridge.dart')
|
'sed -i "s/ffi.NativeFunction<ffi.Bool Function(DartPort/ffi.NativeFunction<ffi.Uint8 Function(DartPort/g" flutter/lib/generated_bridge.dart')
|
||||||
|
|
||||||
|
|
||||||
|
# libdrmtap is fetched at build time from the rustdesk-org fork at a pinned
|
||||||
|
# commit — the same way rustdesk sources its other native build deps (vcpkg,
|
||||||
|
# flutter_rust_bridge, ...), rather than carrying a git submodule. It is the ONLY
|
||||||
|
# pin for the drm backend: rustdesk dlopens this .so at runtime and does not depend on
|
||||||
|
# the libdrmtap-sys crate (whose build.rs would statically link the C tree, a helper and
|
||||||
|
# libdrm/seccomp/cap). DRMTAP_REPO, DRMTAP_SHA and DRMTAP_PREBUILT_DIR override it for local testing
|
||||||
|
# or another fork, and each requires DRMTAP_ALLOW_UNPINNED=1 alongside it (see below).
|
||||||
|
# The commit is fetched directly by sha, so no branch or tag name takes part in the build: see
|
||||||
|
# build_libdrmtap_so(). This is the SINGLE source of truth for the pin, deliberately not duplicated in
|
||||||
|
# any workflow, so a bump is one edit here (plus the informational version comment in
|
||||||
|
# libs/scrap/Cargo.toml). This commit is libdrmtap v0.5.2.
|
||||||
|
LIBDRMTAP_REPO_PINNED = 'https://github.com/rustdesk-org/libdrmtap'
|
||||||
|
LIBDRMTAP_SHA_PINNED = '653de8c774bc245eaf960611ca7a136f7a544d21'
|
||||||
|
LIBDRMTAP_REPO = os.environ.get('DRMTAP_REPO', LIBDRMTAP_REPO_PINNED)
|
||||||
|
LIBDRMTAP_SHA = os.environ.get('DRMTAP_SHA', LIBDRMTAP_SHA_PINNED)
|
||||||
|
# Every way of getting a different .so than the pin needs the same explicit opt-in. Otherwise the
|
||||||
|
# claim this feature rests on -- that the privileged capture library is the reviewed object at
|
||||||
|
# LIBDRMTAP_SHA_PINNED -- would hold only as long as nobody happened to have one of these set, and a
|
||||||
|
# build that silently used something else would be indistinguishable from one that did not.
|
||||||
|
# DRMTAP_PREBUILT_DIR is in the list because it is the widest of the three: it skips both the fetch
|
||||||
|
# and the sha verification and hands over an object built from nothing this script can see.
|
||||||
|
DRMTAP_UNPINNED_OK = os.environ.get('DRMTAP_ALLOW_UNPINNED') == '1'
|
||||||
|
|
||||||
|
|
||||||
|
def _prebuilt_dir_is_the_pinned_checkout(prebuilt_dir):
|
||||||
|
# A .so built from this repo's own third_party/libdrmtap at the pinned sha is the pinned object,
|
||||||
|
# not an override, so it must not need the opt-in. This is how CI hands the library from a step
|
||||||
|
# that has meson to a packaging container that does not.
|
||||||
|
src = os.path.join(REPO_ROOT, 'third_party', 'libdrmtap')
|
||||||
|
try:
|
||||||
|
inside = os.path.commonpath([os.path.abspath(prebuilt_dir), src]) == src
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
if not inside or not os.path.isdir(os.path.join(src, '.git')):
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
head = subprocess.check_output(['git', '-C', src, 'rev-parse', 'HEAD']).decode().strip()
|
||||||
|
except (subprocess.SubprocessError, OSError):
|
||||||
|
return False
|
||||||
|
return head == LIBDRMTAP_SHA
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_libdrmtap_pin():
|
||||||
|
# Called from build_libdrmtap_so(), NOT at import: a stock (non --drm) build must stay
|
||||||
|
# byte-identical to upstream in behaviour too, and leftover DRMTAP_* variables in the
|
||||||
|
# environment (or a malformed sha) must not be able to fail a build that never touches
|
||||||
|
# libdrmtap.
|
||||||
|
# `or None` so an empty value reads as unset here exactly as it does in build_libdrmtap_so(),
|
||||||
|
# which tests it for truthiness.
|
||||||
|
prebuilt = os.environ.get('DRMTAP_PREBUILT_DIR') or None
|
||||||
|
if prebuilt and _prebuilt_dir_is_the_pinned_checkout(prebuilt):
|
||||||
|
prebuilt = None
|
||||||
|
overridden = [
|
||||||
|
name
|
||||||
|
for name, value, pinned in (
|
||||||
|
('DRMTAP_REPO', LIBDRMTAP_REPO, LIBDRMTAP_REPO_PINNED),
|
||||||
|
('DRMTAP_SHA', LIBDRMTAP_SHA, LIBDRMTAP_SHA_PINNED),
|
||||||
|
('DRMTAP_PREBUILT_DIR', prebuilt, None),
|
||||||
|
)
|
||||||
|
if value != pinned
|
||||||
|
]
|
||||||
|
if overridden and not DRMTAP_UNPINNED_OK:
|
||||||
|
raise Exception(
|
||||||
|
f'{", ".join(overridden)} would build libdrmtap from something other than the pinned '
|
||||||
|
f'{LIBDRMTAP_REPO_PINNED} at {LIBDRMTAP_SHA_PINNED}. That is supported for local work and '
|
||||||
|
'cross-builds, but it has to be deliberate: set DRMTAP_ALLOW_UNPINNED=1 as well.')
|
||||||
|
if overridden:
|
||||||
|
print(f'WARNING: libdrmtap is NOT the pinned build ({", ".join(overridden)} set)')
|
||||||
|
# Both are interpolated into shell commands below, and both are env-overridable, so validate
|
||||||
|
# their SHAPE before they get there. This is not only about a hostile environment: a truncated
|
||||||
|
# or abbreviated sha would otherwise reach `git fetch` and fail with something far less obvious
|
||||||
|
# than saying so here, and an abbreviated one would defeat the point of pinning.
|
||||||
|
if not re.fullmatch(r'[0-9a-f]{40}', LIBDRMTAP_SHA):
|
||||||
|
raise Exception(
|
||||||
|
f'DRMTAP_SHA must be a full 40-character commit sha, got {LIBDRMTAP_SHA!r}')
|
||||||
|
if not re.fullmatch(r'(https://|git@)[A-Za-z0-9._~:/@-]+', LIBDRMTAP_REPO):
|
||||||
|
raise Exception(f'DRMTAP_REPO does not look like a git remote url: {LIBDRMTAP_REPO!r}')
|
||||||
|
|
||||||
|
|
||||||
|
def _single_real_so(paths, where):
|
||||||
|
# Return the one real libdrmtap.so.0.* object among `paths`, failing if there are zero or several.
|
||||||
|
# glob order is arbitrary, so silently taking [0] could ship a stale or wrong-arch object left
|
||||||
|
# over from an earlier build; a mismatch should fail the build loudly instead.
|
||||||
|
real = sorted(p for p in paths if os.path.isfile(p) and not os.path.islink(p))
|
||||||
|
if len(real) != 1:
|
||||||
|
raise Exception(
|
||||||
|
f'expected exactly one real libdrmtap.so.0.* in {where}, found {len(real)}: {real}')
|
||||||
|
return real[0]
|
||||||
|
|
||||||
|
|
||||||
|
def build_libdrmtap_so():
|
||||||
|
# Build libdrmtap.so from the rustdesk-org fork, fetched at the pinned LIBDRMTAP_SHA. The
|
||||||
|
# pivot dlopen-s this .so in-process in the root service (which already holds
|
||||||
|
# CAP_SYS_ADMIN) — no setcap helper, no privileged child. Only the shared
|
||||||
|
# library target is built (the source also carries a helper binary we do not
|
||||||
|
# ship). Returns the path to the built versioned .so (e.g. libdrmtap.so.0.4.x).
|
||||||
|
_validate_libdrmtap_pin()
|
||||||
|
# Allow a caller (e.g. CI) to build the .so ahead of time and hand it in via
|
||||||
|
# DRMTAP_PREBUILT_DIR (must contain the real libdrmtap.so.0.* object).
|
||||||
|
prebuilt_dir = os.environ.get('DRMTAP_PREBUILT_DIR')
|
||||||
|
if prebuilt_dir:
|
||||||
|
# DRMTAP_PREBUILT_DIR explicitly names the artifact source, so honor it strictly: fail
|
||||||
|
# (rather than silently falling back to a source build) if it holds no single real .so.
|
||||||
|
prebuilt = glob.glob(os.path.join(prebuilt_dir, 'libdrmtap.so.0.*'))
|
||||||
|
so = _single_real_so(prebuilt, f'DRMTAP_PREBUILT_DIR={prebuilt_dir}')
|
||||||
|
# Check the stub case HERE too, not only on the source path below. This is the widest
|
||||||
|
# override of the three -- no fetch, no sha verification, an object built by something this
|
||||||
|
# script cannot see -- so it is the likeliest to hand over a CPU-only build, and skipping the
|
||||||
|
# assertion on exactly this path would leave the check guarding only the case that was
|
||||||
|
# already trustworthy.
|
||||||
|
_assert_so_has_egl(so)
|
||||||
|
return so
|
||||||
|
# Fetch the pinned source if it is not already present. third_party/libdrmtap is not a submodule
|
||||||
|
# anymore; it is git-ignored. The commit is fetched BY SHA rather than by cloning a branch:
|
||||||
|
# `clone --depth 1 --branch main` only ever fetches the tip, so the moment upstream pushes to
|
||||||
|
# `main` the pinned commit is not in the shallow clone at all and the build fails on an unreachable
|
||||||
|
# object. Fetching the sha needs no branch name, so it keeps working across every upstream push and
|
||||||
|
# is immune to a ref being moved or repointed.
|
||||||
|
src = os.path.join(REPO_ROOT, 'third_party', 'libdrmtap')
|
||||||
|
if not os.path.exists(os.path.join(src, 'meson.build')):
|
||||||
|
if os.path.isdir(src):
|
||||||
|
shutil.rmtree(src)
|
||||||
|
os.makedirs(src, exist_ok=True)
|
||||||
|
system2(f'git -C "{src}" init -q')
|
||||||
|
system2(f'git -C "{src}" remote add origin {LIBDRMTAP_REPO}')
|
||||||
|
system2(f'git -C "{src}" fetch --depth 1 origin {LIBDRMTAP_SHA}')
|
||||||
|
system2(f'git -C "{src}" checkout -q FETCH_HEAD')
|
||||||
|
# Verify the pin whenever the source is a GIT checkout. A fetch by sha cannot resolve to anything
|
||||||
|
# else, so this now guards the OTHER case: a reused checkout left by an earlier build at a
|
||||||
|
# different pin, which is what a bump leaves behind. Reject and remove it so the next run re-fetches
|
||||||
|
# cleanly. A NON-git tree placed here on purpose (a developer building unreleased local libdrmtap
|
||||||
|
# source) has nothing to verify and is used as-is.
|
||||||
|
if os.path.isdir(os.path.join(src, '.git')):
|
||||||
|
got_sha = subprocess.check_output(
|
||||||
|
['git', '-C', src, 'rev-parse', 'HEAD']).decode().strip()
|
||||||
|
if got_sha != LIBDRMTAP_SHA:
|
||||||
|
shutil.rmtree(src, ignore_errors=True)
|
||||||
|
raise Exception(
|
||||||
|
f'libdrmtap at {src} is {got_sha}, expected {LIBDRMTAP_SHA} '
|
||||||
|
f'(stale checkout from a different pin; removed, re-run to re-fetch)')
|
||||||
|
build_dir = os.path.join(src, 'build-pkg')
|
||||||
|
if not os.path.exists(os.path.join(build_dir, 'build.ninja')):
|
||||||
|
system2(f'meson setup "{build_dir}" "{src}" --buildtype=release')
|
||||||
|
# Build only the shared library, not the bundled helper binary or the static archive. Since
|
||||||
|
# libdrmtap 0.4.11 the project is `both_libraries` (a version-scripted .so + a static .a), so the
|
||||||
|
# bare `drmtap` target is ambiguous ("drmtap:shared_library" vs "drmtap:static_library"); ask for
|
||||||
|
# the shared one explicitly (rustdesk dlopens the .so and never needs the archive).
|
||||||
|
system2(f'meson compile -C "{build_dir}" drmtap:shared_library')
|
||||||
|
sos = glob.glob(os.path.join(build_dir, 'libdrmtap.so.0.*'))
|
||||||
|
# keep the real object (libdrmtap.so.0.4.x), not the .so/.so.0 symlinks or meson's .p dir, and
|
||||||
|
# require exactly one so a stale object from an earlier build is never silently picked.
|
||||||
|
so = _single_real_so(sos, f'the libdrmtap meson build dir {build_dir}')
|
||||||
|
_assert_so_has_egl(so)
|
||||||
|
return so
|
||||||
|
|
||||||
|
|
||||||
|
def _assert_so_has_egl(so_path):
|
||||||
|
# libdrmtap treats egl/glesv2 as OPTIONAL dependencies: without their headers and pkg-config
|
||||||
|
# files, meson silently builds a CPU-only stub. That stub still exports every symbol the loader
|
||||||
|
# checks for, so nothing downstream notices -- and the split architecture depends entirely on the
|
||||||
|
# unprivileged side EGL-detiling the scanout it receives. The result is a build where DRM capture
|
||||||
|
# quietly degrades to PipeWire on every tiled-scanout host, which is most of them.
|
||||||
|
#
|
||||||
|
# Assert on the ARTIFACT rather than passing an option that demands it: `-Degl=enabled` exists
|
||||||
|
# only in libdrmtap past 0.4.15, and checking what was actually produced also catches a stale or
|
||||||
|
# hand-substituted object, which a build flag cannot.
|
||||||
|
#
|
||||||
|
# EGL is reached by lazy dlopen, on purpose, so that the privileged service never links the GPU
|
||||||
|
# stack. That means there is no DT_NEEDED to look for and an ELF-level check reports "no EGL" on a
|
||||||
|
# perfectly good library; the dlopen name and an extension symbol are what a CPU-only stub really
|
||||||
|
# lacks.
|
||||||
|
try:
|
||||||
|
with open(so_path, 'rb') as f:
|
||||||
|
blob = f.read()
|
||||||
|
except OSError as err:
|
||||||
|
raise Exception(f'cannot read the built libdrmtap at {so_path}: {err}') from err
|
||||||
|
missing = [m for m in (b'libEGL.so.1', b'eglCreateImageKHR') if m not in blob]
|
||||||
|
if missing:
|
||||||
|
raise Exception(
|
||||||
|
f'{so_path} looks like a CPU-only libdrmtap stub (missing '
|
||||||
|
f'{", ".join(m.decode() for m in missing)}): the EGL detile path the split capture '
|
||||||
|
'depends on is not in it, and DRM capture would silently fall back to PipeWire. '
|
||||||
|
'Install the EGL development packages and rebuild (Debian/Ubuntu: libegl-dev '
|
||||||
|
'libgles2-mesa-dev; Arch: mesa libglvnd).')
|
||||||
|
|
||||||
|
|
||||||
|
DRM_PACKAGE_NAME = 'rustdesk-unattended-wayland'
|
||||||
|
|
||||||
|
|
||||||
|
def assert_so_satisfies_the_runtime_abi_gate(so_path):
|
||||||
|
"""The .so we are about to ship must be one the RUNTIME will actually accept.
|
||||||
|
|
||||||
|
`abi_accepted` in libs/scrap/src/common/drmtap_dl.rs is the only place the pinned library's
|
||||||
|
version is ever validated, and it runs at dlopen time on the USER's machine. Nothing in the
|
||||||
|
build or in CI compared the two, so the pin and the gate could drift apart and every existing
|
||||||
|
assertion would still pass: the EGL check does not look at the version, the CI symbol contract
|
||||||
|
does not call drmtap_version(), and the deb-contents regex matches any `libdrmtap.so.0.X.Y`.
|
||||||
|
A green pipeline could therefore produce a deb in which DRM capture can never start, and the
|
||||||
|
only symptom on the host is one log line before it falls back to the portal.
|
||||||
|
|
||||||
|
So parse the gate out of the Rust and apply it here, to the object being staged. This is the
|
||||||
|
same rule, not a copy of the numbers: if someone bumps the constants, this reads the new ones.
|
||||||
|
"""
|
||||||
|
m = re.search(r'libdrmtap\.so\.(\d+)\.(\d+)\.(\d+)', os.path.basename(so_path))
|
||||||
|
if not m:
|
||||||
|
# Not a versioned soname (a local dev build, say). The gate cannot be evaluated, and
|
||||||
|
# inventing a verdict would be worse than saying so.
|
||||||
|
print(f'[drm] cannot read a version out of {so_path}; skipping the ABI-gate cross-check')
|
||||||
|
return
|
||||||
|
so_ver = tuple(int(g) for g in m.groups())
|
||||||
|
# REPO_ROOT, not abspath(__file__): both callers have chdir'd into flutter/ by now.
|
||||||
|
gate_path = os.path.join(REPO_ROOT, 'libs', 'scrap', 'src', 'common', 'drmtap_dl.rs')
|
||||||
|
with open(gate_path) as f:
|
||||||
|
gate_src = f.read()
|
||||||
|
|
||||||
|
def _const(name):
|
||||||
|
mm = re.search(rf'const {name}: c_int = (\d+);', gate_src)
|
||||||
|
return int(mm.group(1)) if mm else None
|
||||||
|
|
||||||
|
major, minor = _const('DRMTAP_ABI_MAJOR'), _const('DRMTAP_ABI_MINOR')
|
||||||
|
mm = re.search(r'const DRMTAP_MIN_MINOR_PATCH: \(c_int, c_int\) = \((\d+), (\d+)\);', gate_src)
|
||||||
|
floor = (int(mm.group(1)), int(mm.group(2))) if mm else None
|
||||||
|
if major is None or minor is None or floor is None:
|
||||||
|
raise Exception(
|
||||||
|
'could not parse the libdrmtap ABI gate out of drmtap_dl.rs (DRMTAP_ABI_MAJOR / '
|
||||||
|
'DRMTAP_ABI_MINOR / DRMTAP_MIN_MINOR_PATCH). The gate moved and this check did not; '
|
||||||
|
'fix the check rather than removing it, or the pin and the gate can drift silently.')
|
||||||
|
accepted = so_ver[0] == major and so_ver[1] == minor and (so_ver[1], so_ver[2]) >= floor
|
||||||
|
if not accepted:
|
||||||
|
raise Exception(
|
||||||
|
f'the libdrmtap being packaged is {so_ver[0]}.{so_ver[1]}.{so_ver[2]}, which the '
|
||||||
|
f'runtime loader would REFUSE: drmtap_dl.rs accepts exactly major {major}, minor '
|
||||||
|
f'{minor}, patch >= {floor[1]}. Shipping it produces a deb whose DRM capture can never '
|
||||||
|
'start. Move the build pin and the gate together, or fix whichever one is wrong.')
|
||||||
|
print(f'[drm] libdrmtap {so_ver[0]}.{so_ver[1]}.{so_ver[2]} satisfies the runtime ABI gate '
|
||||||
|
f'(major {major}, minor {minor}, patch >= {floor[1]})')
|
||||||
|
|
||||||
|
|
||||||
|
def stage_libdrmtap_into_deb(so_path):
|
||||||
|
# Put the built libdrmtap object plus its soname symlink into the staged deb. Only the soname
|
||||||
|
# symlink is needed: libdrmtap is resolved by ABSOLUTE path (/usr/lib/rustdesk/libdrmtap.so.0) at
|
||||||
|
# the in-process dlopen site (drmtap_dl.rs), so the deb does NOT drop /usr/lib/rustdesk into the
|
||||||
|
# system-wide /etc/ld.so.conf.d search path, which would let this private library shadow a system
|
||||||
|
# library for every binary on the host (Debian Policy 10.2 forbids that). No ld.so.conf.d drop-in
|
||||||
|
# and no ldconfig trigger are shipped, so the stock postinst is used unchanged.
|
||||||
|
assert_so_satisfies_the_runtime_abi_gate(so_path)
|
||||||
|
so_basename = os.path.basename(so_path)
|
||||||
|
system2('mkdir -p tmpdeb/usr/lib/rustdesk')
|
||||||
|
# Quoted: so_path comes from the repo root or from DRMTAP_PREBUILT_DIR, either of which can
|
||||||
|
# contain a space, and an unquoted interpolation would split the argument and fail obscurely.
|
||||||
|
system2(f'cp "{so_path}" tmpdeb/usr/lib/rustdesk/')
|
||||||
|
system2(f'ln -sf "{so_basename}" tmpdeb/usr/lib/rustdesk/libdrmtap.so.0')
|
||||||
|
|
||||||
|
|
||||||
|
def _max_glibc_minor(path):
|
||||||
|
# Read from .dynstr rather than via objdump so packaging needs no binutils; chunked because
|
||||||
|
# librustdesk.so is ~45 MB.
|
||||||
|
best = 0
|
||||||
|
with open(path, 'rb') as f:
|
||||||
|
tail = b''
|
||||||
|
while True:
|
||||||
|
chunk = f.read(1 << 20)
|
||||||
|
if not chunk:
|
||||||
|
return best
|
||||||
|
for m in re.finditer(rb'GLIBC_2\.(\d+)', tail + chunk):
|
||||||
|
best = max(best, int(m.group(1)))
|
||||||
|
tail = chunk[-16:]
|
||||||
|
|
||||||
|
|
||||||
|
def measured_glibc_floor():
|
||||||
|
# libdrmtap is built on a newer base than the rest of the deb, so the floor is whichever staged
|
||||||
|
# object is higher -- and it moves whenever either base does.
|
||||||
|
paths = [p for p in glob.glob('tmpdeb/usr/lib/rustdesk/libdrmtap.so.0.*')
|
||||||
|
+ glob.glob('tmpdeb/usr/share/rustdesk/lib/librustdesk.so')
|
||||||
|
+ glob.glob('tmpdeb/usr/share/rustdesk/rustdesk')
|
||||||
|
if os.path.isfile(p) and not os.path.islink(p)]
|
||||||
|
minor = max((_max_glibc_minor(p) for p in paths), default=0)
|
||||||
|
if not minor:
|
||||||
|
raise Exception(
|
||||||
|
f'could not measure a GLIBC_2.x floor from any staged object ({paths or "none found"}); '
|
||||||
|
'refusing to ship the unattended-wayland variant with an undeclared libc6 floor, which '
|
||||||
|
'is what lets it install on a host where libdrmtap can never load')
|
||||||
|
return f'2.{minor}'
|
||||||
|
|
||||||
|
|
||||||
|
def retarget_control_to_drm_variant():
|
||||||
|
# Rewrite the control file that generate_control_file just produced, instead of parameterizing that
|
||||||
|
# function: the stock packaging path stays exactly as upstream wrote it, and everything specific to
|
||||||
|
# this variant lives here. The variant installs the same files as the stock package, so it must
|
||||||
|
# conflict with and replace it: you install one or the other, never both. It also needs libdrmtap's
|
||||||
|
# own runtime deps, which the stock package has no reason to carry.
|
||||||
|
path = '../res/DEBIAN/control'
|
||||||
|
floor = measured_glibc_floor()
|
||||||
|
print(f'[drm] {DRM_PACKAGE_NAME} libc6 floor measured at {floor}')
|
||||||
|
with open(path) as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
out = []
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith('Package: rustdesk'):
|
||||||
|
out.append(f'Package: {DRM_PACKAGE_NAME}\n')
|
||||||
|
out.append('Conflicts: rustdesk\nReplaces: rustdesk\nProvides: rustdesk\n')
|
||||||
|
elif line.startswith('Depends:'):
|
||||||
|
# 2.4.101 is where drmModeGetFB2 landed; below it libdrmtap loads and can never capture.
|
||||||
|
out.append(line.rstrip('\n') + ', libdrm2 (>= 2.4.101), libegl1, libgles2, '
|
||||||
|
f'libc6 (>= {floor})\n')
|
||||||
|
else:
|
||||||
|
out.append(line)
|
||||||
|
body = ''.join(out)
|
||||||
|
# Fail loudly rather than silently shipping a package that says `rustdesk`: a stock control file
|
||||||
|
# that stopped matching either anchor would otherwise produce a variant deb wearing the stock name.
|
||||||
|
if f'Package: {DRM_PACKAGE_NAME}\n' not in body or 'libegl1' not in body:
|
||||||
|
raise Exception(f'could not retarget {path} to the drm variant; upstream control layout changed')
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.write(body)
|
||||||
|
|
||||||
|
|
||||||
def build_flutter_deb(version, features):
|
def build_flutter_deb(version, features):
|
||||||
if not skip_cargo:
|
if not skip_cargo:
|
||||||
system2(f'cargo build --features {features} --lib --release')
|
system2(f'cargo build --locked --features {features} --lib --release')
|
||||||
ffi_bindgen_function_refactor()
|
ffi_bindgen_function_refactor()
|
||||||
os.chdir('flutter')
|
os.chdir('flutter')
|
||||||
system2('flutter build linux --release')
|
system2('flutter build linux --release')
|
||||||
@@ -351,9 +732,22 @@ def build_flutter_deb(version, features):
|
|||||||
'cp ../res/pam.d/rustdesk.debian tmpdeb/etc/pam.d/rustdesk')
|
'cp ../res/pam.d/rustdesk.debian tmpdeb/etc/pam.d/rustdesk')
|
||||||
system2(
|
system2(
|
||||||
"echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit")
|
"echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit")
|
||||||
|
# Bundle libdrmtap.so only when this build actually enabled the `drm` feature, so stock packages
|
||||||
|
# stay exactly what they were. The root service dlopens it in-process by absolute path.
|
||||||
|
# `features` is the comma-joined string, so split it: a bare substring test would also match any
|
||||||
|
# future feature merely containing "drm" (drm-lease, vaapi-drm) and rename the deb to the
|
||||||
|
# consent-bypass variant without --drm ever being passed.
|
||||||
|
ships_so = 'drm' in features.split(',')
|
||||||
|
if ships_so:
|
||||||
|
# Same artifact assertion as the --package path. Under --skip-cargo nothing here rebuilt the
|
||||||
|
# binary, so `features` says what was ASKED for while the staged bundle can be anything.
|
||||||
|
assert_staged_binary_is_drm()
|
||||||
|
stage_libdrmtap_into_deb(build_libdrmtap_so())
|
||||||
|
|
||||||
system2('mkdir -p tmpdeb/DEBIAN')
|
system2('mkdir -p tmpdeb/DEBIAN')
|
||||||
generate_control_file(version)
|
generate_control_file(version)
|
||||||
|
if ships_so:
|
||||||
|
retarget_control_to_drm_variant()
|
||||||
system2('cp -a ../res/DEBIAN/* tmpdeb/DEBIAN/')
|
system2('cp -a ../res/DEBIAN/* tmpdeb/DEBIAN/')
|
||||||
md5_file_folder("tmpdeb/")
|
md5_file_folder("tmpdeb/")
|
||||||
system2('dpkg-deb -b tmpdeb rustdesk.deb;')
|
system2('dpkg-deb -b tmpdeb rustdesk.deb;')
|
||||||
@@ -361,10 +755,68 @@ def build_flutter_deb(version, features):
|
|||||||
system2('/bin/rm -rf tmpdeb/')
|
system2('/bin/rm -rf tmpdeb/')
|
||||||
system2('/bin/rm -rf ../res/DEBIAN/control')
|
system2('/bin/rm -rf ../res/DEBIAN/control')
|
||||||
os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version)
|
os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version)
|
||||||
|
if ships_so:
|
||||||
|
# Named apart from the stock package so installing the consent-free variant is a deliberate act.
|
||||||
|
os.rename('../rustdesk-%s.deb' % version, f'../{DRM_PACKAGE_NAME}-{version}.deb')
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
|
||||||
def build_deb_from_folder(version, binary_folder):
|
DRMTAP_DLOPEN_MARKER = b'/usr/lib/rustdesk/libdrmtap.so.0'
|
||||||
|
# Present only when `drm-wake` is compiled in: the runtime option constant is itself
|
||||||
|
# #[cfg(feature = "drm-wake")] (src/ipc/drm.rs). The dlopen marker above cannot stand in for it -
|
||||||
|
# `--features drm` alone produces a binary that carries the dlopen path and NO wake code, and that
|
||||||
|
# is exactly the deb this assertion is here to refuse.
|
||||||
|
DRMTAP_WAKE_MARKER = b'enable-drm-display-wake'
|
||||||
|
|
||||||
|
|
||||||
|
def _carries_drmtap_marker(path, marker=DRMTAP_DLOPEN_MARKER):
|
||||||
|
# Chunked, with an overlap of len(marker)-1 so the marker cannot be missed at a chunk boundary:
|
||||||
|
# librustdesk.so is ~45 MB and there is no reason to hold it all in memory, and the `with`
|
||||||
|
# closes deterministically instead of relying on refcounting.
|
||||||
|
with open(path, 'rb') as f:
|
||||||
|
tail = b''
|
||||||
|
while True:
|
||||||
|
chunk = f.read(1 << 20)
|
||||||
|
if not chunk:
|
||||||
|
return False
|
||||||
|
if marker in tail + chunk:
|
||||||
|
return True
|
||||||
|
tail = chunk[-(len(marker) - 1):]
|
||||||
|
|
||||||
|
|
||||||
|
def assert_staged_binary_is_drm():
|
||||||
|
"""The staged BINARY must really be a drm build before it is named the unattended-wayland
|
||||||
|
variant. That package conflicts with and replaces the stock one, so shipping a stock binary
|
||||||
|
under that name produces something that can never capture and cannot be installed alongside
|
||||||
|
what it replaced. The marker is the absolute dlopen path from drmtap_dl.rs, present only when
|
||||||
|
the feature is compiled in -- assert what was produced, not what was asked for.
|
||||||
|
|
||||||
|
Called from BOTH packaging paths. It used to guard only one of them, and `--skip-cargo` (which
|
||||||
|
is how CI packages) reaches the other, where nothing had rebuilt the binary at all.
|
||||||
|
"""
|
||||||
|
binaries = [p for p in glob.glob('tmpdeb/usr/share/rustdesk/lib/librustdesk.so')
|
||||||
|
+ glob.glob('tmpdeb/usr/share/rustdesk/rustdesk') if os.path.isfile(p)]
|
||||||
|
if not any(_carries_drmtap_marker(p) for p in binaries):
|
||||||
|
raise Exception(
|
||||||
|
f'--drm was requested but the staged bundle does not look like a drm build (no '
|
||||||
|
f'{DRMTAP_DLOPEN_MARKER.decode()} dlopen path in {binaries or "any staged binary"}); '
|
||||||
|
'refusing to package it as the unattended-wayland variant, which conflicts with and '
|
||||||
|
'replaces the stock package but could never capture')
|
||||||
|
# And the WAKE half. `--drm` enables `drm-wake` too (see get_features), and the deb is named and
|
||||||
|
# documented as the variant that can reach a machine whose screen has gone dark. The dlopen
|
||||||
|
# marker above does not distinguish them: `--features drm` alone carries it and has no wake code
|
||||||
|
# at all. Asserting only the first half is how a deb can be named for a feature it does not have.
|
||||||
|
if not any(_carries_drmtap_marker(p, DRMTAP_WAKE_MARKER) for p in binaries):
|
||||||
|
raise Exception(
|
||||||
|
f'--drm was requested but the staged binary has no {DRMTAP_WAKE_MARKER.decode()} '
|
||||||
|
f'marker in {binaries or "any staged binary"}, so it was built without `drm-wake`; '
|
||||||
|
'refusing to package it as the unattended-wayland variant, which is named and '
|
||||||
|
'documented as the build that can wake an idle-disabled display. If this fired under '
|
||||||
|
'--skip-cargo, the cargo line that produced the bundle is missing the feature: '
|
||||||
|
'--features ...,drm,drm-wake')
|
||||||
|
|
||||||
|
|
||||||
|
def build_deb_from_folder(version, binary_folder, want_drm=False):
|
||||||
os.chdir('flutter')
|
os.chdir('flutter')
|
||||||
system2('mkdir -p tmpdeb/usr/bin/')
|
system2('mkdir -p tmpdeb/usr/bin/')
|
||||||
system2('mkdir -p tmpdeb/usr/share/rustdesk')
|
system2('mkdir -p tmpdeb/usr/share/rustdesk')
|
||||||
@@ -388,9 +840,53 @@ def build_deb_from_folder(version, binary_folder):
|
|||||||
'cp ../res/rustdesk-link.desktop tmpdeb/usr/share/applications/rustdesk-link.desktop')
|
'cp ../res/rustdesk-link.desktop tmpdeb/usr/share/applications/rustdesk-link.desktop')
|
||||||
system2(
|
system2(
|
||||||
"echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit")
|
"echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit")
|
||||||
|
# Where the capture library comes from for a `--package <folder> --drm` build. Two shapes are
|
||||||
|
# supported, because two exist in practice: a bundle that already carries libdrmtap.so.0.*
|
||||||
|
# (someone staged it, e.g. a CI artifact), and a plain bundle, which is what every build path
|
||||||
|
# here actually produces -- the flutter deb builds the library straight into the staged deb, so
|
||||||
|
# nothing ever puts it inside the bundle folder. Demanding it in the bundle made this flag
|
||||||
|
# combination impossible to satisfy.
|
||||||
|
bundled_glob = glob.glob('tmpdeb/usr/share/rustdesk/libdrmtap.so.0.*')
|
||||||
|
bundle_carries_so = any(os.path.isfile(p) and not os.path.islink(p) for p in bundled_glob)
|
||||||
|
# The variant must be decided by the EXPLICIT --drm request, not merely by what happens to be
|
||||||
|
# staged: a bundle that carries the .so must NOT be shipped as the consent-bypass variant when
|
||||||
|
# --drm was never passed.
|
||||||
|
if bundle_carries_so and not want_drm:
|
||||||
|
raise Exception(
|
||||||
|
'the staged bundle carries libdrmtap.so.0.* but --drm was not passed; refusing '
|
||||||
|
'to silently ship the consent-bypass unattended-wayland variant (pass --drm to '
|
||||||
|
'build it deliberately)')
|
||||||
|
if want_drm:
|
||||||
|
# Whichever shape we are in, the staged BINARY must really be a drm build. This is the
|
||||||
|
# property the old presence-of-the-.so test stood in for, badly: a stock binary packaged as
|
||||||
|
# the unattended-wayland variant would carry the consent-bypass name, conflict with and
|
||||||
|
# replace the stock package, and never be able to capture. The marker is the absolute
|
||||||
|
# dlopen path from drmtap_dl.rs, present only when the feature is compiled in -- the same
|
||||||
|
# kind of artifact assertion as _assert_so_has_egl, and for the same reason: assert what
|
||||||
|
# was produced, not what was asked for.
|
||||||
|
assert_staged_binary_is_drm()
|
||||||
|
if bundle_carries_so:
|
||||||
|
so = _single_real_so(bundled_glob, 'the staged --drm bundle')
|
||||||
|
# The THIRD artifact source, and the last one that was missing the check: --package
|
||||||
|
# takes the .so straight out of a bundle somebody else produced, so it has the same
|
||||||
|
# exposure as DRMTAP_PREBUILT_DIR (see the comment on that branch). A CPU-only stub
|
||||||
|
# would ship, the loader would accept it, and capture would degrade to PipeWire
|
||||||
|
# without a word.
|
||||||
|
_assert_so_has_egl(so)
|
||||||
|
stage_libdrmtap_into_deb(so)
|
||||||
|
system2(f'rm -f "{so}"')
|
||||||
|
system2('rm -f tmpdeb/usr/share/rustdesk/libdrmtap.so tmpdeb/usr/share/rustdesk/libdrmtap.so.0')
|
||||||
|
else:
|
||||||
|
# Build it here, exactly as the flutter deb path does (build_libdrmtap_so asserts the
|
||||||
|
# EGL backend itself). The library is independent of the staged binary.
|
||||||
|
stage_libdrmtap_into_deb(build_libdrmtap_so())
|
||||||
|
|
||||||
system2('mkdir -p tmpdeb/DEBIAN')
|
system2('mkdir -p tmpdeb/DEBIAN')
|
||||||
generate_control_file(version)
|
generate_control_file(version)
|
||||||
|
# Keyed on the EXPLICIT request, not on what happened to be staged: by here a --drm build has
|
||||||
|
# its library in tmpdeb whichever of the two shapes it came from.
|
||||||
|
if want_drm:
|
||||||
|
retarget_control_to_drm_variant()
|
||||||
system2('cp -a ../res/DEBIAN/* tmpdeb/DEBIAN/')
|
system2('cp -a ../res/DEBIAN/* tmpdeb/DEBIAN/')
|
||||||
md5_file_folder("tmpdeb/")
|
md5_file_folder("tmpdeb/")
|
||||||
system2('dpkg-deb -b tmpdeb rustdesk.deb;')
|
system2('dpkg-deb -b tmpdeb rustdesk.deb;')
|
||||||
@@ -398,6 +894,8 @@ def build_deb_from_folder(version, binary_folder):
|
|||||||
system2('/bin/rm -rf tmpdeb/')
|
system2('/bin/rm -rf tmpdeb/')
|
||||||
system2('/bin/rm -rf ../res/DEBIAN/control')
|
system2('/bin/rm -rf ../res/DEBIAN/control')
|
||||||
os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version)
|
os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version)
|
||||||
|
if want_drm:
|
||||||
|
os.rename('../rustdesk-%s.deb' % version, f'../{DRM_PACKAGE_NAME}-{version}.deb')
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
|
||||||
@@ -405,12 +903,17 @@ def build_flutter_dmg(version, features):
|
|||||||
if not skip_cargo:
|
if not skip_cargo:
|
||||||
# set minimum osx build target, now is 10.14, which is the same as the flutter xcode project
|
# set minimum osx build target, now is 10.14, which is the same as the flutter xcode project
|
||||||
system2(
|
system2(
|
||||||
f'MACOSX_DEPLOYMENT_TARGET=10.14 cargo build --features {features} --release')
|
f'MACOSX_DEPLOYMENT_TARGET=10.14 cargo build --locked --features {features} --release')
|
||||||
# copy dylib
|
# copy dylib
|
||||||
system2(
|
system2(
|
||||||
"cp target/release/liblibrustdesk.dylib target/release/librustdesk.dylib")
|
"cp target/release/liblibrustdesk.dylib target/release/librustdesk.dylib")
|
||||||
os.chdir('flutter')
|
os.chdir('flutter')
|
||||||
system2('flutter build macos --release')
|
# cargo builds a single-arch dylib for the host; restrict Xcode to the same arch
|
||||||
|
# so the universal-by-default ARCHS_STANDARD doesn't try to link a missing slice.
|
||||||
|
# FLUTTER_XCODE_* env vars are forwarded to xcodebuild as build settings.
|
||||||
|
mac_arch = 'arm64' if platform.machine().lower() in ('arm64', 'aarch64') else 'x86_64'
|
||||||
|
system2(
|
||||||
|
f'FLUTTER_XCODE_ARCHS={mac_arch} FLUTTER_XCODE_ONLY_ACTIVE_ARCH=YES flutter build macos --release')
|
||||||
system2('cp -rf ../target/release/service ./build/macos/Build/Products/Release/RustDesk.app/Contents/MacOS/')
|
system2('cp -rf ../target/release/service ./build/macos/Build/Products/Release/RustDesk.app/Contents/MacOS/')
|
||||||
'''
|
'''
|
||||||
system2(
|
system2(
|
||||||
@@ -422,7 +925,7 @@ def build_flutter_dmg(version, features):
|
|||||||
|
|
||||||
def build_flutter_arch_manjaro(version, features):
|
def build_flutter_arch_manjaro(version, features):
|
||||||
if not skip_cargo:
|
if not skip_cargo:
|
||||||
system2(f'cargo build --features {features} --lib --release')
|
system2(f'cargo build --locked --features {features} --lib --release')
|
||||||
ffi_bindgen_function_refactor()
|
ffi_bindgen_function_refactor()
|
||||||
os.chdir('flutter')
|
os.chdir('flutter')
|
||||||
system2('flutter build linux --release')
|
system2('flutter build linux --release')
|
||||||
@@ -433,7 +936,7 @@ def build_flutter_arch_manjaro(version, features):
|
|||||||
|
|
||||||
def build_flutter_windows(version, features, skip_portable_pack):
|
def build_flutter_windows(version, features, skip_portable_pack):
|
||||||
if not skip_cargo:
|
if not skip_cargo:
|
||||||
system2(f'cargo build --features {features} --lib --release')
|
system2(f'cargo build --locked --features {features} --lib --release')
|
||||||
if not os.path.exists("target/release/librustdesk.dll"):
|
if not os.path.exists("target/release/librustdesk.dll"):
|
||||||
print("cargo build failed, please check rust source code.")
|
print("cargo build failed, please check rust source code.")
|
||||||
exit(-1)
|
exit(-1)
|
||||||
@@ -467,6 +970,19 @@ def main():
|
|||||||
parser = make_parser()
|
parser = make_parser()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Before anything with a side effect: this is a query, and a caller uses it to build the very
|
||||||
|
# binary it will then package. `get_features` stays the single definition of what a flag
|
||||||
|
# combination means; a caller that hardcodes the list instead is one edit away from compiling
|
||||||
|
# something other than what it ships.
|
||||||
|
if args.print_features:
|
||||||
|
# stdout carries the list and nothing else, so a caller can use it directly in a command
|
||||||
|
# substitution. `get_features` prints a human-readable line of its own; send that to stderr
|
||||||
|
# for this call rather than silencing it, which would change what every other path prints.
|
||||||
|
with contextlib.redirect_stdout(sys.stderr):
|
||||||
|
feats = ','.join(get_features(args))
|
||||||
|
print(feats)
|
||||||
|
return
|
||||||
|
|
||||||
if os.path.exists(exe_path):
|
if os.path.exists(exe_path):
|
||||||
os.unlink(exe_path)
|
os.unlink(exe_path)
|
||||||
if os.path.isfile('/usr/bin/pacman'):
|
if os.path.isfile('/usr/bin/pacman'):
|
||||||
@@ -482,20 +998,20 @@ def main():
|
|||||||
portable = args.portable
|
portable = args.portable
|
||||||
package = args.package
|
package = args.package
|
||||||
if package:
|
if package:
|
||||||
build_deb_from_folder(version, package)
|
build_deb_from_folder(version, package, args.drm)
|
||||||
return
|
return
|
||||||
res_dir = 'resources'
|
res_dir = 'resources'
|
||||||
external_resources(flutter, args, res_dir)
|
external_resources(flutter, args, res_dir)
|
||||||
if windows:
|
if windows:
|
||||||
# build virtual display dynamic library
|
# build virtual display dynamic library
|
||||||
os.chdir('libs/virtual_display/dylib')
|
os.chdir('libs/virtual_display/dylib')
|
||||||
system2('cargo build --release')
|
system2('cargo build --locked --release')
|
||||||
os.chdir('../../..')
|
os.chdir('../../..')
|
||||||
|
|
||||||
if flutter:
|
if flutter:
|
||||||
build_flutter_windows(version, features, args.skip_portable_pack)
|
build_flutter_windows(version, features, args.skip_portable_pack)
|
||||||
return
|
return
|
||||||
system2('cargo build --release --features ' + features)
|
system2('cargo build --locked --release --features ' + features)
|
||||||
# system2('upx.exe target/release/rustdesk.exe')
|
# system2('upx.exe target/release/rustdesk.exe')
|
||||||
system2('mv target/release/rustdesk.exe target/release/RustDesk.exe')
|
system2('mv target/release/rustdesk.exe target/release/RustDesk.exe')
|
||||||
pa = os.environ.get('P')
|
pa = os.environ.get('P')
|
||||||
@@ -506,20 +1022,21 @@ def main():
|
|||||||
'target\\release\\rustdesk.exe')
|
'target\\release\\rustdesk.exe')
|
||||||
else:
|
else:
|
||||||
print('Not signed')
|
print('Not signed')
|
||||||
|
os.makedirs(res_dir, exist_ok=True)
|
||||||
system2(
|
system2(
|
||||||
f'cp -rf target/release/RustDesk.exe {res_dir}')
|
f'cp -rf target/release/RustDesk.exe {res_dir}')
|
||||||
os.chdir('libs/portable')
|
os.chdir('libs/portable')
|
||||||
system2('pip3 install -r requirements.txt')
|
system2('pip3 install -r requirements.txt')
|
||||||
system2(
|
system2(
|
||||||
f'python3 ./generate.py -f ../../{res_dir} -o . -e ../../{res_dir}/rustdesk-{version}-win7-install.exe')
|
f'python3 ./generate.py -f ../../{res_dir} -o . -e ../../{res_dir}/rustdesk-{version}-win7-install.exe')
|
||||||
system2('mv ../../{res_dir}/rustdesk-{version}-win7-install.exe ../..')
|
system2(f'mv ../../{res_dir}/rustdesk-{version}-win7-install.exe ../..')
|
||||||
elif os.path.isfile('/usr/bin/pacman'):
|
elif os.path.isfile('/usr/bin/pacman'):
|
||||||
# pacman -S -needed base-devel
|
# pacman -S -needed base-devel
|
||||||
system2("sed -i 's/pkgver=.*/pkgver=%s/g' res/PKGBUILD" % version)
|
system2("sed -i 's/pkgver=.*/pkgver=%s/g' res/PKGBUILD" % version)
|
||||||
if flutter:
|
if flutter:
|
||||||
build_flutter_arch_manjaro(version, features)
|
build_flutter_arch_manjaro(version, features)
|
||||||
else:
|
else:
|
||||||
system2('cargo build --release --features ' + features)
|
system2('cargo build --locked --release --features ' + features)
|
||||||
system2('git checkout src/ui/common.tis')
|
system2('git checkout src/ui/common.tis')
|
||||||
system2('strip target/release/rustdesk')
|
system2('strip target/release/rustdesk')
|
||||||
system2('ln -s res/pacman_install && ln -s res/PKGBUILD')
|
system2('ln -s res/pacman_install && ln -s res/PKGBUILD')
|
||||||
@@ -528,7 +1045,7 @@ def main():
|
|||||||
version, version))
|
version, version))
|
||||||
# pacman -U ./rustdesk.pkg.tar.zst
|
# pacman -U ./rustdesk.pkg.tar.zst
|
||||||
elif os.path.isfile('/usr/bin/yum'):
|
elif os.path.isfile('/usr/bin/yum'):
|
||||||
system2('cargo build --release --features ' + features)
|
system2('cargo build --locked --release --features ' + features)
|
||||||
system2('strip target/release/rustdesk')
|
system2('strip target/release/rustdesk')
|
||||||
system2(
|
system2(
|
||||||
"sed -i 's/Version: .*/Version: %s/g' res/rpm.spec" % version)
|
"sed -i 's/Version: .*/Version: %s/g' res/rpm.spec" % version)
|
||||||
@@ -538,7 +1055,7 @@ def main():
|
|||||||
version, version))
|
version, version))
|
||||||
# yum localinstall rustdesk.rpm
|
# yum localinstall rustdesk.rpm
|
||||||
elif os.path.isfile('/usr/bin/zypper'):
|
elif os.path.isfile('/usr/bin/zypper'):
|
||||||
system2('cargo build --release --features ' + features)
|
system2('cargo build --locked --release --features ' + features)
|
||||||
system2('strip target/release/rustdesk')
|
system2('strip target/release/rustdesk')
|
||||||
system2(
|
system2(
|
||||||
"sed -i 's/Version: .*/Version: %s/g' res/rpm-suse.spec" % version)
|
"sed -i 's/Version: .*/Version: %s/g' res/rpm-suse.spec" % version)
|
||||||
@@ -557,7 +1074,7 @@ def main():
|
|||||||
# 'mv target/release/bundle/deb/rustdesk*.deb ./flutter/rustdesk.deb')
|
# 'mv target/release/bundle/deb/rustdesk*.deb ./flutter/rustdesk.deb')
|
||||||
build_flutter_deb(version, features)
|
build_flutter_deb(version, features)
|
||||||
else:
|
else:
|
||||||
system2('cargo bundle --release --features ' + features)
|
system2('cargo --locked bundle --release --features ' + features)
|
||||||
if osx:
|
if osx:
|
||||||
system2(
|
system2(
|
||||||
'strip target/release/bundle/osx/RustDesk.app/Contents/MacOS/rustdesk')
|
'strip target/release/bundle/osx/RustDesk.app/Contents/MacOS/rustdesk')
|
||||||
|
|||||||
143
docs/CODE_OF_CONDUCT-FR.md
Normal file
143
docs/CODE_OF_CONDUCT-FR.md
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
|
||||||
|
# Code de conduite des contributeurs
|
||||||
|
|
||||||
|
## Notre engagement
|
||||||
|
|
||||||
|
En tant que membres, contributeurs et responsables, nous nous engageons à faire
|
||||||
|
de la participation à notre communauté une expérience exempte de harcèlement pour
|
||||||
|
tous, indépendamment de l'âge, de la taille corporelle, du handicap visible ou
|
||||||
|
invisible, de l'origine ethnique, des caractéristiques sexuelles, de l'identité
|
||||||
|
et de l'expression de genre, du niveau d'expérience, de l'éducation, du statut
|
||||||
|
socio-économique, de la nationalité, de l'apparence personnelle, de la race, de
|
||||||
|
la religion ou de l'identité et de l'orientation sexuelle.
|
||||||
|
|
||||||
|
Nous nous engageons à agir et à interagir de manière à contribuer à une
|
||||||
|
communauté ouverte, accueillante, diversifiée, inclusive et saine.
|
||||||
|
|
||||||
|
## Nos standards
|
||||||
|
|
||||||
|
Exemples de comportements qui contribuent à un environnement positif pour notre
|
||||||
|
communauté :
|
||||||
|
|
||||||
|
* Faire preuve d'empathie et de bienveillance envers les autres
|
||||||
|
* Respecter les opinions, les points de vue et les expériences différents
|
||||||
|
* Donner et accepter gracieusement les retours constructifs
|
||||||
|
* Assumer ses responsabilités, s'excuser auprès des personnes affectées par nos
|
||||||
|
erreurs et apprendre de l'expérience
|
||||||
|
* Se concentrer sur ce qui est le mieux non seulement pour nous en tant
|
||||||
|
qu'individus, mais pour l'ensemble de la communauté
|
||||||
|
|
||||||
|
Exemples de comportements inacceptables :
|
||||||
|
|
||||||
|
* L'utilisation de langage ou d'images à caractère sexuel, et les attentions ou
|
||||||
|
avances sexuelles de quelque nature que ce soit
|
||||||
|
* Le trolling, les commentaires insultants ou désobligeants, et les attaques
|
||||||
|
personnelles ou politiques
|
||||||
|
* Le harcèlement public ou privé
|
||||||
|
* La publication d'informations privées d'autrui, telles qu'une adresse physique
|
||||||
|
ou électronique, sans autorisation explicite
|
||||||
|
* Tout autre comportement qui pourrait raisonnablement être considéré comme
|
||||||
|
inapproprié dans un cadre professionnel
|
||||||
|
|
||||||
|
## Responsabilités en matière d'application
|
||||||
|
|
||||||
|
Les responsables de la communauté sont chargés de clarifier et d'appliquer nos
|
||||||
|
standards de comportement acceptable et prendront des mesures correctives
|
||||||
|
appropriées et équitables en réponse à tout comportement qu'ils jugent
|
||||||
|
inapproprié, menaçant, offensant ou nuisible.
|
||||||
|
|
||||||
|
Les responsables de la communauté ont le droit et la responsabilité de
|
||||||
|
supprimer, modifier ou rejeter les commentaires, commits, code, modifications
|
||||||
|
du wiki, issues et autres contributions qui ne sont pas conformes à ce Code de
|
||||||
|
conduite, et communiqueront les raisons de leurs décisions de modération le cas
|
||||||
|
échéant.
|
||||||
|
|
||||||
|
## Portée
|
||||||
|
|
||||||
|
Ce Code de conduite s'applique dans tous les espaces communautaires, et
|
||||||
|
s'applique également lorsqu'une personne représente officiellement la communauté
|
||||||
|
dans les espaces publics. Les exemples de représentation de notre communauté
|
||||||
|
incluent l'utilisation d'une adresse e-mail officielle, la publication via un
|
||||||
|
compte de réseau social officiel, ou le fait d'agir en tant que représentant
|
||||||
|
désigné lors d'un événement en ligne ou hors ligne.
|
||||||
|
|
||||||
|
## Application
|
||||||
|
|
||||||
|
Les cas de comportements abusifs, harcelants ou autrement inacceptables peuvent
|
||||||
|
être signalés aux responsables de la communauté chargés de l'application à
|
||||||
|
[info@rustdesk.com](mailto:info@rustdesk.com).
|
||||||
|
Toutes les plaintes seront examinées et feront l'objet d'une enquête rapide et
|
||||||
|
équitable.
|
||||||
|
|
||||||
|
Tous les responsables de la communauté sont tenus de respecter la vie privée et
|
||||||
|
la sécurité de la personne ayant signalé un incident.
|
||||||
|
|
||||||
|
## Directives d'application
|
||||||
|
|
||||||
|
Les responsables de la communauté suivront ces Directives d'impact communautaire
|
||||||
|
pour déterminer les conséquences de toute action qu'ils jugent en violation de ce
|
||||||
|
Code de conduite :
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Impact communautaire** : Utilisation d'un langage inapproprié ou autre
|
||||||
|
comportement jugé non professionnel ou indésirable dans la communauté.
|
||||||
|
|
||||||
|
**Conséquence** : Un avertissement écrit et privé de la part des responsables de
|
||||||
|
la communauté, expliquant la nature de la violation et pourquoi le comportement
|
||||||
|
était inapproprié. Des excuses publiques peuvent être demandées.
|
||||||
|
|
||||||
|
### 2. Avertissement
|
||||||
|
|
||||||
|
**Impact communautaire** : Une violation par un incident isolé ou une série
|
||||||
|
d'actions.
|
||||||
|
|
||||||
|
**Conséquence** : Un avertissement avec des conséquences en cas de comportement
|
||||||
|
répété. Aucune interaction avec les personnes impliquées, y compris les
|
||||||
|
interactions non sollicitées avec les personnes chargées d'appliquer le Code de
|
||||||
|
conduite, pendant une période déterminée. Cela inclut d'éviter les interactions
|
||||||
|
dans les espaces communautaires ainsi que dans les canaux externes comme les
|
||||||
|
réseaux sociaux. Le non-respect de ces conditions peut entraîner une exclusion
|
||||||
|
temporaire ou permanente.
|
||||||
|
|
||||||
|
### 3. Exclusion temporaire
|
||||||
|
|
||||||
|
**Impact communautaire** : Une violation grave des standards communautaires, y
|
||||||
|
compris un comportement inapproprié persistant.
|
||||||
|
|
||||||
|
**Conséquence** : Une exclusion temporaire de toute interaction ou communication
|
||||||
|
publique avec la communauté pendant une période déterminée. Aucune interaction
|
||||||
|
publique ou privée avec les personnes impliquées, y compris les interactions non
|
||||||
|
sollicitées avec les personnes chargées d'appliquer le Code de conduite, n'est
|
||||||
|
autorisée pendant cette période. Le non-respect de ces conditions peut entraîner
|
||||||
|
une exclusion permanente.
|
||||||
|
|
||||||
|
### 4. Exclusion permanente
|
||||||
|
|
||||||
|
**Impact communautaire** : Démontrer un schéma de violation des standards
|
||||||
|
communautaires, y compris un comportement inapproprié persistant, le harcèlement
|
||||||
|
d'une personne, ou une agression envers des catégories de personnes ou leur
|
||||||
|
dénigrement.
|
||||||
|
|
||||||
|
**Conséquence** : Une exclusion permanente de toute interaction publique au sein
|
||||||
|
de la communauté.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
Ce Code de conduite est adapté du [Contributor Covenant][homepage], version 2.0,
|
||||||
|
disponible à l'adresse
|
||||||
|
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
||||||
|
|
||||||
|
Les Directives d'impact communautaire ont été inspirées par
|
||||||
|
[l'échelle d'application du code de conduite de Mozilla][Mozilla CoC].
|
||||||
|
|
||||||
|
Pour des réponses aux questions fréquentes sur ce code de conduite, consultez la
|
||||||
|
FAQ à l'adresse [https://www.contributor-covenant.org/faq][FAQ]. Des traductions
|
||||||
|
sont disponibles à l'adresse
|
||||||
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||||
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
@@ -107,7 +107,7 @@ Violating these terms may lead to a permanent ban.
|
|||||||
### 4. Permanent Ban
|
### 4. Permanent Ban
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
standards, including sustained inappropriate behavior, harassment of an
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
individual, or aggression toward or disparagement of classes of individuals.
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
|||||||
55
docs/CONTRIBUTING-FR.md
Normal file
55
docs/CONTRIBUTING-FR.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
# Contribuer à RustDesk
|
||||||
|
|
||||||
|
RustDesk accueille les contributions de tous. Voici les directives si vous
|
||||||
|
envisagez de nous aider :
|
||||||
|
|
||||||
|
## Contributions
|
||||||
|
|
||||||
|
Les contributions à RustDesk ou à ses dépendances doivent être soumises sous
|
||||||
|
forme de pull requests GitHub. Chaque pull request sera examinée par un
|
||||||
|
contributeur principal (une personne ayant la permission d'intégrer des
|
||||||
|
correctifs) et sera soit intégrée dans la branche principale, soit accompagnée
|
||||||
|
de retours sur les modifications requises. Toutes les contributions doivent
|
||||||
|
suivre ce format, même celles des contributeurs principaux.
|
||||||
|
|
||||||
|
Si vous souhaitez travailler sur une issue, veuillez d'abord la revendiquer en
|
||||||
|
commentant sur l'issue GitHub indiquant que vous souhaitez la traiter. Cela
|
||||||
|
permet d'éviter les efforts en double de la part des contributeurs sur la même
|
||||||
|
issue.
|
||||||
|
|
||||||
|
## Liste de vérification pour les pull requests
|
||||||
|
|
||||||
|
- Partez de la branche master et, si nécessaire, effectuez un rebase sur la
|
||||||
|
branche master actuelle avant de soumettre votre pull request. Si elle ne
|
||||||
|
fusionne pas proprement avec master, il vous sera peut-être demandé de
|
||||||
|
rebaser vos modifications.
|
||||||
|
|
||||||
|
- Les commits doivent être aussi petits que possible, tout en s'assurant que
|
||||||
|
chaque commit est correct de manière indépendante (c.-à-d. que chaque commit
|
||||||
|
doit compiler et passer les tests).
|
||||||
|
|
||||||
|
- Les commits doivent être accompagnés d'une signature Developer Certificate of
|
||||||
|
Origin (http://developercertificate.org), indiquant que vous (et votre
|
||||||
|
employeur le cas échéant) acceptez d'être liés par les termes de la
|
||||||
|
[licence du projet](../LICENCE). Dans git, il s'agit de l'option `-s` de
|
||||||
|
`git commit`.
|
||||||
|
|
||||||
|
- Si votre correctif n'est pas examiné ou si vous avez besoin qu'une personne
|
||||||
|
spécifique l'examine, vous pouvez @-mentionner un relecteur pour demander une
|
||||||
|
revue dans la pull request ou un commentaire, ou vous pouvez demander une
|
||||||
|
revue par [e-mail](mailto:info@rustdesk.com).
|
||||||
|
|
||||||
|
- Ajoutez des tests relatifs au bug corrigé ou à la nouvelle fonctionnalité.
|
||||||
|
|
||||||
|
Pour des instructions git spécifiques, consultez le
|
||||||
|
[GitHub workflow 101](https://github.com/servo/servo/wiki/GitHub-workflow).
|
||||||
|
|
||||||
|
## Conduite
|
||||||
|
|
||||||
|
https://github.com/rustdesk/rustdesk/blob/master/docs/CODE_OF_CONDUCT.md
|
||||||
|
|
||||||
|
## Communication
|
||||||
|
|
||||||
|
Les contributeurs de RustDesk se retrouvent fréquemment sur
|
||||||
|
[Discord](https://discord.gg/nDceKgxnkV).
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Contributing to RustDesk
|
# Contributing to RustDesk
|
||||||
|
|
||||||
RustDesk welcomes contribution from everyone. Here are the guidelines if you are
|
RustDesk welcomes contributions from everyone. Here are the guidelines if you are
|
||||||
thinking of helping us:
|
thinking of helping us:
|
||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="../res/logo-header.svg" alt="RustDesk - Your remote desktop"><br>
|
<img src="../res/logo-header.svg" alt="RustDesk - Dein Remote-Desktop"><br>
|
||||||
<a href="#freie-öffentliche-server">Server</a> •
|
|
||||||
<a href="#grobe-schritte-zum-kompilieren">Kompilieren</a> •
|
<a href="#grobe-schritte-zum-kompilieren">Kompilieren</a> •
|
||||||
<a href="#auf-docker-kompilieren">Docker</a> •
|
<a href="#auf-docker-kompilieren">Docker</a> •
|
||||||
<a href="#dateistruktur">Dateistruktur</a> •
|
<a href="#dateistruktur">Dateistruktur</a> •
|
||||||
<a href="#screenshots">Screenshots</a><br>
|
<a href="#screenshots">Screenshots</a><br>
|
||||||
[<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-IT.md">Italiano</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-VN.md">Tiếng Việt</a>] | [<a href="README-DA.md">Dansk</a>] | [<a href="README-GR.md">Ελληνικά</a>]<br>
|
[<a href="docs/README-UA.md">Українська</a>] | [<a href="docs/README-CS.md">česky</a>] | [<a href="docs/README-ZH.md">中文</a>] | [<a href="docs/README-HU.md">Magyar</a>] | [<a href="docs/README-ES.md">Español</a>] | [<a href="docs/README-FA.md">فارسی</a>] | [<a href="docs/README-FR.md">Français</a>] | [<a href="docs/README-DE.md">Deutsch</a>] | [<a href="docs/README-PL.md">Polski</a>] | [<a href="docs/README-ID.md">Indonesian</a>] | [<a href="docs/README-FI.md">Suomi</a>] | [<a href="docs/README-ML.md">മലയാളം</a>] | [<a href="docs/README-JP.md">日本語</a>] | [<a href="docs/README-NL.md">Nederlands</a>] | [<a href="docs/README-IT.md">Italiano</a>] | [<a href="docs/README-RU.md">Русский</a>] | [<a href="docs/README-PTBR.md">Português (Brasil)</a>] | [<a href="docs/README-EO.md">Esperanto</a>] | [<a href="docs/README-KR.md">한국어</a>] | [<a href="docs/README-AR.md">العربي</a>] | [<a href="docs/README-VN.md">Tiếng Việt</a>] | [<a href="docs/README-DA.md">Dansk</a>] | [<a href="docs/README-GR.md">Ελληνικά</a>] | [<a href="docs/README-TR.md">Türkçe</a>] | [<a href="docs/README-NO.md">Norsk</a>] | [<a href="docs/README-RO.md">Română</a>]<br>
|
||||||
<b>Wir brauchen Ihre Hilfe, um dieses README, die <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">RustDesk-Benutzeroberfläche</a> und die <a href="https://github.com/rustdesk/doc.rustdesk.com">Dokumentation</a> in Ihre Muttersprache zu übersetzen.</b>
|
<b>Wir brauchen Ihre Hilfe, um dieses README, die <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">RustDesk-Benutzeroberfläche</a> und die <a href="https://github.com/rustdesk/doc.rustdesk.com">Dokumentation</a> in Ihre Muttersprache zu übersetzen.</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
> [!Vorsicht]
|
> [!Caution]
|
||||||
> **Haftungsausschluss bei Missbrauch::** <br>
|
> **Haftungsausschluss bei Missbrauch::** <br>
|
||||||
> Die Entwickler von RustDesk billigen oder unterstützen keine unethische oder illegale Nutzung dieser Software. Missbrauch, wie unbefugter Zugriff, unbefugte Kontrolle oder Verletzung der Privatsphäre, verstößt strikt gegen unsere Richtlinien. Die Autoren sind nicht verantwortlich für jeglichen Missbrauch der Anwendung.
|
> Die Entwickler von RustDesk billigen oder unterstützen keine unethische oder illegale Nutzung dieser Software. Missbrauch, wie unbefugter Zugriff, unbefugte Kontrolle oder Verletzung der Privatsphäre, verstößt strikt gegen unsere Richtlinien. Die Autoren sind nicht verantwortlich für jeglichen Missbrauch der Anwendung.
|
||||||
|
|
||||||
@@ -28,11 +27,14 @@ RustDesk heißt jegliche Mitarbeit willkommen. Schauen Sie sich [CONTRIBUTING-DE
|
|||||||
|
|
||||||
[**Programm herunterladen**](https://github.com/rustdesk/rustdesk/releases)
|
[**Programm herunterladen**](https://github.com/rustdesk/rustdesk/releases)
|
||||||
|
|
||||||
[**Nächtliche Erstellung**](https://github.com/rustdesk/rustdesk/releases/tag/nightly)
|
[**Nightly Builds**](https://github.com/rustdesk/rustdesk/releases/tag/nightly)
|
||||||
|
|
||||||
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
|
[<img src="https://f-droid.org/badge/get-it-on.png"
|
||||||
alt="Get it on F-Droid"
|
alt="Get it on F-Droid"
|
||||||
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
|
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
|
||||||
|
[<img src="https://flathub.org/api/badge?svg&locale=en"
|
||||||
|
alt="Get it on Flathub"
|
||||||
|
height="80">](https://flathub.org/apps/com.rustdesk.RustDesk)
|
||||||
|
|
||||||
## Abhängigkeiten
|
## Abhängigkeiten
|
||||||
|
|
||||||
@@ -64,18 +66,19 @@ Bitte laden Sie die dynamische Bibliothek Sciter selbst herunter.
|
|||||||
```sh
|
```sh
|
||||||
sudo apt install -y zip g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev \
|
sudo apt install -y zip g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev \
|
||||||
libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake make \
|
libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake make \
|
||||||
libclang-dev ninja-build libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
libclang-dev ninja-build libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libpam0g-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### openSUSE Tumbleweed
|
### openSUSE Tumbleweed
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo zypper install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libXfixes-devel cmake alsa-lib-devel gstreamer-devel gstreamer-plugins-base-devel xdotool-devel
|
sudo zypper install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libXfixes-devel cmake alsa-lib-devel gstreamer-devel gstreamer-plugins-base-devel xdotool-devel pam-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fedora 28 (CentOS 8)
|
### Fedora 28 (CentOS 8)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libxdo-devel libXfixes-devel pulseaudio-libs-devel cmake alsa-lib-devel
|
sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libxdo-devel libXfixes-devel pulseaudio-libs-devel cmake alsa-lib-devel gstreamer1-devel gstreamer1-plugins-base-devel pam-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Arch (Manjaro)
|
### Arch (Manjaro)
|
||||||
@@ -114,7 +117,7 @@ cd
|
|||||||
```sh
|
```sh
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
source $HOME/.cargo/env
|
source $HOME/.cargo/env
|
||||||
git clone https://github.com/rustdesk/rustdesk
|
git clone --recurse-submodules https://github.com/rustdesk/rustdesk
|
||||||
cd rustdesk
|
cd rustdesk
|
||||||
mkdir -p target/debug
|
mkdir -p target/debug
|
||||||
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
|
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
|
||||||
@@ -129,6 +132,7 @@ Beginnen Sie damit, das Repository zu klonen und den Docker-Container zu bauen:
|
|||||||
```sh
|
```sh
|
||||||
git clone https://github.com/rustdesk/rustdesk
|
git clone https://github.com/rustdesk/rustdesk
|
||||||
cd rustdesk
|
cd rustdesk
|
||||||
|
git submodule update --init --recursive
|
||||||
docker build -t "rustdesk-builder" .
|
docker build -t "rustdesk-builder" .
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -157,6 +161,7 @@ Bitte stellen Sie sicher, dass Sie diese Befehle im Stammverzeichnis des RustDes
|
|||||||
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: Video-Codec, Konfiguration, TCP/UDP-Wrapper, Protokoll-Puffer, fs-Funktionen für Dateitransfer und ein paar andere nützliche Funktionen
|
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: Video-Codec, Konfiguration, TCP/UDP-Wrapper, Protokoll-Puffer, fs-Funktionen für Dateitransfer und ein paar andere nützliche Funktionen
|
||||||
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: Bildschirmaufnahme
|
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: Bildschirmaufnahme
|
||||||
- **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: Plattformspezifische Maus- und Tastatursteuerung
|
- **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: Plattformspezifische Maus- und Tastatursteuerung
|
||||||
|
- **[libs/clipboard](https://github.com/rustdesk/rustdesk/tree/master/libs/clipboard)**: Datei kopieren und einfügen Implementierung für Windows, Linux, macOS.
|
||||||
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: GUI
|
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: GUI
|
||||||
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: Audio/Zwischenablage/Eingabe/Videodienste und Netzwerkverbindungen
|
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: Audio/Zwischenablage/Eingabe/Videodienste und Netzwerkverbindungen
|
||||||
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: Starten einer Peer-Verbindung
|
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: Starten einer Peer-Verbindung
|
||||||
@@ -167,10 +172,11 @@ Bitte stellen Sie sicher, dass Sie diese Befehle im Stammverzeichnis des RustDes
|
|||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||

|
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ Les versions de bureau utilisent [sciter](https://sciter.com/) pour l'interface
|
|||||||
- Installez [vcpkg](https://github.com/microsoft/vcpkg), et définissez correctement la variable d'environnement `VCPKG_ROOT`.
|
- Installez [vcpkg](https://github.com/microsoft/vcpkg), et définissez correctement la variable d'environnement `VCPKG_ROOT`.
|
||||||
|
|
||||||
- Windows : vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static
|
- Windows : vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static
|
||||||
- Linux/Osx : vcpkg install libvpx libyuv opus aom
|
- Linux/macOS : vcpkg install libvpx libyuv opus aom
|
||||||
|
|
||||||
- Exécuter `cargo run`
|
- Exécutez `cargo run`
|
||||||
|
|
||||||
## Comment compiler/build sous Linux
|
## Comment compiler/build sous Linux
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ cd rustdesk
|
|||||||
mkdir -p target/debug
|
mkdir -p target/debug
|
||||||
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
|
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
|
||||||
mv libsciter-gtk.so target/debug
|
mv libsciter-gtk.so target/debug
|
||||||
Exécution du cargo
|
cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
## Comment construire avec Docker
|
## Comment construire avec Docker
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="../res/logo-header.svg" alt="RustDesk - Your remote desktop"><br>
|
<img src="../res/logo-header.svg" alt="RustDesk - Your remote desktop"><br>
|
||||||
<a href="#빌드를 위한 원시 단계">빌드</a> •
|
<a href="#빌드를_위한_원시_단계">빌드</a> •
|
||||||
<a href="#Docker로 빌드하는 방법">Docker</a> •
|
<a href="#Docker로_빌드하는_방법">Docker</a> •
|
||||||
<a href="#파일 구조">구조</a> •
|
<a href="#파일_구조">구조</a> •
|
||||||
<a href="#스크린샷">스냇샷</a><br>
|
<a href="#스크린샷">스냅샷</a><br>
|
||||||
[<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-IT.md">Italiano</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-VN.md">Tiếng Việt</a>] | [<a href="README-DA.md">Dansk</a>] | [<a href="README-GR.md">Ελληνικά</a>] | [<a href="README-TR.md">Türkçe</a>] | [<a href="README-NO.md">Norsk</a>]<br>
|
[<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-IT.md">Italiano</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-VN.md">Tiếng Việt</a>] | [<a href="README-DA.md">Dansk</a>] | [<a href="README-GR.md">Ελληνικά</a>] | [<a href="README-TR.md">Türkçe</a>] | [<a href="README-NO.md">Norsk</a>] | [<a href="README-RO.md">Română</a>]<br>
|
||||||
<b>이 README, <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">RustDesk UI</a> 및 <a href="https://github.com/rustdesk/doc.rustdesk.com">RustDesk 문서</a>를 귀하의 모국어로 번역하는 데 도움이 필요합니다</b>
|
<b>이 README, <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">RustDesk UI</a> 및 <a href="https://github.com/rustdesk/doc.rustdesk.com">RustDesk 문서</a>를 귀하의 모국어로 번역하는 데 도움이 필요합니다</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ Sciter 동적 라이브러리를 직접 다운로드하세요.
|
|||||||
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
|
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
|
||||||
[macOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib)
|
[macOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib)
|
||||||
|
|
||||||
## 빌드를 위한 원시 단계
|
## 빌드를_위한_원시_단계
|
||||||
|
|
||||||
- Rust 개발 환경과 C++ 빌드 환경을 준비합니다
|
- Rust 개발 환경과 C++ 빌드 환경 준비
|
||||||
|
|
||||||
- [vcpkg](https://github.com/microsoft/vcpkg)를 설치하고 `VCPKG_ROOT` 환경 변수를 올바르게 설정합니다
|
- [vcpkg](https://github.com/microsoft/vcpkg)를 설치하고 `VCPKG_ROOT` 환경 변수를 올바르게 설정합니다
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ mv libsciter-gtk.so target/debug
|
|||||||
VCPKG_ROOT=$HOME/vcpkg cargo run
|
VCPKG_ROOT=$HOME/vcpkg cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
## Docker로 빌드하는 방법
|
## Docker로_빌드하는_방법
|
||||||
|
|
||||||
먼저 리포지토리를 복제하고 Docker 컨테이너를 빌드합니다:
|
먼저 리포지토리를 복제하고 Docker 컨테이너를 빌드합니다:
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ target/release/rustdesk
|
|||||||
|
|
||||||
RustDesk 리포지토리의 루트에서 이러한 명령을 실행하고 있는지 확인하세요. 그렇지 않으면 응용 프로그램이 필요한 리소스를 찾지 못할 수 있습니다. 또한 `install` 또는 `run` 과 같은 다른 cargo 하위 명령은 호스트가 아닌 컨테이너 내부에 프로그램을 설치하거나 실행하므로 현재 이 방법을 통해 지원되지 않는다는 점에 유의하세요.
|
RustDesk 리포지토리의 루트에서 이러한 명령을 실행하고 있는지 확인하세요. 그렇지 않으면 응용 프로그램이 필요한 리소스를 찾지 못할 수 있습니다. 또한 `install` 또는 `run` 과 같은 다른 cargo 하위 명령은 호스트가 아닌 컨테이너 내부에 프로그램을 설치하거나 실행하므로 현재 이 방법을 통해 지원되지 않는다는 점에 유의하세요.
|
||||||
|
|
||||||
## 파일 구조
|
## 파일_구조
|
||||||
|
|
||||||
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: 비디오 코덱, 구성, tcp/udp wrapper, protobuf, 파일 전송을 위한 fs 함수 및 기타 유틸리티 함수
|
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: 비디오 코덱, 구성, tcp/udp wrapper, protobuf, 파일 전송을 위한 fs 함수 및 기타 유틸리티 함수
|
||||||
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: 화면 캡쳐
|
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: 화면 캡쳐
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ Porozmawiaj z nami na: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](http
|
|||||||
|
|
||||||
[](https://rustdesk.com/pricing.html)
|
[](https://rustdesk.com/pricing.html)
|
||||||
|
|
||||||
Kolejny program do zdalnego pulpitu, napisany w Rust. Działa od samego początku, nie wymaga konfiguracji. Masz pełną kontrolę nad swoimi danymi, bez obaw o bezpieczeństwo. Możesz skorzystać z naszego darmowego serwera publicznego, [skonfigurować własny](https://rustdesk.com/server), lub [napisać własny serwer](https://github.com/rustdesk/rustdesk-server-demo).
|
## O projekcie
|
||||||
|
|
||||||
|
RustDesk to wieloplatformowe oprogramowanie do zdalnego pulpitu, napisane w języku Rust, zaprojektowane z myślą o prostocie wdrożenia, bezpieczeństwie i pełnej kontroli użytkownika nad danymi. Aplikacja działa od razu po uruchomieniu i nie wymaga skomplikowanej konfiguracji. Możesz skorzystać z naszego darmowego serwera publicznego, [skonfigurować własny](https://rustdesk.com/server), lub [napisać własny serwer](https://github.com/rustdesk/rustdesk-server-demo).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ RustDesk zaprasza do współpracy każdego. Zobacz [`docs/CONTRIBUTING-PL.md`](C
|
|||||||
|
|
||||||
## Zależności
|
## Zależności
|
||||||
|
|
||||||
Wersje desktopowe używają [sciter](https://sciter.com/) dla GUI, proszę pobrać samodzielnie bibliotekę sciter.
|
Wersje desktopowe korzystają z biblioteki [sciter](https://sciter.com/) jako silnika GUI. Bibliotekę Sciter należy pobrać i zainstalować samodzielnie.
|
||||||
|
|
||||||
[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) |
|
[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) |
|
||||||
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
|
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
|
||||||
|
|||||||
@@ -1,55 +1,82 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="../res/logo-header.svg" alt="RustDesk - Seu desktop remoto"><br>
|
<img src="../res/logo-header.svg" alt="RustDesk - Seu desktop remoto"><br>
|
||||||
<a href="#servidores-públicos-grátis">Servidores</a> •
|
<a href="#compilar">Compilar</a> •
|
||||||
<a href="#compilação-crua">Compilar</a> •
|
<a href="#como-compilar-com-o-docker">Docker</a> •
|
||||||
<a href="#como-compilar-com-docker">Docker</a> •
|
|
||||||
<a href="#estrutura-de-arquivos">Estrutura</a> •
|
<a href="#estrutura-de-arquivos">Estrutura</a> •
|
||||||
<a href="#screenshots">Screenshots</a><br>
|
<a href="#capturas-de-tela">Capturas de Tela</a><br>
|
||||||
[<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-IT.md">Italiano</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-VN.md">Tiếng Việt</a>] | [<a href="README-GR.md">Ελληνικά</a>]<br>
|
[<a href="../README.md">Inglês</a>] | [<a href="docs/README-UA.md">Ucraniano</a>] | [<a href="docs/README-CS.md">Tcheco</a>] | [<a href="docs/README-ZH.md">Chinês</a>] | [<a href="docs/README-HU.md">Húngaro</a>] | [<a href="docs/README-ES.md">Espanhol</a>] | [<a href="docs/README-FA.md">Persa</a>] | [<a href="docs/README-FR.md">Francês</a>] | [<a href="docs/README-DE.md">Alemão</a>] | [<a href="docs/README-PL.md">Polonês</a>] | [<a href="docs/README-ID.md">Indonésio</a>] | [<a href="docs/README-FI.md">Finlandês</a>] | [<a href="docs/README-ML.md">Malaiala</a>] | [<a href="docs/README-JP.md">Japonês</a>] | [<a href="docs/README-NL.md">Holandês</a>] | [<a href="docs/README-IT.md">Italiano</a>] | [<a href="docs/README-RU.md">Russo</a>] | [<a href="docs/README-EO.md">Esperanto</a>] | [<a href="docs/README-KR.md">Coreano</a>] | [<a href="docs/README-AR.md">Árabe</a>] | [<a href="docs/README-VN.md">Vietnamita</a>] | [<a href="docs/README-DA.md">Dinamarquês</a>] | [<a href="docs/README-GR.md">Grego</a>] | [<a href="docs/README-TR.md">Turco</a>] | [<a href="docs/README-NO.md">Norueguês</a>] | [<a href="docs/README-RO.md">Romeno</a>]<br>
|
||||||
<b>Precisamos de sua ajuda para traduzir este README e a <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">UI do RustDesk</a> para sua língua nativa</b>
|
<b>Precisamos da sua ajuda para traduzir este README, a <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">Interface do RustDesk</a> e a <a href="https://github.com/rustdesk/doc.rustdesk.com">Documentação do RustDesk</a> para o seu idioma nativo</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
> [!Caution]
|
||||||
|
> **Aviso de Isenção de Responsabilidade por Uso Indevido:** <br>
|
||||||
|
> Os desenvolvedores do RustDesk não toleram ou apoiam qualquer uso antiético ou ilegal deste software. O uso indevido, como acesso não autorizado, controle ou invasão de privacidade, viola estritamente nossas diretrizes. Os autores não são responsáveis por qualquer uso indevido do aplicativo.
|
||||||
|
|
||||||
|
|
||||||
Converse conosco: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](https://twitter.com/rustdesk) | [Reddit](https://www.reddit.com/r/rustdesk) | [YouTube](https://www.youtube.com/@rustdesk)
|
Converse conosco: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](https://twitter.com/rustdesk) | [Reddit](https://www.reddit.com/r/rustdesk) | [YouTube](https://www.youtube.com/@rustdesk)
|
||||||
|
|
||||||
[](https://rustdesk.com/pricing.html)
|
[](https://rustdesk.com/pricing.html)
|
||||||
|
|
||||||
Mais um software de desktop remoto, escrito em Rust. Funciona por padrão, sem necessidade de configuração. Você tem completo controle de seus dados, sem se preocupar com segurança. Você pode usar nossos servidores de rendezvous/relay, [configurar seu próprio](https://rustdesk.com/server), ou [escrever seu próprio servidor de rendezvous/relay](https://github.com/rustdesk/rustdesk-server-demo).
|
Mais uma solução de desktop remoto, escrita em Rust. Funciona imediatamente, sem necessidade de configuração. Você tem controle total dos seus dados, sem preocupações com segurança. Você pode usar nosso servidor de conexão/retransmissão (rendezvous/relay), [configurar o seu próprio](https://rustdesk.com/server) ou [escrever seu próprio servidor de conexão/retransmissão](https://github.com/rustdesk/rustdesk-server-demo).
|
||||||
|
|
||||||
RustDesk acolhe contribuições de todos. Leia [`docs/CONTRIBUTING.md`](CONTRIBUTING.md) para ver como começar.
|

|
||||||
|
|
||||||
[**DOWNLOAD DE BINÁRIOS**](https://github.com/rustdesk/rustdesk/releases)
|
O RustDesk acolhe a contribuição de todos. Veja [CONTRIBUTING.md](docs/CONTRIBUTING.md) para ajuda em como começar.
|
||||||
|
|
||||||
|
[**Perguntas Frequentes (FAQ)**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
|
||||||
|
|
||||||
|
[**DOWNLOAD DOS BINÁRIOS**](https://github.com/rustdesk/rustdesk/releases)
|
||||||
|
|
||||||
|
[**VERSÕES NIGHTLY (EM DESENVOLVIMENTO)**](https://github.com/rustdesk/rustdesk/releases/tag/nightly)
|
||||||
|
|
||||||
|
[<img src="https://f-droid.org/badge/get-it-on.png"
|
||||||
|
alt="Baixe no F-Droid"
|
||||||
|
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
|
||||||
|
[<img src="https://flathub.org/api/badge?svg&locale=en"
|
||||||
|
alt="Baixe no Flathub"
|
||||||
|
height="80">](https://flathub.org/apps/com.rustdesk.RustDesk)
|
||||||
|
|
||||||
## Dependências
|
## Dependências
|
||||||
|
|
||||||
Versões de desktop utilizam [sciter](https://sciter.com/) para a GUI, por favor baixe a biblioteca dinâmica sciter por conta própria.
|
As versões de desktop usam Flutter ou Sciter (descontinuado) para a interface gráfica (GUI). Este tutorial é apenas para o Sciter, por ser mais fácil e amigável para começar. Verifique nosso [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) para instruções de compilação da versão em Flutter.
|
||||||
|
|
||||||
|
Por favor, faça o download da biblioteca dinâmica do Sciter por conta própria.
|
||||||
|
|
||||||
[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) |
|
[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) |
|
||||||
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
|
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
|
||||||
[MacOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib)
|
[macOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib)
|
||||||
|
|
||||||
## Compilação crua
|
## Passos básicos para compilar
|
||||||
|
|
||||||
- Prepare seu ambiente de desenvolvimento Rust e ambiente de compilação C++
|
- Prepare seu ambiente de desenvolvimento Rust e o ambiente de compilação C++
|
||||||
|
|
||||||
- Instale [vcpkg](https://github.com/microsoft/vcpkg), e configure a variável de ambiente `VCPKG_ROOT` corretamente
|
- Instale o [vcpkg](https://github.com/microsoft/vcpkg) e configure a variável de ambiente `VCPKG_ROOT` corretamente
|
||||||
|
|
||||||
- Windows: vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static
|
- Windows: `vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static`
|
||||||
- Linux/MacOS: vcpkg install libvpx libyuv opus aom
|
- Linux/macOS: `vcpkg install libvpx libyuv opus aom`
|
||||||
|
|
||||||
- Execute `cargo run`
|
- Execute `cargo run`
|
||||||
|
|
||||||
## Como compilar no Linux
|
## [Compilar](https://rustdesk.com/docs/en/dev/build/)
|
||||||
|
|
||||||
|
## Como Compilar no Linux
|
||||||
|
|
||||||
### Ubuntu 18 (Debian 10)
|
### Ubuntu 18 (Debian 10)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake
|
sudo apt install -y zip g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake make libclang-dev ninja-build libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libpam0g-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### openSUSE Tumbleweed
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo zypper install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libXfixes-devel cmake alsa-lib-devel gstreamer-devel gstreamer-plugins-base-devel xdotool-devel pam-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fedora 28 (CentOS 8)
|
### Fedora 28 (CentOS 8)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libxdo-devel libXfixes-devel pulseaudio-libs-devel cmake alsa-lib-devel
|
sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libxdo-devel libXfixes-devel pulseaudio-libs-devel cmake alsa-lib-devel gstreamer1-devel gstreamer1-plugins-base-devel pam-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Arch (Manjaro)
|
### Arch (Manjaro)
|
||||||
@@ -58,7 +85,7 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-
|
|||||||
sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pipewire
|
sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pipewire
|
||||||
```
|
```
|
||||||
|
|
||||||
### Instale vcpkg
|
### Instalar o vcpkg
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/microsoft/vcpkg
|
git clone https://github.com/microsoft/vcpkg
|
||||||
@@ -70,7 +97,7 @@ export VCPKG_ROOT=$HOME/vcpkg
|
|||||||
vcpkg/vcpkg install libvpx libyuv opus aom
|
vcpkg/vcpkg install libvpx libyuv opus aom
|
||||||
```
|
```
|
||||||
|
|
||||||
### Conserte libvpx (Para o Fedora)
|
### Corrigir o libvpx (Para Fedora)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd vcpkg/buildtrees/libvpx/src
|
cd vcpkg/buildtrees/libvpx/src
|
||||||
@@ -83,12 +110,12 @@ cp libvpx.a $HOME/vcpkg/installed/x64-linux/lib/
|
|||||||
cd
|
cd
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compile
|
### Compilar
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
source $HOME/.cargo/env
|
source $HOME/.cargo/env
|
||||||
git clone https://github.com/rustdesk/rustdesk
|
git clone --recurse-submodules https://github.com/rustdesk/rustdesk
|
||||||
cd rustdesk
|
cd rustdesk
|
||||||
mkdir -p target/debug
|
mkdir -p target/debug
|
||||||
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
|
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
|
||||||
@@ -96,57 +123,57 @@ mv libsciter-gtk.so target/debug
|
|||||||
VCPKG_ROOT=$HOME/vcpkg cargo run
|
VCPKG_ROOT=$HOME/vcpkg cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
## Como compilar com Docker
|
## Como compilar com o Docker
|
||||||
|
|
||||||
Comece clonando o repositório e montando o container docker:
|
Comece clonando o repositório e construindo o contêiner Docker:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/rustdesk/rustdesk
|
git clone https://github.com/rustdesk/rustdesk
|
||||||
cd rustdesk
|
cd rustdesk
|
||||||
|
git submodule update --init --recursive
|
||||||
docker build -t "rustdesk-builder" .
|
docker build -t "rustdesk-builder" .
|
||||||
```
|
```
|
||||||
|
|
||||||
Então, sempre que precisar compilar a aplicação, execute este comando:
|
Depois, cada vez que precisar compilar o aplicativo, execute o seguinte comando:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder
|
docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder
|
||||||
```
|
```
|
||||||
|
|
||||||
Note que a primeira compilação pode demorar mais antes que as dependências sejam armazenadas em cache, as compilações subsequentes serão mais rápidas. Adicionalmente, se você precisar especificar argumentos diferentes para o comando de compilação, você pode fazê-lo ao final do comando na posição do `<OPTIONAL-ARGS>`. Por exemplo, se você gostaria de compilar uma versão de release otimizada, você executaria o comando acima seguido de `--release`. O executável gerado estará disponível no diretório alvo no seu sistema, e pode ser executado com:
|
Note que a primeira compilação pode demorar mais até que as dependências sejam armazenadas em cache; as compilações subsequentes serão mais rápidas. Além disso, se você precisar especificar argumentos diferentes para o comando de compilação, poderá fazê-lo ao final do comando na posição `<ARGUMENTOS-OPCIONAIS>`. Por exemplo, se você quiser compilar uma versão de lançamento (release) otimizada, executaria o comando acima seguido de `--release`. O executável resultante estará disponível na pasta `target` do seu sistema e pode ser executado com:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
target/debug/rustdesk
|
target/debug/rustdesk
|
||||||
```
|
```
|
||||||
|
|
||||||
Ou, se estiver rodando um executável de release:
|
Ou, se estiver executando o executável de lançamento:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
target/release/rustdesk
|
target/release/rustdesk
|
||||||
```
|
```
|
||||||
|
|
||||||
Por favor verifique que está executando estes comandos da raiz do repositório do RustDesk, senão a aplicação pode não encontrar os recursos necessários. Note também que outros subcomandos do cargo como `install` ou `run` não são suportados atualmente via este método, já que eles iriam instalar ou rodar o programa dentro do container ao invés do host.
|
Certifique-se de executar esses comandos a partir da raiz do repositório do RustDesk, do contrário o aplicativo pode não encontrar os recursos necessários. Note também que outros subcomandos do cargo, como `install` ou `run`, não são suportados atualmente por este método, pois instalariam ou executariam o programa dentro do contêiner em vez de no sistema hospedeiro.
|
||||||
|
|
||||||
## Estrutura de arquivos
|
## Estrutura de Arquivos
|
||||||
|
|
||||||
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: codec de vídeo, configurações, wrapper de tcp/udp, protobuf, funções de sistema de arquivos para transferência de arquivos, e outras funções utilitárias
|
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: codec de vídeo, configuração, encapsulador (wrapper) tcp/udp, protobuf, funções de sistema de arquivos para transferência de arquivos e algumas outras funções utilitárias.
|
||||||
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: captura de tela
|
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: captura de tela.
|
||||||
- **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: controle de teclado/mouse específico a cada plataforma
|
- **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: controle de teclado/mouse específico de cada plataforma.
|
||||||
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: GUI
|
- **[libs/clipboard](https://github.com/rustdesk/rustdesk/tree/master/libs/clipboard)**: implementação de copiar e colar arquivos para Windows, Linux e macOS.
|
||||||
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: serviços de áudio/área de transferência/entrada/vídeo, e conexões de rede
|
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: interface Sciter antiga (descontinuada).
|
||||||
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: iniciar uma conexão "peer to peer"
|
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: serviços de áudio/área de transferência/entrada/vídeo e conexões de rede.
|
||||||
- **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: Comunicação com [rustdesk-server](https://github.com/rustdesk/rustdesk-server), aguardar pela conexão remota direta (TCP hole punching) ou conexão indireta (relayed)
|
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: inicia uma conexão direta (peer connection).
|
||||||
- **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: código específico a cada plataforma
|
- **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: Comunica-se com o [rustdesk-server](https://github.com/rustdesk/rustdesk-server), aguarda por conexão remota direta (perfuração de túnel TCP / hole punching) ou retransmitida.
|
||||||
|
- **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: código específico de cada plataforma.
|
||||||
|
- **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: código Flutter para desktop e dispositivos móveis.
|
||||||
|
- **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/v1/js)**: JavaScript para o cliente web do Flutter.
|
||||||
|
|
||||||
> [!Cuidadob]
|
## Capturas de Tela
|
||||||
> **Aviso de uso indevido:** <br>
|
|
||||||
> Os desenvolvedores do RustDesk não aprovam nem apoiam qualquer uso antiético ou ilegal deste software. O uso indevido, como acesso não autorizado, controle ou invasão de privacidade, é estritamente contra nossas diretrizes. Os autores não são responsáveis por qualquer uso indevido da aplicação.
|
|
||||||
|
|
||||||
## Screenshots
|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ target/release/rustdesk
|
|||||||
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: графический пользовательский интерфейс на Sciter (устаревшее)
|
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: графический пользовательский интерфейс на Sciter (устаревшее)
|
||||||
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: сервисы аудио, буфера обмена, ввода, видео и сетевых подключений
|
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: сервисы аудио, буфера обмена, ввода, видео и сетевых подключений
|
||||||
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: одноранговое соединение
|
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: одноранговое соединение
|
||||||
- **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: связь с [сервером Rustdesk](https://github.com/rustdesk/rustdesk-server), ожидает удаленного прямого (через TCP hole punching) или ретранслируемого соединения
|
- **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: связь с [сервером RustDesk](https://github.com/rustdesk/rustdesk-server), ожидает удаленного прямого (через TCP hole punching) или ретранслируемого соединения
|
||||||
- **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: специфичный для платформы код
|
- **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: специфичный для платформы код
|
||||||
- **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: код Flutter для ПК-версии и мобильных устройств
|
- **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: код Flutter для ПК-версии и мобильных устройств
|
||||||
- **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/v1/js)**: JavaScript для Web-клиента Flutter
|
- **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/v1/js)**: JavaScript для Web-клиента Flutter
|
||||||
|
|||||||
16
docs/SECURITY-FR.md
Normal file
16
docs/SECURITY-FR.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
# Politique de sécurité
|
||||||
|
|
||||||
|
## Signaler une vulnérabilité
|
||||||
|
|
||||||
|
Nous accordons une très grande importance à la sécurité du projet. Nous
|
||||||
|
encourageons tous les utilisateurs à nous signaler toute vulnérabilité qu'ils
|
||||||
|
découvrent.
|
||||||
|
|
||||||
|
Si vous trouvez une vulnérabilité de sécurité dans le projet RustDesk, veuillez
|
||||||
|
la signaler de manière responsable en envoyant un e-mail à info@rustdesk.com.
|
||||||
|
|
||||||
|
À ce stade, nous n'avons pas de programme de bug bounty. Nous sommes une petite
|
||||||
|
équipe qui s'attaque à un grand défi. Nous vous encourageons vivement à signaler
|
||||||
|
toute vulnérabilité de manière responsable afin que nous puissions continuer à
|
||||||
|
développer une application sécurisée pour l'ensemble de la communauté.
|
||||||
@@ -33,4 +33,4 @@ if [ -z $release ]; then
|
|||||||
fi
|
fi
|
||||||
set -f
|
set -f
|
||||||
#shellcheck disable=2086
|
#shellcheck disable=2086
|
||||||
VCPKG_ROOT=/vcpkg cargo build $argv
|
VCPKG_ROOT=/vcpkg cargo build --locked $argv
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<li> Supports VP8 / VP9 / AV1 software codecs, and H264 / H265 hardware codecs. </li>
|
<li> Supports VP8 / VP9 / AV1 software codecs, and H264 / H265 hardware codecs. </li>
|
||||||
<li> Own your data, easily set up self-hosting solution on your infrastructure. </li>
|
<li> Own your data, easily set up self-hosting solution on your infrastructure. </li>
|
||||||
<li> P2P connection with end-to-end encryption based on NaCl. </li>
|
<li> P2P connection with end-to-end encryption based on NaCl. </li>
|
||||||
<li> No administrative privileges or installation needed for Windows, elevate priviledge locally or from remote on demand. </li>
|
<li> No administrative privileges or installation needed for Windows, elevate privilege locally or from remote on demand. </li>
|
||||||
<li> We like to keep things simple and will strive to make simpler where possible. </li>
|
<li> We like to keep things simple and will strive to make simpler where possible. </li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
],
|
],
|
||||||
"finish-args": [
|
"finish-args": [
|
||||||
"--share=ipc",
|
"--share=ipc",
|
||||||
|
"--socket=wayland",
|
||||||
"--socket=x11",
|
"--socket=x11",
|
||||||
"--share=network",
|
"--share=network",
|
||||||
"--filesystem=home",
|
"--filesystem=home",
|
||||||
|
|||||||
@@ -62,7 +62,13 @@ class AudioRecordHandle(private var context: Context, private var isVideoStart:
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
audioRecorder = builder.build()
|
val recorder = try {
|
||||||
|
builder.build()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(logTag, "createAudioRecorder failed", e)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
audioRecorder = recorder
|
||||||
Log.d(logTag, "createAudioRecorder done,minBufferSize:$minBufferSize")
|
Log.d(logTag, "createAudioRecorder done,minBufferSize:$minBufferSize")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,10 @@ class FloatingWindowService : Service(), View.OnTouchListener {
|
|||||||
popupMenu.menu.add(0, idSyncClipboard, 0, translate("Update client clipboard"))
|
popupMenu.menu.add(0, idSyncClipboard, 0, translate("Update client clipboard"))
|
||||||
}
|
}
|
||||||
val idStopService = 2
|
val idStopService = 2
|
||||||
popupMenu.menu.add(0, idStopService, 0, translate("Stop service"))
|
val hideStopService = FFI.getBuildinOption("hide-stop-service") == "Y"
|
||||||
|
if (!hideStopService) {
|
||||||
|
popupMenu.menu.add(0, idStopService, 0, translate("Stop service"))
|
||||||
|
}
|
||||||
popupMenu.setOnMenuItemClickListener { menuItem ->
|
popupMenu.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
idShowRustDesk -> {
|
idShowRustDesk -> {
|
||||||
@@ -389,4 +392,3 @@ class FloatingWindowService : Service(), View.OnTouchListener {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package com.carriez.flutter_hbb
|
|||||||
|
|
||||||
import android.accessibilityservice.AccessibilityService
|
import android.accessibilityservice.AccessibilityService
|
||||||
import android.accessibilityservice.GestureDescription
|
import android.accessibilityservice.GestureDescription
|
||||||
|
import android.content.Intent
|
||||||
import android.graphics.Path
|
import android.graphics.Path
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -68,6 +69,16 @@ class InputService : AccessibilityService() {
|
|||||||
get() = ctx != null
|
get() = ctx != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun notifyInputState() {
|
||||||
|
val inputState = isOpen.toString()
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
MainActivity.flutterMethodChannel?.invokeMethod(
|
||||||
|
"on_state_changed",
|
||||||
|
mapOf("name" to "input", "value" to inputState)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val logTag = "input service"
|
private val logTag = "input service"
|
||||||
private var leftIsDown = false
|
private var leftIsDown = false
|
||||||
private var touchPath = Path()
|
private var touchPath = Path()
|
||||||
@@ -716,6 +727,7 @@ class InputService : AccessibilityService() {
|
|||||||
override fun onServiceConnected() {
|
override fun onServiceConnected() {
|
||||||
super.onServiceConnected()
|
super.onServiceConnected()
|
||||||
ctx = this
|
ctx = this
|
||||||
|
notifyInputState()
|
||||||
val info = AccessibilityServiceInfo()
|
val info = AccessibilityServiceInfo()
|
||||||
if (Build.VERSION.SDK_INT >= 33) {
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
info.flags = FLAG_INPUT_METHOD_EDITOR or FLAG_RETRIEVE_INTERACTIVE_WINDOWS
|
info.flags = FLAG_INPUT_METHOD_EDITOR or FLAG_RETRIEVE_INTERACTIVE_WINDOWS
|
||||||
@@ -734,8 +746,16 @@ class InputService : AccessibilityService() {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
ctx = null
|
ctx = null
|
||||||
|
// Keep this fallback even though onUnbind usually notifies first.
|
||||||
|
notifyInputState()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onUnbind(intent: Intent?): Boolean {
|
||||||
|
ctx = null
|
||||||
|
notifyInputState()
|
||||||
|
return super.onUnbind(intent)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onInterrupt() {}
|
override fun onInterrupt() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,16 @@ class MainActivity : FlutterActivity() {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
Log.e(logTag, "onDestroy")
|
Log.e(logTag, "onDestroy")
|
||||||
|
// The process can outlive the UI whenever something keeps it alive:
|
||||||
|
// MainService, or the accessibility InputService on its own. Only the
|
||||||
|
// former gets onTaskRemoved, so close outgoing sessions here too,
|
||||||
|
// otherwise a session survives with no UI left to close it.
|
||||||
|
// `isFinishing` distinguishes the user really leaving from a destroy
|
||||||
|
// for recreation (configuration change, "don't keep activities"),
|
||||||
|
// which must not tear down a live session.
|
||||||
|
if (isFinishing) {
|
||||||
|
FFI.closeAllSessions()
|
||||||
|
}
|
||||||
mainService?.let {
|
mainService?.let {
|
||||||
unbindService(serviceConnection)
|
unbindService(serviceConnection)
|
||||||
}
|
}
|
||||||
@@ -200,12 +210,13 @@ class MainActivity : FlutterActivity() {
|
|||||||
"stop_input" -> {
|
"stop_input" -> {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
InputService.ctx?.disableSelf()
|
InputService.ctx?.disableSelf()
|
||||||
|
} else {
|
||||||
|
InputService.ctx = null
|
||||||
|
Companion.flutterMethodChannel?.invokeMethod(
|
||||||
|
"on_state_changed",
|
||||||
|
mapOf("name" to "input", "value" to InputService.isOpen.toString())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
InputService.ctx = null
|
|
||||||
Companion.flutterMethodChannel?.invokeMethod(
|
|
||||||
"on_state_changed",
|
|
||||||
mapOf("name" to "input", "value" to InputService.isOpen.toString())
|
|
||||||
)
|
|
||||||
result.success(true)
|
result.success(true)
|
||||||
}
|
}
|
||||||
"cancel_notification" -> {
|
"cancel_notification" -> {
|
||||||
|
|||||||
@@ -254,6 +254,16 @@ class MainService : Service() {
|
|||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swiping the app away from recents destroys the UI but this service keeps
|
||||||
|
// the process alive, so outgoing sessions would stay connected with no way
|
||||||
|
// to close them. Incoming connections are unaffected: the service keeps
|
||||||
|
// running so the device stays reachable.
|
||||||
|
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||||
|
Log.d(logTag, "onTaskRemoved, closing outgoing sessions")
|
||||||
|
FFI.closeAllSessions()
|
||||||
|
super.onTaskRemoved(rootIntent)
|
||||||
|
}
|
||||||
|
|
||||||
private var isHalfScale: Boolean? = null;
|
private var isHalfScale: Boolean? = null;
|
||||||
private fun updateScreenInfo(orientation: Int) {
|
private fun updateScreenInfo(orientation: Int) {
|
||||||
var w: Int
|
var w: Int
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ object FFI {
|
|||||||
external fun onAudioFrameUpdate(buf: ByteBuffer)
|
external fun onAudioFrameUpdate(buf: ByteBuffer)
|
||||||
external fun translateLocale(localeName: String, input: String): String
|
external fun translateLocale(localeName: String, input: String): String
|
||||||
external fun refreshScreen()
|
external fun refreshScreen()
|
||||||
|
external fun closeAllSessions()
|
||||||
external fun setFrameRawEnable(name: String, value: Boolean)
|
external fun setFrameRawEnable(name: String, value: Boolean)
|
||||||
external fun setCodecInfo(info: String)
|
external fun setCodecInfo(info: String)
|
||||||
external fun getLocalOption(key: String): String
|
external fun getLocalOption(key: String): String
|
||||||
|
external fun getBuildinOption(key: String): String
|
||||||
external fun onClipboardUpdate(clips: ByteBuffer)
|
external fun onClipboardUpdate(clips: ByteBuffer)
|
||||||
external fun isServiceClipboardEnabled(): Boolean
|
external fun isServiceClipboardEnabled(): Boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="199"><path fill="#0089d6" d="M118.432 187.698c32.89-5.81 60.055-10.618 60.367-10.684l.568-.12-31.052-36.935c-17.078-20.314-31.051-37.014-31.051-37.11 0-.182 32.063-88.477 32.243-88.792.06-.105 21.88 37.567 52.893 91.32 29.035 50.323 52.973 91.815 53.195 92.203l.405.707-98.684-.012-98.684-.013 59.8-10.564zM0 176.435c0-.052 14.631-25.451 32.514-56.442l32.514-56.347 37.891-31.799C123.76 14.358 140.867.027 140.935.001c.069-.026-.205.664-.609 1.534s-18.919 40.582-41.145 88.25l-40.41 86.67-29.386.037c-16.162.02-29.385-.005-29.385-.057z"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 604 B |
1
flutter/assets/auth-microsoft.svg
Normal file
1
flutter/assets/auth-microsoft.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="4" width="19" height="19" fill="#f25022"/><rect x="25" y="4" width="19" height="19" fill="#7fba00"/><rect x="4" y="25" width="19" height="19" fill="#00a4ef"/><rect x="25" y="25" width="19" height="19" fill="#ffb900"/></svg>
|
||||||
|
After Width: | Height: | Size: 321 B |
7
flutter/assets/display_switcher.svg
Normal file
7
flutter/assets/display_switcher.svg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g fill="#000000" fill-rule="evenodd">
|
||||||
|
<rect x="4" y="6" width="24" height="16" rx="3"/>
|
||||||
|
<rect x="14.5" y="22" width="3" height="2"/>
|
||||||
|
<rect x="9.5" y="24" width="13" height="2.5" rx="1.25"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 303 B |
@@ -6,83 +6,82 @@ ANDROID_ABI=$1
|
|||||||
|
|
||||||
# Build RustDesk dependencies for Android using vcpkg.json
|
# Build RustDesk dependencies for Android using vcpkg.json
|
||||||
# Required:
|
# Required:
|
||||||
# 1. set VCPKG_ROOT / ANDROID_NDK path environment variables
|
# 1. set VCPKG_ROOT / ANDROID_NDK_HOME path environment variables
|
||||||
# 2. vcpkg initialized
|
# 2. vcpkg initialized
|
||||||
# 3. ndk, version: r25c or newer
|
# 3. ndk, version: r25c or newer
|
||||||
|
|
||||||
if [ -z "$ANDROID_NDK_HOME" ]; then
|
if [ -z "${ANDROID_NDK_HOME}" ]; then
|
||||||
echo "Failed! Please set ANDROID_NDK_HOME"
|
echo "ERROR: Please set ANDROID_NDK_HOME environment variable" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$VCPKG_ROOT" ]; then
|
if [ -z "${VCPKG_ROOT}" ]; then
|
||||||
echo "Failed! Please set VCPKG_ROOT"
|
echo "ERROR: Please set VCPKG_ROOT environment variable" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
API_LEVEL="21"
|
case "${ANDROID_ABI}" in
|
||||||
|
arm64-v8a)
|
||||||
|
VCPKG_TARGET=arm64-android
|
||||||
|
;;
|
||||||
|
armeabi-v7a)
|
||||||
|
VCPKG_TARGET=arm-neon-android
|
||||||
|
;;
|
||||||
|
x86_64)
|
||||||
|
VCPKG_TARGET=x64-android
|
||||||
|
;;
|
||||||
|
x86)
|
||||||
|
VCPKG_TARGET=x86-android
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: build_android_deps.sh <arm64-v8a|armeabi-v7a|x86_64|x86>" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Get directory of this script
|
# Get directory of this script
|
||||||
|
|
||||||
SCRIPTDIR="$(readlink -f "$0")"
|
SCRIPTDIR="$(readlink -f "$0")"
|
||||||
SCRIPTDIR="$(dirname "$SCRIPTDIR")"
|
SCRIPTDIR="$(dirname "${SCRIPTDIR}")"
|
||||||
|
|
||||||
# Check if vcpkg.json is one level up - in root directory of RD
|
# Check if vcpkg.json is one level up - in root directory of RD
|
||||||
|
|
||||||
if [ ! -f "$SCRIPTDIR/../vcpkg.json" ]; then
|
if [ ! -f "${SCRIPTDIR}/../vcpkg.json" ]; then
|
||||||
echo "Failed! Please check where vcpkg.json is!"
|
echo "ERROR: Can not find vcpkg.json in RustDesk top-level directory" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# NDK llvm toolchain
|
echo "INFO: Building and install vcpkg dependencies for Android ${ANDROID_ABI} ..."
|
||||||
|
|
||||||
HOST_TAG="linux-x86_64" # current platform, set as `ls $ANDROID_NDK/toolchains/llvm/prebuilt/`
|
pushd "${SCRIPTDIR}/.."
|
||||||
TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST_TAG
|
|
||||||
|
|
||||||
function build {
|
"${VCPKG_ROOT}/vcpkg" install \
|
||||||
ANDROID_ABI=$1
|
--triplet "${VCPKG_TARGET}" \
|
||||||
|
--x-install-root="${VCPKG_ROOT}/installed"
|
||||||
|
|
||||||
case "$ANDROID_ABI" in
|
popd
|
||||||
arm64-v8a)
|
|
||||||
ABI=aarch64-linux-android$API_LEVEL
|
|
||||||
VCPKG_TARGET=arm64-android
|
|
||||||
;;
|
|
||||||
armeabi-v7a)
|
|
||||||
ABI=armv7a-linux-androideabi$API_LEVEL
|
|
||||||
VCPKG_TARGET=arm-neon-android
|
|
||||||
;;
|
|
||||||
x86_64)
|
|
||||||
ABI=x86_64-linux-android$API_LEVEL
|
|
||||||
VCPKG_TARGET=x64-android
|
|
||||||
;;
|
|
||||||
x86)
|
|
||||||
ABI=i686-linux-android$API_LEVEL
|
|
||||||
VCPKG_TARGET=x86-android
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "ERROR: ANDROID_ABI must be one of: arm64-v8a, armeabi-v7a, x86_64, x86" >&2
|
|
||||||
return 1
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "*** [$ANDROID_ABI][Start] Build and install vcpkg dependencies"
|
echo "INFO: Completed building vcpkg dependencies for Android ${ANDROID_ABI}"
|
||||||
pushd "$SCRIPTDIR/.."
|
|
||||||
$VCPKG_ROOT/vcpkg install --triplet $VCPKG_TARGET --x-install-root="$VCPKG_ROOT/installed"
|
|
||||||
popd
|
|
||||||
head -n 100 "${VCPKG_ROOT}/buildtrees/ffmpeg/build-$VCPKG_TARGET-rel-out.log" || true
|
|
||||||
echo "*** [$ANDROID_ABI][Finished] Build and install vcpkg dependencies"
|
|
||||||
|
|
||||||
if [ -d "$VCPKG_ROOT/installed/arm-neon-android" ]; then
|
if [ "${ANDROID_ABI}" = 'armeabi-v7a' ]; then
|
||||||
echo "*** [Start] Move arm-neon-android to arm-android"
|
# Symlink arm-neon-android to arm-android because cargo-ndk does not
|
||||||
|
# understand NEON suffix.
|
||||||
|
|
||||||
mv "$VCPKG_ROOT/installed/arm-neon-android" "$VCPKG_ROOT/installed/arm-android"
|
if [ -d "${VCPKG_ROOT}/installed/arm-neon-android" ]; then
|
||||||
|
echo 'INFO: Symlinking arm-neon-android to arm-android'
|
||||||
|
|
||||||
echo "*** [Finished] Move arm-neon-android to arm-android"
|
ln -sf \
|
||||||
fi
|
"${VCPKG_ROOT}/installed/arm-neon-android" \
|
||||||
}
|
"${VCPKG_ROOT}/installed/arm-android"
|
||||||
|
|
||||||
if [ ! -z "$ANDROID_ABI" ]; then
|
echo 'INFO: Symlinked arm-neon-android to arm-android'
|
||||||
build "$ANDROID_ABI"
|
else
|
||||||
else
|
cat 0<<.a
|
||||||
echo "Usage: build-android-deps.sh <ANDROID-ABI>" >&2
|
ERROR: 'vcpkg install' seem to complete successfully but
|
||||||
exit 1
|
directory '${VCPKG_ROOT}/installed/arm-neon-android' is missing!
|
||||||
|
|
||||||
|
.a
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
# 2024, Vasyl Gello <vasek.gello@gmail.com>
|
# 2024, Vasyl Gello <vasek.gello@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# The script is invoked by F-Droid builder system ste-by-step.
|
# The script is invoked by F-Droid builder system step-by-step.
|
||||||
#
|
#
|
||||||
# It accepts the following arguments:
|
# It accepts the following arguments:
|
||||||
#
|
#
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
# - Android architecture to build APK for: armeabi-v7a arm64-v8av x86 x86_64
|
# - Android architecture to build APK for: armeabi-v7a arm64-v8av x86 x86_64
|
||||||
# - The build step to execute:
|
# - The build step to execute:
|
||||||
#
|
#
|
||||||
# + sudo-deps: as root, install needed Debian packages into builder VM
|
|
||||||
# + prebuild: patch sources and do other stuff before the build
|
# + prebuild: patch sources and do other stuff before the build
|
||||||
# + build: perform actual build of APK file
|
# + build: perform actual build of APK file
|
||||||
#
|
#
|
||||||
@@ -184,13 +183,9 @@ prebuild)
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Map NDK version to revision
|
# Map NDK version to revision
|
||||||
|
NDK_VERSION="$(curl https://gitlab.com/fdroid/android-sdk-transparency-log/-/raw/master/signed/checksums.json |
|
||||||
NDK_VERSION="$(wget \
|
jq -r ".\"https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip\"[0].\"source.properties\"" |
|
||||||
-qO- \
|
sed -n -E 's/.*Pkg.Revision = ([0-9.]+).*/\1/p')"
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
'https://api.github.com/repos/android/ndk/releases' |
|
|
||||||
jq -r ".[] | select(.tag_name == \"${NDK_VERSION}\") | .body | match(\"ndkVersion \\\"(.*)\\\"\").captures[0].string")"
|
|
||||||
|
|
||||||
if [ -z "${NDK_VERSION}" ]; then
|
if [ -z "${NDK_VERSION}" ]; then
|
||||||
echo "ERROR: Can not map Android NDK codename to revision!" >&2
|
echo "ERROR: Can not map Android NDK codename to revision!" >&2
|
||||||
@@ -316,6 +311,18 @@ prebuild)
|
|||||||
# `FLUTTER_BRIDGE_VERSION` an restore the pubspec later
|
# `FLUTTER_BRIDGE_VERSION` an restore the pubspec later
|
||||||
|
|
||||||
if [ "${FLUTTER_VERSION}" != "${FLUTTER_BRIDGE_VERSION}" ]; then
|
if [ "${FLUTTER_VERSION}" != "${FLUTTER_BRIDGE_VERSION}" ]; then
|
||||||
|
# Find first libclang.so and set BRIDGE_LLVM_PATH
|
||||||
|
|
||||||
|
BRIDGE_LLVM_PATH="$(find /usr/lib/ -name libclang.so | head -n1)"
|
||||||
|
|
||||||
|
if [ -z "${BRIDGE_LLVM_PATH}" ]; then
|
||||||
|
echo 'ERROR: Can not find libclang.so for bridge generator!' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BRIDGE_LLVM_PATH="$(dirname "${BRIDGE_LLVM_PATH}")"
|
||||||
|
BRIDGE_LLVM_PATH="$(dirname "${BRIDGE_LLVM_PATH}")"
|
||||||
|
|
||||||
# Install Flutter bridge version
|
# Install Flutter bridge version
|
||||||
|
|
||||||
prepare_flutter "${FLUTTER_BRIDGE_VERSION}" "${HOME}/flutter"
|
prepare_flutter "${FLUTTER_BRIDGE_VERSION}" "${HOME}/flutter"
|
||||||
@@ -344,7 +351,8 @@ prebuild)
|
|||||||
|
|
||||||
flutter_rust_bridge_codegen \
|
flutter_rust_bridge_codegen \
|
||||||
--rust-input ./src/flutter_ffi.rs \
|
--rust-input ./src/flutter_ffi.rs \
|
||||||
--dart-output ./flutter/lib/generated_bridge.dart
|
--dart-output ./flutter/lib/generated_bridge.dart \
|
||||||
|
--llvm-path "${BRIDGE_LLVM_PATH}"
|
||||||
|
|
||||||
# Add bridge files to save-list
|
# Add bridge files to save-list
|
||||||
|
|
||||||
@@ -355,13 +363,15 @@ prebuild)
|
|||||||
git checkout '*'
|
git checkout '*'
|
||||||
git clean -dffx
|
git clean -dffx
|
||||||
git reset
|
git reset
|
||||||
|
|
||||||
|
unset BRIDGE_LLVM_PATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Flutter version for RustDesk library build
|
# Install Flutter version for RustDesk library build
|
||||||
|
|
||||||
prepare_flutter "${FLUTTER_VERSION}" "${HOME}/flutter"
|
prepare_flutter "${FLUTTER_VERSION}" "${HOME}/flutter"
|
||||||
|
|
||||||
# gms is not in thoes files now, but we still keep the following line for future reference(maybe).
|
# gms is not in these files now, but we still keep the following line for future reference(maybe).
|
||||||
|
|
||||||
sed \
|
sed \
|
||||||
-i \
|
-i \
|
||||||
@@ -414,13 +424,9 @@ build)
|
|||||||
.github/workflows/flutter-build.yml)"
|
.github/workflows/flutter-build.yml)"
|
||||||
|
|
||||||
# Map NDK version to revision
|
# Map NDK version to revision
|
||||||
|
NDK_VERSION="$(curl https://gitlab.com/fdroid/android-sdk-transparency-log/-/raw/master/signed/checksums.json |
|
||||||
NDK_VERSION="$(wget \
|
jq -r ".\"https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip\"[0].\"source.properties\"" |
|
||||||
-qO- \
|
sed -n -E 's/.*Pkg.Revision = ([0-9.]+).*/\1/p')"
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
'https://api.github.com/repos/android/ndk/releases' |
|
|
||||||
jq -r ".[] | select(.tag_name == \"${NDK_VERSION}\") | .body | match(\"ndkVersion \\\"(.*)\\\"\").captures[0].string")"
|
|
||||||
|
|
||||||
if [ -z "${NDK_VERSION}" ]; then
|
if [ -z "${NDK_VERSION}" ]; then
|
||||||
echo "ERROR: Can not map Android NDK codename to revision!" >&2
|
echo "ERROR: Can not map Android NDK codename to revision!" >&2
|
||||||
@@ -454,6 +460,7 @@ build)
|
|||||||
--target "${RUST_TARGET}" \
|
--target "${RUST_TARGET}" \
|
||||||
--bindgen \
|
--bindgen \
|
||||||
build \
|
build \
|
||||||
|
--locked \
|
||||||
--release \
|
--release \
|
||||||
--features "${RUSTDESK_FEATURES}"
|
--features "${RUSTDESK_FEATURES}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CLIENT_ID</key>
|
|
||||||
<string>768133699366-k1rn3ls1u2n3nklmgd9t4cmpdob0c8bn.apps.googleusercontent.com</string>
|
|
||||||
<key>REVERSED_CLIENT_ID</key>
|
|
||||||
<string>com.googleusercontent.apps.768133699366-k1rn3ls1u2n3nklmgd9t4cmpdob0c8bn</string>
|
|
||||||
<key>API_KEY</key>
|
|
||||||
<string>AIzaSyCf57HjCwSokt91CqFI0Mwf8D--ek0jvfc</string>
|
|
||||||
<key>GCM_SENDER_ID</key>
|
|
||||||
<string>768133699366</string>
|
|
||||||
<key>PLIST_VERSION</key>
|
|
||||||
<string>1</string>
|
|
||||||
<key>BUNDLE_ID</key>
|
|
||||||
<string>com.carriez.flutterHbb</string>
|
|
||||||
<key>PROJECT_ID</key>
|
|
||||||
<string>rustdesk</string>
|
|
||||||
<key>STORAGE_BUCKET</key>
|
|
||||||
<string>rustdesk.appspot.com</string>
|
|
||||||
<key>IS_ADS_ENABLED</key>
|
|
||||||
<false></false>
|
|
||||||
<key>IS_ANALYTICS_ENABLED</key>
|
|
||||||
<false></false>
|
|
||||||
<key>IS_APPINVITE_ENABLED</key>
|
|
||||||
<true></true>
|
|
||||||
<key>IS_GCM_ENABLED</key>
|
|
||||||
<true></true>
|
|
||||||
<key>IS_SIGNIN_ENABLED</key>
|
|
||||||
<true></true>
|
|
||||||
<key>GOOGLE_APP_ID</key>
|
|
||||||
<string>1:768133699366:ios:c33078a6181b9d507993e7</string>
|
|
||||||
<key>DATABASE_URL</key>
|
|
||||||
<string>https://rustdesk.firebaseio.com</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cargo build --features flutter,hwcodec --release --target aarch64-apple-ios --lib
|
cargo build --locked --features flutter,hwcodec --release --target aarch64-apple-ios --lib
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cargo build --features flutter --release --target x86_64-apple-ios --lib
|
cargo build --locked --features flutter --release --target x86_64-apple-ios --lib
|
||||||
|
|||||||
@@ -716,6 +716,17 @@ closeConnection({String? id}) {
|
|||||||
stateGlobal.isInMainPage = true;
|
stateGlobal.isInMainPage = true;
|
||||||
} else {
|
} else {
|
||||||
final controller = Get.find<DesktopTabController>();
|
final controller = Get.find<DesktopTabController>();
|
||||||
|
if (controller.tabType == DesktopTabType.terminal &&
|
||||||
|
controller.onCloseWindow != null) {
|
||||||
|
// Terminal windows are scoped to one peer. The optional id passed to
|
||||||
|
// closeConnection() is that peer id, not a terminal tab key
|
||||||
|
// (${peerId}_${terminalId}). Closing from terminal dialogs should close
|
||||||
|
// the peer's whole terminal window, including all terminal tabs.
|
||||||
|
unawaited(controller.onCloseWindow!().catchError((e, _) {
|
||||||
|
debugPrint('[closeConnection] Failed to close terminal window: $e');
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
controller.closeBy(id);
|
controller.closeBy(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1124,18 +1135,23 @@ class CustomAlertDialog extends StatelessWidget {
|
|||||||
|
|
||||||
Widget createDialogContent(String text) {
|
Widget createDialogContent(String text) {
|
||||||
final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
|
final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
|
||||||
|
bool hasLink = linkRegExp.hasMatch(text);
|
||||||
|
|
||||||
|
// Early return: no link, use default theme color
|
||||||
|
if (!hasLink) {
|
||||||
|
return SelectableText(text, style: const TextStyle(fontSize: 15));
|
||||||
|
}
|
||||||
|
|
||||||
final List<TextSpan> spans = [];
|
final List<TextSpan> spans = [];
|
||||||
int start = 0;
|
int start = 0;
|
||||||
bool hasLink = false;
|
|
||||||
|
|
||||||
linkRegExp.allMatches(text).forEach((match) {
|
linkRegExp.allMatches(text).forEach((match) {
|
||||||
hasLink = true;
|
|
||||||
if (match.start > start) {
|
if (match.start > start) {
|
||||||
spans.add(TextSpan(text: text.substring(start, match.start)));
|
spans.add(TextSpan(text: text.substring(start, match.start)));
|
||||||
}
|
}
|
||||||
spans.add(TextSpan(
|
spans.add(TextSpan(
|
||||||
text: match.group(0) ?? '',
|
text: match.group(0) ?? '',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
decoration: TextDecoration.underline,
|
decoration: TextDecoration.underline,
|
||||||
),
|
),
|
||||||
@@ -1153,13 +1169,9 @@ Widget createDialogContent(String text) {
|
|||||||
spans.add(TextSpan(text: text.substring(start)));
|
spans.add(TextSpan(text: text.substring(start)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasLink) {
|
|
||||||
return SelectableText(text, style: const TextStyle(fontSize: 15));
|
|
||||||
}
|
|
||||||
|
|
||||||
return SelectableText.rich(
|
return SelectableText.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: TextStyle(color: Colors.black, fontSize: 15),
|
style: const TextStyle(fontSize: 15),
|
||||||
children: spans,
|
children: spans,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -1173,6 +1185,48 @@ void msgBox(SessionID sessionId, String type, String title, String text,
|
|||||||
VoidCallback? onSubmit,
|
VoidCallback? onSubmit,
|
||||||
int? submitTimeout}) {
|
int? submitTimeout}) {
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
|
if (type.contains('insecure-connection')) {
|
||||||
|
Future<void> closeSession() async {
|
||||||
|
await bind.sessionSetCommon(
|
||||||
|
sessionId: sessionId,
|
||||||
|
key: 'continue-insecure-connection',
|
||||||
|
value: 'N',
|
||||||
|
);
|
||||||
|
dialogManager.dismissAll();
|
||||||
|
closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
void continueSession() {
|
||||||
|
unawaited(
|
||||||
|
bind.sessionSetCommon(
|
||||||
|
sessionId: sessionId,
|
||||||
|
key: 'continue-insecure-connection',
|
||||||
|
value: 'Y',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
dialogManager.dismissAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogManager.show(
|
||||||
|
(setState, close, context) => CustomAlertDialog(
|
||||||
|
title: null,
|
||||||
|
content: SelectionArea(child: msgboxContent(type, title, text)),
|
||||||
|
actions: [
|
||||||
|
dialogButton(
|
||||||
|
'Continue',
|
||||||
|
onPressed: continueSession,
|
||||||
|
isOutline: true,
|
||||||
|
),
|
||||||
|
dialogButton('Disconnect', onPressed: closeSession),
|
||||||
|
],
|
||||||
|
onSubmit: closeSession,
|
||||||
|
onCancel: closeSession,
|
||||||
|
),
|
||||||
|
tag: '$sessionId-$type-$title-$text-$link',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Widget> buttons = [];
|
List<Widget> buttons = [];
|
||||||
bool hasOk = false;
|
bool hasOk = false;
|
||||||
submit() {
|
submit() {
|
||||||
@@ -1578,7 +1632,7 @@ bool option2bool(String option, String value) {
|
|||||||
option == kOptionForceAlwaysRelay) {
|
option == kOptionForceAlwaysRelay) {
|
||||||
res = value == "Y";
|
res = value == "Y";
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
// "" is true
|
||||||
res = value != "N";
|
res = value != "N";
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -1596,9 +1650,6 @@ String bool2option(String option, bool b) {
|
|||||||
option == kOptionForceAlwaysRelay) {
|
option == kOptionForceAlwaysRelay) {
|
||||||
res = b ? 'Y' : defaultOptionNo;
|
res = b ? 'Y' : defaultOptionNo;
|
||||||
} else {
|
} else {
|
||||||
if (option != kOptionEnableUdpPunch && option != kOptionEnableIpv6Punch) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
res = b ? 'Y' : 'N';
|
res = b ? 'Y' : 'N';
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -2367,6 +2418,19 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
|
|||||||
id = uri.path.substring("/new/".length);
|
id = uri.path.substring("/new/".length);
|
||||||
} else if (uri.authority == "config") {
|
} else if (uri.authority == "config") {
|
||||||
if (isAndroid || isIOS) {
|
if (isAndroid || isIOS) {
|
||||||
|
final allowDeepLinkServerSettings =
|
||||||
|
bind.mainGetBuildinOption(key: kOptionAllowDeepLinkServerSettings) ==
|
||||||
|
'Y';
|
||||||
|
if (!allowDeepLinkServerSettings) {
|
||||||
|
debugPrint(
|
||||||
|
"Ignore rustdesk://config because $kOptionAllowDeepLinkServerSettings is not enabled.");
|
||||||
|
// Keep the user-facing error generic; detailed rejection reason is in debug logs.
|
||||||
|
// Delay toast to avoid missing overlay during cold-start deeplink handling.
|
||||||
|
Timer(Duration(seconds: 1), () {
|
||||||
|
showToast(translate('Failed'));
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final config = uri.path.substring("/".length);
|
final config = uri.path.substring("/".length);
|
||||||
// add a timer to make showToast work
|
// add a timer to make showToast work
|
||||||
Timer(Duration(seconds: 1), () {
|
Timer(Duration(seconds: 1), () {
|
||||||
@@ -2376,11 +2440,24 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
|
|||||||
return null;
|
return null;
|
||||||
} else if (uri.authority == "password") {
|
} else if (uri.authority == "password") {
|
||||||
if (isAndroid || isIOS) {
|
if (isAndroid || isIOS) {
|
||||||
|
final allowDeepLinkPassword =
|
||||||
|
bind.mainGetBuildinOption(key: kOptionAllowDeepLinkPassword) == 'Y';
|
||||||
|
if (!allowDeepLinkPassword) {
|
||||||
|
debugPrint(
|
||||||
|
"Ignore rustdesk://password because $kOptionAllowDeepLinkPassword is not enabled.");
|
||||||
|
// Keep the user-facing error generic; detailed rejection reason is in debug logs.
|
||||||
|
// Delay toast to avoid missing overlay during cold-start deeplink handling.
|
||||||
|
Timer(Duration(seconds: 1), () {
|
||||||
|
showToast(translate('Failed'));
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final password = uri.path.substring("/".length);
|
final password = uri.path.substring("/".length);
|
||||||
if (password.isNotEmpty) {
|
if (password.isNotEmpty) {
|
||||||
Timer(Duration(seconds: 1), () async {
|
Timer(Duration(seconds: 1), () async {
|
||||||
await bind.mainSetPermanentPassword(password: password);
|
final ok =
|
||||||
showToast(translate('Successful'));
|
await bind.mainSetPermanentPasswordWithResult(password: password);
|
||||||
|
showToast(translate(ok ? 'Successful' : 'Failed'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2684,20 +2761,44 @@ class SimpleWrapper<T> {
|
|||||||
/// This manager handles multiple tabs within the same isolate.
|
/// This manager handles multiple tabs within the same isolate.
|
||||||
class WakelockManager {
|
class WakelockManager {
|
||||||
static final Set<UniqueKey> _enabledKeys = {};
|
static final Set<UniqueKey> _enabledKeys = {};
|
||||||
|
// Don't use WakelockPlus.enabled, it causes error on Android:
|
||||||
|
// Unhandled Exception: FormatException: Message corrupted
|
||||||
|
//
|
||||||
|
// On Linux, multiple enable() calls create only one inhibit, but each disable()
|
||||||
|
// only releases if _cookie != null. So we need our own _enabled state to avoid
|
||||||
|
// calling disable() when not enabled.
|
||||||
|
// See: https://github.com/fluttercommunity/wakelock_plus/blob/0c74e5bbc6aefac57b6c96bb7ef987705ed559ec/wakelock_plus/lib/src/wakelock_plus_linux_plugin.dart#L48
|
||||||
|
static bool _enabled = false;
|
||||||
|
|
||||||
static void enable(UniqueKey key) {
|
static void enable(UniqueKey key, {bool isServer = false}) {
|
||||||
if (isLinux) return;
|
// Check if we should keep awake during outgoing sessions
|
||||||
_enabledKeys.add(key);
|
if (!isServer) {
|
||||||
WakelockPlus.enable();
|
final keepAwake =
|
||||||
|
mainGetLocalBoolOptionSync(kOptionKeepAwakeDuringOutgoingSessions);
|
||||||
|
if (!keepAwake) {
|
||||||
|
return; // Don't enable wakelock if user disabled keep awake
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isDesktop) {
|
||||||
|
_enabledKeys.add(key);
|
||||||
|
}
|
||||||
|
if (!_enabled) {
|
||||||
|
_enabled = true;
|
||||||
|
WakelockPlus.enable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void disable(UniqueKey key) {
|
static void disable(UniqueKey key) {
|
||||||
if (isLinux) return;
|
if (isDesktop) {
|
||||||
if (_enabledKeys.remove(key)) {
|
_enabledKeys.remove(key);
|
||||||
if (_enabledKeys.isEmpty) {
|
if (_enabledKeys.isNotEmpty) {
|
||||||
WakelockPlus.disable();
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_enabled) {
|
||||||
|
WakelockPlus.disable();
|
||||||
|
_enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3023,6 +3124,15 @@ void onCopyFingerprint(String value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onCopyId(String value) {
|
||||||
|
if (value.isNotEmpty) {
|
||||||
|
Clipboard.setData(ClipboardData(text: value));
|
||||||
|
showToast('$value\n${translate("Copied")}');
|
||||||
|
} else {
|
||||||
|
showToast(translate("Invalid ID"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> callMainCheckSuperUserPermission() async {
|
Future<bool> callMainCheckSuperUserPermission() async {
|
||||||
bool checked = await bind.mainCheckSuperUserPermission();
|
bool checked = await bind.mainCheckSuperUserPermission();
|
||||||
if (isMacOS) {
|
if (isMacOS) {
|
||||||
@@ -3041,6 +3151,11 @@ Future<void> start_service(bool is_start) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> canBeBlocked() async {
|
Future<bool> canBeBlocked() async {
|
||||||
|
if (isWeb) {
|
||||||
|
// Web can only act as a controller, never as a controlled side,
|
||||||
|
// so it should never be blocked by a remote session.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// First check control permission
|
// First check control permission
|
||||||
final controlPermission = await bind.mainGetCommon(
|
final controlPermission = await bind.mainGetCommon(
|
||||||
key: "is-remote-modify-enabled-by-control-permissions");
|
key: "is-remote-modify-enabled-by-control-permissions");
|
||||||
@@ -3286,7 +3401,12 @@ Future<List<Rect>> getScreenRectList() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi,
|
openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi,
|
||||||
{bool updateCursorPos = true}) {
|
{bool updateCursorPos = true, bool recordSelection = true}) {
|
||||||
|
if (recordSelection) {
|
||||||
|
ffi.ffiModel.lastUserDisplay = i;
|
||||||
|
ffi.ffiModel.cancelPendingRestoreTimer();
|
||||||
|
ffi.ffiModel.pendingMonitorRestore = null;
|
||||||
|
}
|
||||||
final displays = i == kAllDisplayValue
|
final displays = i == kAllDisplayValue
|
||||||
? List.generate(pi.displays.length, (index) => index)
|
? List.generate(pi.displays.length, (index) => index)
|
||||||
: [i];
|
: [i];
|
||||||
@@ -3649,14 +3769,54 @@ Widget loadPowered(BuildContext context) {
|
|||||||
).marginOnly(top: 6);
|
).marginOnly(top: 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// max 300 x 60
|
const _kDefaultLogoAsset = 'assets/logo.png';
|
||||||
Widget loadLogo() {
|
const _kLightLogoAsset = 'assets/logo_light.png';
|
||||||
return FutureBuilder<ByteData>(
|
const _kDarkLogoAsset = 'assets/logo_dark.png';
|
||||||
future: rootBundle.load('assets/logo.png'),
|
|
||||||
builder: (BuildContext context, AsyncSnapshot<ByteData> snapshot) {
|
List<String> _logoAssetCandidatesForBrightness(Brightness brightness) {
|
||||||
if (snapshot.hasData) {
|
return brightness == Brightness.dark
|
||||||
|
? [_kDarkLogoAsset, _kDefaultLogoAsset]
|
||||||
|
: [_kLightLogoAsset, _kDefaultLogoAsset];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> _resolveLogoAsset(Brightness brightness) async {
|
||||||
|
for (final asset in _logoAssetCandidatesForBrightness(brightness)) {
|
||||||
|
try {
|
||||||
|
await rootBundle.load(asset);
|
||||||
|
return asset;
|
||||||
|
} on FlutterError {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Logo extends StatefulWidget {
|
||||||
|
const _Logo();
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_Logo> createState() => _LogoState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LogoState extends State<_Logo> {
|
||||||
|
final Map<Brightness, Future<String?>> _logoFutures = {};
|
||||||
|
|
||||||
|
Future<String?> _logoFutureFor(Brightness brightness) {
|
||||||
|
return _logoFutures.putIfAbsent(
|
||||||
|
brightness,
|
||||||
|
() => _resolveLogoAsset(brightness),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FutureBuilder<String?>(
|
||||||
|
future: _logoFutureFor(Theme.of(context).brightness),
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {
|
||||||
|
final asset = snapshot.data;
|
||||||
|
if (asset != null) {
|
||||||
final image = Image.asset(
|
final image = Image.asset(
|
||||||
'assets/logo.png',
|
asset,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
errorBuilder: (ctx, error, stackTrace) {
|
errorBuilder: (ctx, error, stackTrace) {
|
||||||
return Container();
|
return Container();
|
||||||
@@ -3668,9 +3828,14 @@ Widget loadLogo() {
|
|||||||
).marginOnly(left: 12, right: 12, top: 12);
|
).marginOnly(left: 12, right: 12, top: 12);
|
||||||
}
|
}
|
||||||
return const Offstage();
|
return const Offstage();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// max 300 x 60
|
||||||
|
Widget loadLogo() => const _Logo();
|
||||||
|
|
||||||
Widget loadIcon(double size) {
|
Widget loadIcon(double size) {
|
||||||
return Image.asset('assets/icon.png',
|
return Image.asset('assets/icon.png',
|
||||||
width: size,
|
width: size,
|
||||||
@@ -3848,6 +4013,11 @@ bool whitelistNotEmpty() {
|
|||||||
return v != '' && v != ',';
|
return v != '' && v != ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool idWhitelistNotEmpty() {
|
||||||
|
final v = bind.mainGetOptionSync(key: kOptionIdWhitelist);
|
||||||
|
return v != '' && v != ',';
|
||||||
|
}
|
||||||
|
|
||||||
// `setMovable()` is only supported on macOS.
|
// `setMovable()` is only supported on macOS.
|
||||||
//
|
//
|
||||||
// On macOS, the window can be dragged by the tab bar by default.
|
// On macOS, the window can be dragged by the tab bar by default.
|
||||||
@@ -3878,7 +4048,8 @@ Widget netWorkErrorWidget() {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(translate("network_error_tip")),
|
if (!gFFI.userModel.networkErrorFromServer.value)
|
||||||
|
Text(translate("network_error_tip")),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: gFFI.userModel.refreshCurrentUser,
|
onPressed: gFFI.userModel.refreshCurrentUser,
|
||||||
child: Text(translate("Retry")))
|
child: Text(translate("Retry")))
|
||||||
@@ -4091,3 +4262,42 @@ String mouseButtonsToPeer(int buttons) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Build an avatar widget from an avatar URL or data URI string.
|
||||||
|
/// Returns [fallback] if avatar is empty or cannot be decoded.
|
||||||
|
/// [borderRadius] defaults to [size]/2 (circle).
|
||||||
|
Widget? buildAvatarWidget({
|
||||||
|
required String avatar,
|
||||||
|
required double size,
|
||||||
|
double? borderRadius,
|
||||||
|
Widget? fallback,
|
||||||
|
}) {
|
||||||
|
final trimmed = avatar.trim();
|
||||||
|
if (trimmed.isEmpty) return fallback;
|
||||||
|
|
||||||
|
ImageProvider? imageProvider;
|
||||||
|
if (trimmed.startsWith('data:image/')) {
|
||||||
|
final comma = trimmed.indexOf(',');
|
||||||
|
if (comma > 0) {
|
||||||
|
try {
|
||||||
|
imageProvider = MemoryImage(base64Decode(trimmed.substring(comma + 1)));
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
} else if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
||||||
|
imageProvider = NetworkImage(trimmed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageProvider == null) return fallback;
|
||||||
|
|
||||||
|
final radius = borderRadius ?? size / 2;
|
||||||
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(radius),
|
||||||
|
child: Image(
|
||||||
|
image: imageProvider,
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder: (_, __, ___) => fallback ?? SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ enum UserStatus { kDisabled, kNormal, kUnverified }
|
|||||||
// Is all the fields of the user needed?
|
// Is all the fields of the user needed?
|
||||||
class UserPayload {
|
class UserPayload {
|
||||||
String name = '';
|
String name = '';
|
||||||
|
String displayName = '';
|
||||||
|
String avatar = '';
|
||||||
String email = '';
|
String email = '';
|
||||||
String note = '';
|
String note = '';
|
||||||
String? verifier;
|
String? verifier;
|
||||||
@@ -33,6 +35,8 @@ class UserPayload {
|
|||||||
|
|
||||||
UserPayload.fromJson(Map<String, dynamic> json)
|
UserPayload.fromJson(Map<String, dynamic> json)
|
||||||
: name = json['name'] ?? '',
|
: name = json['name'] ?? '',
|
||||||
|
displayName = json['display_name'] ?? '',
|
||||||
|
avatar = json['avatar'] ?? '',
|
||||||
email = json['email'] ?? '',
|
email = json['email'] ?? '',
|
||||||
note = json['note'] ?? '',
|
note = json['note'] ?? '',
|
||||||
verifier = json['verifier'],
|
verifier = json['verifier'],
|
||||||
@@ -46,6 +50,8 @@ class UserPayload {
|
|||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> map = {
|
final Map<String, dynamic> map = {
|
||||||
'name': name,
|
'name': name,
|
||||||
|
'display_name': displayName,
|
||||||
|
'avatar': avatar,
|
||||||
'status': status == UserStatus.kDisabled
|
'status': status == UserStatus.kDisabled
|
||||||
? 0
|
? 0
|
||||||
: status == UserStatus.kUnverified
|
: status == UserStatus.kUnverified
|
||||||
@@ -58,9 +64,14 @@ class UserPayload {
|
|||||||
Map<String, dynamic> toGroupCacheJson() {
|
Map<String, dynamic> toGroupCacheJson() {
|
||||||
final Map<String, dynamic> map = {
|
final Map<String, dynamic> map = {
|
||||||
'name': name,
|
'name': name,
|
||||||
|
'display_name': displayName,
|
||||||
};
|
};
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get displayNameOrName {
|
||||||
|
return displayName.trim().isEmpty ? name : displayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PeerPayload {
|
class PeerPayload {
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ class _AddressBookState extends State<AddressBook> {
|
|||||||
const LinearProgressIndicator(),
|
const LinearProgressIndicator(),
|
||||||
buildErrorBanner(context,
|
buildErrorBanner(context,
|
||||||
loading: gFFI.abModel.currentAbLoading,
|
loading: gFFI.abModel.currentAbLoading,
|
||||||
err: gFFI.abModel.currentAbPullError,
|
err: gFFI.abModel.abPullError,
|
||||||
retry: null,
|
retry: null,
|
||||||
close: () => gFFI.abModel.currentAbPullError.value = ''),
|
close: gFFI.abModel.clearPullErrors),
|
||||||
buildErrorBanner(context,
|
buildErrorBanner(context,
|
||||||
loading: gFFI.abModel.currentAbLoading,
|
loading: gFFI.abModel.currentAbLoading,
|
||||||
err: gFFI.abModel.currentAbPushError,
|
err: gFFI.abModel.currentAbPushError,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/common/formatter/id_formatter.dart';
|
import 'package:flutter_hbb/common/formatter/id_formatter.dart';
|
||||||
import '../../../models/platform_model.dart';
|
import '../../../models/platform_model.dart';
|
||||||
@@ -5,27 +8,136 @@ import 'package:flutter_hbb/models/peer_model.dart';
|
|||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/common/widgets/peer_card.dart';
|
import 'package:flutter_hbb/common/widgets/peer_card.dart';
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
List<Peer> mergeAutocompletePeers({
|
||||||
|
Iterable<Peer> addressBookPeers = const [],
|
||||||
|
Iterable<Peer> groupPeers = const [],
|
||||||
|
Iterable<Peer> lanPeers = const [],
|
||||||
|
Iterable<Peer> recentPeers = const [],
|
||||||
|
Iterable<String> restRecentPeerIds = const [],
|
||||||
|
}) {
|
||||||
|
final combinedPeers = <String, Peer>{};
|
||||||
|
|
||||||
|
void addPeer(Peer peer) {
|
||||||
|
if (peer.id.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final existingPeer = combinedPeers[peer.id];
|
||||||
|
if (existingPeer == null) {
|
||||||
|
combinedPeers[peer.id] = Peer.copy(peer);
|
||||||
|
} else if (peer.online) {
|
||||||
|
existingPeer.online = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final peer in addressBookPeers) {
|
||||||
|
addPeer(peer);
|
||||||
|
}
|
||||||
|
for (final peer in groupPeers) {
|
||||||
|
addPeer(peer);
|
||||||
|
}
|
||||||
|
for (final peer in lanPeers) {
|
||||||
|
addPeer(peer);
|
||||||
|
}
|
||||||
|
for (final peer in recentPeers) {
|
||||||
|
addPeer(peer);
|
||||||
|
}
|
||||||
|
for (final id in restRecentPeerIds) {
|
||||||
|
if (id.isNotEmpty && !combinedPeers.containsKey(id)) {
|
||||||
|
combinedPeers[id] = Peer.fromJson({'id': id});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return combinedPeers.values.toList(growable: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
bool updateAutocompletePeerOnlineStates(
|
||||||
|
List<Peer> peers, {
|
||||||
|
required Set<String> onlines,
|
||||||
|
required Set<String> offlines,
|
||||||
|
}) {
|
||||||
|
var changed = false;
|
||||||
|
for (final peer in peers) {
|
||||||
|
if (onlines.contains(peer.id)) {
|
||||||
|
if (!peer.online) {
|
||||||
|
peer.online = true;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
} else if (offlines.contains(peer.id)) {
|
||||||
|
if (peer.online) {
|
||||||
|
peer.online = false;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
List<String> autocompleteOnlineQueryIds(
|
||||||
|
Iterable<Peer> options, {
|
||||||
|
required int limit,
|
||||||
|
}) {
|
||||||
|
final ids = <String>[];
|
||||||
|
final seenIds = <String>{};
|
||||||
|
for (final peer in options) {
|
||||||
|
if (peer.id.isEmpty || seenIds.contains(peer.id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
seenIds.add(peer.id);
|
||||||
|
ids.add(peer.id);
|
||||||
|
if (ids.length >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
class AllPeersLoader {
|
class AllPeersLoader {
|
||||||
List<Peer> peers = [];
|
List<Peer> peers = [];
|
||||||
|
|
||||||
bool _isPeersLoading = false;
|
bool _isPeersLoading = false;
|
||||||
bool _isPeersLoaded = false;
|
bool _isPeersLoaded = false;
|
||||||
|
Set<String> _lastQueryOnlineIds = {};
|
||||||
|
DateTime _lastQueryOnlineTime = DateTime.fromMillisecondsSinceEpoch(0);
|
||||||
|
Timer? _queryOnlineTimer;
|
||||||
|
List<Peer> _lastQueryOnlineOptions = const [];
|
||||||
|
Set<String> _lastOnlineIds = {};
|
||||||
|
Set<String> _lastOfflineIds = {};
|
||||||
|
final Future<void> Function(List<String> ids) _queryOnlines;
|
||||||
|
final Duration _queryOnlineDebounce;
|
||||||
|
void Function(VoidCallback)? _setState;
|
||||||
|
bool _isCleared = false;
|
||||||
|
|
||||||
final String _listenerKey = 'AllPeersLoader';
|
final String _listenerKey = 'AllPeersLoader';
|
||||||
|
static const String _cbQueryOnlines = 'callback_query_onlines';
|
||||||
late void Function(VoidCallback) setState;
|
static const Duration _queryOnlineInterval = Duration(seconds: 5);
|
||||||
|
static const Duration _defaultQueryOnlineDebounce =
|
||||||
|
Duration(milliseconds: 300);
|
||||||
|
static const int _maxQueryOnlineOptions = 20;
|
||||||
|
|
||||||
bool get needLoad => !_isPeersLoaded && !_isPeersLoading;
|
bool get needLoad => !_isPeersLoaded && !_isPeersLoading;
|
||||||
bool get isPeersLoaded => _isPeersLoaded;
|
bool get isPeersLoaded => _isPeersLoaded;
|
||||||
|
|
||||||
AllPeersLoader();
|
AllPeersLoader({
|
||||||
|
@visibleForTesting Future<void> Function(List<String> ids)? queryOnlines,
|
||||||
|
@visibleForTesting Duration? queryOnlineDebounce,
|
||||||
|
}) : _queryOnlines = queryOnlines ?? ((ids) => bind.queryOnlines(ids: ids)),
|
||||||
|
_queryOnlineDebounce =
|
||||||
|
queryOnlineDebounce ?? _defaultQueryOnlineDebounce;
|
||||||
|
|
||||||
void init(void Function(VoidCallback) setState) {
|
void init(void Function(VoidCallback) setState) {
|
||||||
this.setState = setState;
|
_setState = setState;
|
||||||
|
_isCleared = false;
|
||||||
gFFI.recentPeersModel.addListener(_mergeAllPeers);
|
gFFI.recentPeersModel.addListener(_mergeAllPeers);
|
||||||
gFFI.lanPeersModel.addListener(_mergeAllPeers);
|
gFFI.lanPeersModel.addListener(_mergeAllPeers);
|
||||||
gFFI.abModel.addPeerUpdateListener(_listenerKey, _mergeAllPeers);
|
gFFI.abModel.addPeerUpdateListener(_listenerKey, _mergeAllPeers);
|
||||||
gFFI.groupModel.addPeerUpdateListener(_listenerKey, _mergeAllPeers);
|
gFFI.groupModel.addPeerUpdateListener(_listenerKey, _mergeAllPeers);
|
||||||
|
platformFFI.registerEventHandler(_cbQueryOnlines, _listenerKey,
|
||||||
|
(evt) async {
|
||||||
|
_updateOnlineState(evt);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
@@ -33,6 +145,11 @@ class AllPeersLoader {
|
|||||||
gFFI.lanPeersModel.removeListener(_mergeAllPeers);
|
gFFI.lanPeersModel.removeListener(_mergeAllPeers);
|
||||||
gFFI.abModel.removePeerUpdateListener(_listenerKey);
|
gFFI.abModel.removePeerUpdateListener(_listenerKey);
|
||||||
gFFI.groupModel.removePeerUpdateListener(_listenerKey);
|
gFFI.groupModel.removePeerUpdateListener(_listenerKey);
|
||||||
|
platformFFI.unregisterEventHandler(_cbQueryOnlines, _listenerKey);
|
||||||
|
_queryOnlineTimer?.cancel();
|
||||||
|
_lastQueryOnlineOptions = const [];
|
||||||
|
_setState = null;
|
||||||
|
_isCleared = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getAllPeers() async {
|
Future<void> getAllPeers() async {
|
||||||
@@ -59,50 +176,106 @@ class AllPeersLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _mergeAllPeers() {
|
void _mergeAllPeers() {
|
||||||
Map<String, dynamic> combinedPeers = {};
|
if (_isCleared) {
|
||||||
for (var p in gFFI.abModel.allPeers()) {
|
return;
|
||||||
if (!combinedPeers.containsKey(p.id)) {
|
|
||||||
combinedPeers[p.id] = p.toJson();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (var p in gFFI.groupModel.peers.map((e) => Peer.copy(e)).toList()) {
|
peers = mergeAutocompletePeers(
|
||||||
if (!combinedPeers.containsKey(p.id)) {
|
addressBookPeers: gFFI.abModel.allPeers(),
|
||||||
combinedPeers[p.id] = p.toJson();
|
groupPeers: gFFI.groupModel.peers,
|
||||||
}
|
lanPeers: gFFI.lanPeersModel.peers,
|
||||||
}
|
recentPeers: gFFI.recentPeersModel.peers,
|
||||||
|
restRecentPeerIds: gFFI.recentPeersModel.restPeerIds,
|
||||||
List<Peer> parsedPeers = [];
|
);
|
||||||
for (var peer in combinedPeers.values) {
|
_applyLastOnlineState(peers);
|
||||||
parsedPeers.add(Peer.fromJson(peer));
|
_scheduleSetState(() {
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> peerIds = combinedPeers.keys.toSet();
|
|
||||||
for (final peer in gFFI.lanPeersModel.peers) {
|
|
||||||
if (!peerIds.contains(peer.id)) {
|
|
||||||
parsedPeers.add(peer);
|
|
||||||
peerIds.add(peer.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final peer in gFFI.recentPeersModel.peers) {
|
|
||||||
if (!peerIds.contains(peer.id)) {
|
|
||||||
parsedPeers.add(peer);
|
|
||||||
peerIds.add(peer.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (final id in gFFI.recentPeersModel.restPeerIds) {
|
|
||||||
if (!peerIds.contains(id)) {
|
|
||||||
parsedPeers.add(Peer.fromJson({'id': id}));
|
|
||||||
peerIds.add(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
peers = parsedPeers;
|
|
||||||
setState(() {
|
|
||||||
_isPeersLoading = false;
|
_isPeersLoading = false;
|
||||||
_isPeersLoaded = true;
|
_isPeersLoaded = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _updateOnlineState(Map<String, dynamic> evt) {
|
||||||
|
if (_isCleared) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_lastOnlineIds = _splitPeerIds(evt['onlines']);
|
||||||
|
_lastOfflineIds = _splitPeerIds(evt['offlines']);
|
||||||
|
final peersChanged = _applyLastOnlineState(peers);
|
||||||
|
final optionsChanged = _applyLastOnlineState(_lastQueryOnlineOptions);
|
||||||
|
if (peersChanged || optionsChanged) {
|
||||||
|
_scheduleSetState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _scheduleSetState(VoidCallback callback) {
|
||||||
|
if (_isCleared) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final setState = _setState;
|
||||||
|
if (setState == null) {
|
||||||
|
callback();
|
||||||
|
} else {
|
||||||
|
setState(callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _applyLastOnlineState(List<Peer> peers) {
|
||||||
|
return updateAutocompletePeerOnlineStates(
|
||||||
|
peers,
|
||||||
|
onlines: _lastOnlineIds,
|
||||||
|
offlines: _lastOfflineIds,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> _splitPeerIds(dynamic ids) {
|
||||||
|
if (ids is! String || ids.isEmpty) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return ids.split(',').where((id) => id.isNotEmpty).toSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
void queryOnlines(Iterable<Peer> options) {
|
||||||
|
if (_isCleared) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_lastQueryOnlineOptions = options.toList(growable: false);
|
||||||
|
final ids = autocompleteOnlineQueryIds(
|
||||||
|
_lastQueryOnlineOptions,
|
||||||
|
limit: _maxQueryOnlineOptions,
|
||||||
|
).toSet();
|
||||||
|
_queryOnlineTimer?.cancel();
|
||||||
|
_queryOnlineTimer = null;
|
||||||
|
if (ids.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final now = DateTime.now();
|
||||||
|
if (setEquals(ids, _lastQueryOnlineIds) &&
|
||||||
|
now.difference(_lastQueryOnlineTime) < _queryOnlineInterval) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_queryOnlineTimer = Timer(_queryOnlineDebounce, () async {
|
||||||
|
try {
|
||||||
|
await _queryOnlines(ids.toList(growable: false));
|
||||||
|
if (_isCleared) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_lastQueryOnlineIds = ids;
|
||||||
|
_lastQueryOnlineTime = DateTime.now();
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('query autocomplete online state failed: $e');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
void updateOnlineStateForTesting(Map<String, dynamic> evt) {
|
||||||
|
_updateOnlineState(evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
bool applyLastOnlineStateForTesting(List<Peer> peers) {
|
||||||
|
return _applyLastOnlineState(peers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutocompletePeerTile extends StatefulWidget {
|
class AutocompletePeerTile extends StatefulWidget {
|
||||||
|
|||||||
@@ -205,6 +205,10 @@ void changeWhiteList({Function()? callback}) async {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8.0,
|
height: 8.0,
|
||||||
),
|
),
|
||||||
|
Text(translate("whitelist_cidr_tip")),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8.0,
|
||||||
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -282,6 +286,111 @@ void changeWhiteList({Function()? callback}) async {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void changeIdWhiteList({Function()? callback}) async {
|
||||||
|
final curIdWhiteList = await bind.mainGetOption(key: kOptionIdWhitelist);
|
||||||
|
var newIdWhiteListField = curIdWhiteList == defaultOptionWhitelist
|
||||||
|
? ''
|
||||||
|
: curIdWhiteList.split(',').join('\n');
|
||||||
|
var controller = TextEditingController(text: newIdWhiteListField);
|
||||||
|
var msg = "";
|
||||||
|
var isInProgress = false;
|
||||||
|
final isOptFixed = isOptionFixed(kOptionIdWhitelist);
|
||||||
|
gFFI.dialogManager.show((setState, close, context) {
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: Text(translate("ID whitelisting")),
|
||||||
|
content: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(translate("whitelist_sep")),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8.0,
|
||||||
|
),
|
||||||
|
Text(translate("id_whitelist_wildcard_tip")),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8.0,
|
||||||
|
),
|
||||||
|
Text(translate("id_whitelist_caveat_tip")),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8.0,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
maxLines: null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
errorText: msg.isEmpty ? null : translate(msg),
|
||||||
|
),
|
||||||
|
controller: controller,
|
||||||
|
enabled: !isOptFixed,
|
||||||
|
autofocus: true)
|
||||||
|
.workaroundFreezeLinuxMint(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 4.0,
|
||||||
|
),
|
||||||
|
// NOT use Offstage to wrap LinearProgressIndicator
|
||||||
|
if (isInProgress) const LinearProgressIndicator(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
dialogButton("Cancel", onPressed: close, isOutline: true),
|
||||||
|
if (!isOptFixed)
|
||||||
|
dialogButton("Clear", onPressed: () async {
|
||||||
|
await bind.mainSetOption(
|
||||||
|
key: kOptionIdWhitelist, value: defaultOptionWhitelist);
|
||||||
|
callback?.call();
|
||||||
|
close();
|
||||||
|
}, isOutline: true),
|
||||||
|
if (!isOptFixed)
|
||||||
|
dialogButton(
|
||||||
|
"OK",
|
||||||
|
onPressed: () async {
|
||||||
|
setState(() {
|
||||||
|
msg = "";
|
||||||
|
isInProgress = true;
|
||||||
|
});
|
||||||
|
newIdWhiteListField = controller.text.trim();
|
||||||
|
var newIdWhiteList = "";
|
||||||
|
if (newIdWhiteListField.isEmpty) {
|
||||||
|
// pass
|
||||||
|
} else {
|
||||||
|
final ids = newIdWhiteListField
|
||||||
|
.trim()
|
||||||
|
.split(RegExp(r"[\s,;\n]+"))
|
||||||
|
.where((e) => e.isNotEmpty)
|
||||||
|
.toList();
|
||||||
|
// Separators are handled above; allow all other Unicode characters.
|
||||||
|
for (final id in ids) {
|
||||||
|
final hasControlCharacters = id.runes.any(
|
||||||
|
(char) => char <= 0x1f || (char >= 0x7f && char <= 0x9f));
|
||||||
|
if (hasControlCharacters) {
|
||||||
|
msg = "${translate("Invalid ID")} $id";
|
||||||
|
setState(() {
|
||||||
|
isInProgress = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newIdWhiteList = ids.join(',');
|
||||||
|
}
|
||||||
|
if (newIdWhiteList.trim().isEmpty) {
|
||||||
|
newIdWhiteList = defaultOptionWhitelist;
|
||||||
|
}
|
||||||
|
await bind.mainSetOption(
|
||||||
|
key: kOptionIdWhitelist, value: newIdWhiteList);
|
||||||
|
callback?.call();
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onCancel: close,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> changeDirectAccessPort(
|
Future<String> changeDirectAccessPort(
|
||||||
String currentIP, String currentPort) async {
|
String currentIP, String currentPort) async {
|
||||||
final controller = TextEditingController(text: currentPort);
|
final controller = TextEditingController(text: currentPort);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
GestureDragStartCallback? onOneFingerPanStart;
|
GestureDragStartCallback? onOneFingerPanStart;
|
||||||
GestureDragUpdateCallback? onOneFingerPanUpdate;
|
GestureDragUpdateCallback? onOneFingerPanUpdate;
|
||||||
GestureDragEndCallback? onOneFingerPanEnd;
|
GestureDragEndCallback? onOneFingerPanEnd;
|
||||||
|
GestureDragCancelCallback? onOneFingerPanCancel;
|
||||||
|
|
||||||
// twoFingerScale : scale + pan event
|
// twoFingerScale : scale + pan event
|
||||||
GestureScaleStartCallback? onTwoFingerScaleStart;
|
GestureScaleStartCallback? onTwoFingerScaleStart;
|
||||||
@@ -169,6 +170,27 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
|
|
||||||
DragEndDetails _getDragEndDetails(ScaleEndDetails d) =>
|
DragEndDetails _getDragEndDetails(ScaleEndDetails d) =>
|
||||||
DragEndDetails(velocity: d.velocity);
|
DragEndDetails(velocity: d.velocity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void rejectGesture(int pointer) {
|
||||||
|
super.rejectGesture(pointer);
|
||||||
|
switch (_currentState) {
|
||||||
|
case GestureState.oneFingerPan:
|
||||||
|
if (onOneFingerPanCancel != null) {
|
||||||
|
onOneFingerPanCancel!();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GestureState.twoFingerScale:
|
||||||
|
// Reset scale state if needed, currently self-contained
|
||||||
|
break;
|
||||||
|
case GestureState.threeFingerVerticalDrag:
|
||||||
|
// Reset drag state if needed, currently self-contained
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_currentState = GestureState.none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HoldTapMoveGestureRecognizer extends GestureRecognizer {
|
class HoldTapMoveGestureRecognizer extends GestureRecognizer {
|
||||||
@@ -717,6 +739,7 @@ RawGestureDetector getMixinGestureDetector({
|
|||||||
GestureDragStartCallback? onOneFingerPanStart,
|
GestureDragStartCallback? onOneFingerPanStart,
|
||||||
GestureDragUpdateCallback? onOneFingerPanUpdate,
|
GestureDragUpdateCallback? onOneFingerPanUpdate,
|
||||||
GestureDragEndCallback? onOneFingerPanEnd,
|
GestureDragEndCallback? onOneFingerPanEnd,
|
||||||
|
GestureDragCancelCallback? onOneFingerPanCancel,
|
||||||
GestureScaleUpdateCallback? onTwoFingerScaleUpdate,
|
GestureScaleUpdateCallback? onTwoFingerScaleUpdate,
|
||||||
GestureScaleEndCallback? onTwoFingerScaleEnd,
|
GestureScaleEndCallback? onTwoFingerScaleEnd,
|
||||||
GestureDragUpdateCallback? onThreeFingerVerticalDragUpdate,
|
GestureDragUpdateCallback? onThreeFingerVerticalDragUpdate,
|
||||||
@@ -765,6 +788,7 @@ RawGestureDetector getMixinGestureDetector({
|
|||||||
..onOneFingerPanStart = onOneFingerPanStart
|
..onOneFingerPanStart = onOneFingerPanStart
|
||||||
..onOneFingerPanUpdate = onOneFingerPanUpdate
|
..onOneFingerPanUpdate = onOneFingerPanUpdate
|
||||||
..onOneFingerPanEnd = onOneFingerPanEnd
|
..onOneFingerPanEnd = onOneFingerPanEnd
|
||||||
|
..onOneFingerPanCancel = onOneFingerPanCancel
|
||||||
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
||||||
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
||||||
..onThreeFingerVerticalDragUpdate = onThreeFingerVerticalDragUpdate;
|
..onThreeFingerVerticalDragUpdate = onThreeFingerVerticalDragUpdate;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
|
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
|
||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:flutter_hbb/models/user_model.dart';
|
import 'package:flutter_hbb/models/user_model.dart';
|
||||||
@@ -11,6 +12,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import './dialog.dart';
|
import './dialog.dart';
|
||||||
|
import './oidc_auth_status.dart';
|
||||||
|
|
||||||
const kOpSvgList = [
|
const kOpSvgList = [
|
||||||
'github',
|
'github',
|
||||||
@@ -20,8 +22,40 @@ const kOpSvgList = [
|
|||||||
'okta',
|
'okta',
|
||||||
'facebook',
|
'facebook',
|
||||||
'azure',
|
'azure',
|
||||||
'auth0'
|
'auth0',
|
||||||
|
'microsoft'
|
||||||
];
|
];
|
||||||
|
const _requestingAccountAuth = 'Requesting account auth';
|
||||||
|
const _waitingAccountAuth = 'Waiting account auth';
|
||||||
|
|
||||||
|
class _OidcProviderBranding {
|
||||||
|
final String label;
|
||||||
|
final String iconKey;
|
||||||
|
|
||||||
|
const _OidcProviderBranding({
|
||||||
|
required this.label,
|
||||||
|
required this.iconKey,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_OidcProviderBranding _oidcProviderBranding(String op) {
|
||||||
|
switch (op.toLowerCase()) {
|
||||||
|
case 'azure':
|
||||||
|
return _OidcProviderBranding(
|
||||||
|
label: 'Microsoft',
|
||||||
|
iconKey: 'microsoft',
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return _OidcProviderBranding(
|
||||||
|
label: {
|
||||||
|
'github': 'GitHub',
|
||||||
|
'gitlab': 'GitLab',
|
||||||
|
}[op.toLowerCase()] ??
|
||||||
|
toCapitalized(op),
|
||||||
|
iconKey: op.toLowerCase(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _IconOP extends StatelessWidget {
|
class _IconOP extends StatelessWidget {
|
||||||
final String op;
|
final String op;
|
||||||
@@ -60,6 +94,7 @@ class ButtonOP extends StatelessWidget {
|
|||||||
final Color primaryColor;
|
final Color primaryColor;
|
||||||
final double height;
|
final double height;
|
||||||
final Function() onTap;
|
final Function() onTap;
|
||||||
|
final bool Function() canStartAuth;
|
||||||
|
|
||||||
const ButtonOP({
|
const ButtonOP({
|
||||||
Key? key,
|
Key? key,
|
||||||
@@ -69,32 +104,29 @@ class ButtonOP extends StatelessWidget {
|
|||||||
required this.primaryColor,
|
required this.primaryColor,
|
||||||
required this.height,
|
required this.height,
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
|
required this.canStartAuth,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final opLabel = {
|
final branding = _oidcProviderBranding(op);
|
||||||
'github': 'GitHub',
|
final buttonLabel = translate("Continue with {${branding.label}}");
|
||||||
'gitlab': 'GitLab'
|
|
||||||
}[op.toLowerCase()] ??
|
|
||||||
toCapitalized(op);
|
|
||||||
return Row(children: [
|
return Row(children: [
|
||||||
Container(
|
Container(
|
||||||
height: height,
|
height: height,
|
||||||
width: 200,
|
width: 200,
|
||||||
child: Obx(() => ElevatedButton(
|
child: Obx(() => ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: curOP.value.isEmpty || curOP.value == op
|
backgroundColor: primaryColor,
|
||||||
? primaryColor
|
|
||||||
: Colors.grey,
|
|
||||||
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
|
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
|
||||||
onPressed: curOP.value.isEmpty || curOP.value == op ? onTap : null,
|
onPressed:
|
||||||
|
curOP.value == 'rustdesk' || !canStartAuth() ? null : onTap,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 30,
|
width: 30,
|
||||||
child: _IconOP(
|
child: _IconOP(
|
||||||
op: op,
|
op: branding.iconKey,
|
||||||
icon: icon,
|
icon: icon,
|
||||||
margin: EdgeInsets.only(right: 5),
|
margin: EdgeInsets.only(right: 5),
|
||||||
),
|
),
|
||||||
@@ -102,8 +134,7 @@ class ButtonOP extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: Center(
|
child: Center(child: Text(buttonLabel)),
|
||||||
child: Text('${translate("Continue with")} $opLabel')),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -119,15 +150,120 @@ class ConfigOP {
|
|||||||
ConfigOP({required this.op, required this.icon});
|
ConfigOP({required this.op, required this.icon});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _OidcAuthController {
|
||||||
|
final RxString curOP = ''.obs;
|
||||||
|
Future<void> _pendingOperation = Future<void>.value();
|
||||||
|
int _authAttempt = 0;
|
||||||
|
bool _closed = false;
|
||||||
|
final _cancelInProgress = false.obs;
|
||||||
|
|
||||||
|
bool _isCurrent(int authAttempt, String op) {
|
||||||
|
return !_closed && authAttempt == _authAttempt && curOP.value == op;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> start(String op) {
|
||||||
|
if (!canStart()) {
|
||||||
|
return Future<bool>.value(false);
|
||||||
|
}
|
||||||
|
final authAttempt = ++_authAttempt;
|
||||||
|
curOP.value = op;
|
||||||
|
// Web auth must start during the original user gesture so popups are allowed.
|
||||||
|
if (isWeb) {
|
||||||
|
return _startWeb(authAttempt, op);
|
||||||
|
}
|
||||||
|
final completer = Completer<bool>();
|
||||||
|
_pendingOperation = _pendingOperation.then((_) async {
|
||||||
|
if (!_isCurrent(authAttempt, op)) {
|
||||||
|
completer.complete(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await bind.mainAccountAuthCancel();
|
||||||
|
if (!_isCurrent(authAttempt, op)) {
|
||||||
|
completer.complete(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await bind.mainAccountAuth(op: op, rememberMe: true);
|
||||||
|
completer.complete(_isCurrent(authAttempt, op));
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
completer.completeError(error, stackTrace);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return completer.future;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _startWeb(int authAttempt, String op) async {
|
||||||
|
await bind.mainAccountAuth(op: op, rememberMe: true);
|
||||||
|
return _isCurrent(authAttempt, op);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool canStart() {
|
||||||
|
return !_closed && !_cancelInProgress.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> cancelCurrent(String op) {
|
||||||
|
if (!canStart() || curOP.value != op) {
|
||||||
|
return Future<bool>.value(false);
|
||||||
|
}
|
||||||
|
final authAttempt = ++_authAttempt;
|
||||||
|
final completer = Completer<bool>();
|
||||||
|
_cancelInProgress.value = true;
|
||||||
|
_pendingOperation = _pendingOperation.then((_) async {
|
||||||
|
try {
|
||||||
|
await bind.mainAccountAuthCancel();
|
||||||
|
completer.complete(_isCurrent(authAttempt, op));
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
completer.completeError(error, stackTrace);
|
||||||
|
} finally {
|
||||||
|
_cancelInProgress.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return completer.future;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _cancelBackend() async {
|
||||||
|
try {
|
||||||
|
await bind.mainAccountAuthCancel();
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
debugPrint('Failed to cancel account authentication $error');
|
||||||
|
debugPrintStack(stackTrace: stackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> close() async {
|
||||||
|
if (_closed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final hasActiveOidcAuth =
|
||||||
|
curOP.value.isNotEmpty && curOP.value != 'rustdesk';
|
||||||
|
_closed = true;
|
||||||
|
_authAttempt++;
|
||||||
|
curOP.value = '';
|
||||||
|
if (hasActiveOidcAuth) {
|
||||||
|
await _cancelBackend();
|
||||||
|
}
|
||||||
|
await _pendingOperation;
|
||||||
|
if (hasActiveOidcAuth) {
|
||||||
|
await _cancelBackend();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class WidgetOP extends StatefulWidget {
|
class WidgetOP extends StatefulWidget {
|
||||||
final ConfigOP config;
|
final ConfigOP config;
|
||||||
final RxString curOP;
|
final RxString curOP;
|
||||||
final Function(Map<String, dynamic>) cbLogin;
|
final Function(Map<String, dynamic>) cbLogin;
|
||||||
|
final Future<bool> Function(String) startAuth;
|
||||||
|
final Future<bool> Function(String) cancelAuth;
|
||||||
|
final bool Function() canStartAuth;
|
||||||
const WidgetOP({
|
const WidgetOP({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.config,
|
required this.config,
|
||||||
required this.curOP,
|
required this.curOP,
|
||||||
required this.cbLogin,
|
required this.cbLogin,
|
||||||
|
required this.startAuth,
|
||||||
|
required this.cancelAuth,
|
||||||
|
required this.canStartAuth,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -138,6 +274,8 @@ class WidgetOP extends StatefulWidget {
|
|||||||
|
|
||||||
class _WidgetOPState extends State<WidgetOP> {
|
class _WidgetOPState extends State<WidgetOP> {
|
||||||
Timer? _updateTimer;
|
Timer? _updateTimer;
|
||||||
|
bool _isAuthStatusQueryInFlight = false;
|
||||||
|
int _authAttempt = 0;
|
||||||
String _stateMsg = '';
|
String _stateMsg = '';
|
||||||
String _failedMsg = '';
|
String _failedMsg = '';
|
||||||
String _url = '';
|
String _url = '';
|
||||||
@@ -148,55 +286,180 @@ class _WidgetOPState extends State<WidgetOP> {
|
|||||||
_updateTimer?.cancel();
|
_updateTimer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
_beginQueryState() {
|
_beginQueryState(int authAttempt) {
|
||||||
|
_updateTimer?.cancel();
|
||||||
|
unawaited(_runAuthStatusQuery(() => _updateState(authAttempt)));
|
||||||
_updateTimer = Timer.periodic(Duration(seconds: 1), (timer) {
|
_updateTimer = Timer.periodic(Duration(seconds: 1), (timer) {
|
||||||
_updateState();
|
unawaited(_runAuthStatusQuery(() => _updateState(authAttempt)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateState() {
|
Future<void> _runAuthStatusQuery(Future<void> Function() query) async {
|
||||||
bind.mainAccountAuthResult().then((result) {
|
if (_isAuthStatusQueryInFlight) {
|
||||||
if (result.isEmpty) {
|
return;
|
||||||
|
}
|
||||||
|
_isAuthStatusQueryInFlight = true;
|
||||||
|
try {
|
||||||
|
await query();
|
||||||
|
} finally {
|
||||||
|
_isAuthStatusQueryInFlight = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _launchAuthUrl(String url) async {
|
||||||
|
try {
|
||||||
|
final launched = await launchUrl(
|
||||||
|
Uri.parse(url),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
);
|
||||||
|
if (!launched) {
|
||||||
|
debugPrint('Failed to open OIDC authentication URL');
|
||||||
|
}
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
debugPrint(
|
||||||
|
'Failed to open OIDC authentication URL (${error.runtimeType})');
|
||||||
|
debugPrintStack(stackTrace: stackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _copyAuthUrl(String url) async {
|
||||||
|
try {
|
||||||
|
await Clipboard.setData(ClipboardData(text: url));
|
||||||
|
showToast(
|
||||||
|
translate('Copied'),
|
||||||
|
);
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
debugPrint(
|
||||||
|
'Failed to copy OIDC authentication URL (${error.runtimeType})');
|
||||||
|
debugPrintStack(stackTrace: stackTrace);
|
||||||
|
showToast(translate('Failed'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _runCurrentAuthUrlAction(
|
||||||
|
int authAttempt,
|
||||||
|
String authUrl,
|
||||||
|
Future<void> Function(String) action,
|
||||||
|
) {
|
||||||
|
if (!mounted ||
|
||||||
|
authAttempt != _authAttempt ||
|
||||||
|
widget.curOP.value != widget.config.op ||
|
||||||
|
authUrl.isEmpty ||
|
||||||
|
_url != authUrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unawaited(action(authUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _invalidateAuthAttempt() {
|
||||||
|
_authAttempt++;
|
||||||
|
_url = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isCurrentAuthAttempt(int authAttempt) {
|
||||||
|
return mounted &&
|
||||||
|
authAttempt == _authAttempt &&
|
||||||
|
widget.curOP.value == widget.config.op;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleAuthFailure(
|
||||||
|
int authAttempt,
|
||||||
|
Object error,
|
||||||
|
String operation,
|
||||||
|
) async {
|
||||||
|
debugPrint('Failed to $operation $error');
|
||||||
|
if (!_isCurrentAuthAttempt(authAttempt)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_updateTimer?.cancel();
|
||||||
|
setState(() => _failedMsg = 'Failed');
|
||||||
|
try {
|
||||||
|
final canceled = await widget.cancelAuth(widget.config.op);
|
||||||
|
if (!canceled || !_isCurrentAuthAttempt(authAttempt)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (cancelError, stackTrace) {
|
||||||
|
debugPrint('Failed to cancel account authentication $cancelError');
|
||||||
|
debugPrintStack(stackTrace: stackTrace);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_invalidateAuthAttempt();
|
||||||
|
widget.curOP.value = '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _updateState(int authAttempt) {
|
||||||
|
if (!mounted ||
|
||||||
|
authAttempt != _authAttempt ||
|
||||||
|
widget.curOP.value != widget.config.op) {
|
||||||
|
_updateTimer?.cancel();
|
||||||
|
return Future<void>.value();
|
||||||
|
}
|
||||||
|
return bind.mainAccountAuthResult().then<void>((result) {
|
||||||
|
if (!mounted ||
|
||||||
|
authAttempt != _authAttempt ||
|
||||||
|
widget.curOP.value != widget.config.op ||
|
||||||
|
result.isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final resultMap = jsonDecode(result);
|
final resultMap = jsonDecode(result);
|
||||||
if (resultMap == null) {
|
if (resultMap == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String stateMsg = resultMap['state_msg'];
|
final String backendStateMsg = resultMap['state_msg'];
|
||||||
String failedMsg = resultMap['failed_msg'];
|
String failedMsg = resultMap['failed_msg'];
|
||||||
final String? url = resultMap['url'];
|
final String? url = resultMap['url'];
|
||||||
|
final stateMsg = backendStateMsg == _requestingAccountAuth &&
|
||||||
|
(url == null || url.isEmpty)
|
||||||
|
? _waitingAccountAuth
|
||||||
|
: backendStateMsg;
|
||||||
final bool urlLaunched = (resultMap['url_launched'] as bool?) ?? false;
|
final bool urlLaunched = (resultMap['url_launched'] as bool?) ?? false;
|
||||||
final authBody = resultMap['auth_body'];
|
final authBody = resultMap['auth_body'];
|
||||||
if (_stateMsg != stateMsg || _failedMsg != failedMsg) {
|
if (authBody != null) {
|
||||||
if (_url.isEmpty && url != null && url.isNotEmpty) {
|
_updateTimer?.cancel();
|
||||||
if (!urlLaunched) {
|
_invalidateAuthAttempt();
|
||||||
launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
|
widget.curOP.value = '';
|
||||||
}
|
widget.cbLogin(authBody as Map<String, dynamic>);
|
||||||
_url = url;
|
return;
|
||||||
}
|
|
||||||
if (authBody != null) {
|
|
||||||
_updateTimer?.cancel();
|
|
||||||
widget.curOP.value = '';
|
|
||||||
widget.cbLogin(authBody as Map<String, dynamic>);
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_stateMsg = stateMsg;
|
|
||||||
_failedMsg = failedMsg;
|
|
||||||
if (failedMsg.isNotEmpty) {
|
|
||||||
widget.curOP.value = '';
|
|
||||||
_updateTimer?.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
final stateChanged = _stateMsg != stateMsg || _failedMsg != failedMsg;
|
||||||
|
final newUrl = _url.isEmpty && url != null && url.isNotEmpty ? url : null;
|
||||||
|
if (!stateChanged && newUrl == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_stateMsg = stateMsg;
|
||||||
|
_failedMsg = failedMsg;
|
||||||
|
if (newUrl != null) {
|
||||||
|
_url = newUrl;
|
||||||
|
}
|
||||||
|
if (failedMsg.isNotEmpty) {
|
||||||
|
_invalidateAuthAttempt();
|
||||||
|
widget.curOP.value = '';
|
||||||
|
_updateTimer?.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (newUrl != null && failedMsg.isEmpty && !urlLaunched) {
|
||||||
|
unawaited(_launchAuthUrl(newUrl));
|
||||||
|
}
|
||||||
|
}).catchError(
|
||||||
|
(e) => _handleAuthFailure(
|
||||||
|
authAttempt,
|
||||||
|
e,
|
||||||
|
'query account authentication',
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_resetState() {
|
int _resetState() {
|
||||||
_stateMsg = '';
|
_updateTimer?.cancel();
|
||||||
_failedMsg = '';
|
setState(() {
|
||||||
_url = '';
|
_invalidateAuthAttempt();
|
||||||
|
_stateMsg = _waitingAccountAuth;
|
||||||
|
_failedMsg = '';
|
||||||
|
});
|
||||||
|
return _authAttempt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -209,11 +472,31 @@ class _WidgetOPState extends State<WidgetOP> {
|
|||||||
icon: widget.config.icon,
|
icon: widget.config.icon,
|
||||||
primaryColor: str2color(widget.config.op, 0x7f),
|
primaryColor: str2color(widget.config.op, 0x7f),
|
||||||
height: 36,
|
height: 36,
|
||||||
|
canStartAuth: widget.canStartAuth,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
_resetState();
|
if (!widget.canStartAuth()) {
|
||||||
widget.curOP.value = widget.config.op;
|
return;
|
||||||
await bind.mainAccountAuth(op: widget.config.op, rememberMe: true);
|
}
|
||||||
_beginQueryState();
|
final authAttempt = _resetState();
|
||||||
|
try {
|
||||||
|
final started = await widget.startAuth(widget.config.op);
|
||||||
|
if (!started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
await _handleAuthFailure(
|
||||||
|
authAttempt,
|
||||||
|
e,
|
||||||
|
'start account authentication',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!mounted ||
|
||||||
|
authAttempt != _authAttempt ||
|
||||||
|
widget.curOP.value != widget.config.op) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_beginQueryState(authAttempt);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
@@ -221,55 +504,74 @@ class _WidgetOPState extends State<WidgetOP> {
|
|||||||
widget.curOP.value != widget.config.op) {
|
widget.curOP.value != widget.config.op) {
|
||||||
_failedMsg = '';
|
_failedMsg = '';
|
||||||
}
|
}
|
||||||
|
final authAttempt = _authAttempt;
|
||||||
|
final authUrl = _url;
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage:
|
offstage:
|
||||||
_failedMsg.isEmpty && widget.curOP.value != widget.config.op,
|
_failedMsg.isEmpty && widget.curOP.value != widget.config.op,
|
||||||
child: RichText(
|
child: Column(
|
||||||
text: TextSpan(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
text: '$_stateMsg ',
|
children: [
|
||||||
style:
|
if (_stateMsg.isNotEmpty && _failedMsg.isEmpty)
|
||||||
DefaultTextStyle.of(context).style.copyWith(fontSize: 12),
|
Padding(
|
||||||
children: <TextSpan>[
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
TextSpan(
|
child: OidcAuthStatus(
|
||||||
text: _failedMsg,
|
message: translate(_stateMsg),
|
||||||
style: DefaultTextStyle.of(context).style.copyWith(
|
browserFallbackPrompt: translate(
|
||||||
fontSize: 14,
|
"Browser didn't open? Use the url below to sign in.",
|
||||||
color: Colors.red,
|
),
|
||||||
),
|
authUrl: authUrl,
|
||||||
|
copyLabel: translate('Copy to clipboard'),
|
||||||
|
onCopy: authUrl.isEmpty
|
||||||
|
? null
|
||||||
|
: () => _runCurrentAuthUrlAction(
|
||||||
|
authAttempt,
|
||||||
|
authUrl,
|
||||||
|
_copyAuthUrl,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
if (_failedMsg.isNotEmpty)
|
||||||
),
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
|
child: Builder(builder: (context) {
|
||||||
|
final errorColor = Theme.of(context).colorScheme.error;
|
||||||
|
final bgColor = Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.errorContainer
|
||||||
|
.withOpacity(0.3);
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0, vertical: 6.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: bgColor,
|
||||||
|
borderRadius: BorderRadius.circular(4.0),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.error_outline,
|
||||||
|
color: errorColor, size: 16),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Flexible(
|
||||||
|
child: SelectableText(
|
||||||
|
translate(_failedMsg),
|
||||||
|
style:
|
||||||
|
DefaultTextStyle.of(context).style.copyWith(
|
||||||
|
fontSize: 13,
|
||||||
|
color: errorColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
Obx(
|
|
||||||
() => Offstage(
|
|
||||||
offstage: widget.curOP.value != widget.config.op,
|
|
||||||
child: const SizedBox(
|
|
||||||
height: 5.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => Offstage(
|
|
||||||
offstage: widget.curOP.value != widget.config.op,
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(maxHeight: 20),
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
widget.curOP.value = '';
|
|
||||||
_updateTimer?.cancel();
|
|
||||||
_resetState();
|
|
||||||
bind.mainAccountAuthCancel();
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
translate('Cancel'),
|
|
||||||
style: TextStyle(fontSize: 15),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -279,12 +581,18 @@ class LoginWidgetOP extends StatelessWidget {
|
|||||||
final List<ConfigOP> ops;
|
final List<ConfigOP> ops;
|
||||||
final RxString curOP;
|
final RxString curOP;
|
||||||
final Function(Map<String, dynamic>) cbLogin;
|
final Function(Map<String, dynamic>) cbLogin;
|
||||||
|
final Future<bool> Function(String) startAuth;
|
||||||
|
final Future<bool> Function(String) cancelAuth;
|
||||||
|
final bool Function() canStartAuth;
|
||||||
|
|
||||||
LoginWidgetOP({
|
LoginWidgetOP({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.ops,
|
required this.ops,
|
||||||
required this.curOP,
|
required this.curOP,
|
||||||
required this.cbLogin,
|
required this.cbLogin,
|
||||||
|
required this.startAuth,
|
||||||
|
required this.cancelAuth,
|
||||||
|
required this.canStartAuth,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -295,6 +603,9 @@ class LoginWidgetOP extends StatelessWidget {
|
|||||||
config: op,
|
config: op,
|
||||||
curOP: curOP,
|
curOP: curOP,
|
||||||
cbLogin: cbLogin,
|
cbLogin: cbLogin,
|
||||||
|
startAuth: startAuth,
|
||||||
|
cancelAuth: cancelAuth,
|
||||||
|
canStartAuth: canStartAuth,
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(
|
||||||
indent: 5,
|
indent: 5,
|
||||||
@@ -372,12 +683,11 @@ class LoginWidgetUserPass extends StatelessWidget {
|
|||||||
translate('Login'),
|
translate('Login'),
|
||||||
style: TextStyle(fontSize: 16),
|
style: TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
onPressed:
|
onPressed: curOP.value.isEmpty && !isInProgress
|
||||||
curOP.value.isEmpty || curOP.value == 'rustdesk'
|
? () {
|
||||||
? () {
|
onLogin();
|
||||||
onLogin();
|
}
|
||||||
}
|
: null,
|
||||||
: null,
|
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
])),
|
])),
|
||||||
@@ -388,8 +698,28 @@ class LoginWidgetUserPass extends StatelessWidget {
|
|||||||
|
|
||||||
const kAuthReqTypeOidc = 'oidc/';
|
const kAuthReqTypeOidc = 'oidc/';
|
||||||
|
|
||||||
|
Future<bool?>? _activeLoginDialog;
|
||||||
|
|
||||||
// call this directly
|
// call this directly
|
||||||
Future<bool?> loginDialog() async {
|
Future<bool?> loginDialog() {
|
||||||
|
final activeDialog = _activeLoginDialog;
|
||||||
|
if (activeDialog != null) {
|
||||||
|
return activeDialog;
|
||||||
|
}
|
||||||
|
final dialog = _openLoginDialogOnce();
|
||||||
|
_activeLoginDialog = dialog;
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> _openLoginDialogOnce() async {
|
||||||
|
try {
|
||||||
|
return await _openLoginDialog();
|
||||||
|
} finally {
|
||||||
|
_activeLoginDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> _openLoginDialog() async {
|
||||||
var username =
|
var username =
|
||||||
TextEditingController(text: UserModel.getLocalUserInfo()?['name'] ?? '');
|
TextEditingController(text: UserModel.getLocalUserInfo()?['name'] ?? '');
|
||||||
var password = TextEditingController();
|
var password = TextEditingController();
|
||||||
@@ -399,14 +729,28 @@ Future<bool?> loginDialog() async {
|
|||||||
String? usernameMsg;
|
String? usernameMsg;
|
||||||
String? passwordMsg;
|
String? passwordMsg;
|
||||||
var isInProgress = false;
|
var isInProgress = false;
|
||||||
final RxString curOP = ''.obs;
|
final oidcAuth = _OidcAuthController();
|
||||||
|
final curOP = oidcAuth.curOP;
|
||||||
// Track hover state for the close icon
|
// Track hover state for the close icon
|
||||||
bool isCloseHovered = false;
|
bool isCloseHovered = false;
|
||||||
|
|
||||||
final loginOptions = [].obs;
|
final loginOptions = [].obs;
|
||||||
Future.delayed(Duration.zero, () async {
|
final loginOptionsError = Rxn<Object>();
|
||||||
loginOptions.value = await UserModel.queryOidcLoginOptions();
|
final loginOptionsInProgress = false.obs;
|
||||||
});
|
fetchLoginOptions() async {
|
||||||
|
loginOptionsInProgress.value = true;
|
||||||
|
try {
|
||||||
|
loginOptions.value = await UserModel.queryOidcLoginOptions();
|
||||||
|
loginOptionsError.value = null;
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint("queryOidcLoginOptions failed: $e");
|
||||||
|
loginOptionsError.value = e;
|
||||||
|
} finally {
|
||||||
|
loginOptionsInProgress.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future.delayed(Duration.zero, fetchLoginOptions);
|
||||||
|
|
||||||
final res = await gFFI.dialogManager.show<bool>((setState, close, context) {
|
final res = await gFFI.dialogManager.show<bool>((setState, close, context) {
|
||||||
username.addListener(() {
|
username.addListener(() {
|
||||||
@@ -480,6 +824,9 @@ Future<bool?> loginDialog() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLogin() async {
|
onLogin() async {
|
||||||
|
if (curOP.value.isNotEmpty || isInProgress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// validate
|
// validate
|
||||||
if (username.text.isEmpty) {
|
if (username.text.isEmpty) {
|
||||||
setState(() => usernameMsg = translate('Username missed'));
|
setState(() => usernameMsg = translate('Username missed'));
|
||||||
@@ -510,6 +857,36 @@ Future<bool?> loginDialog() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thirdAuthWidget() => Obx(() {
|
thirdAuthWidget() => Obx(() {
|
||||||
|
final error = loginOptionsError.value;
|
||||||
|
final inProgress = loginOptionsInProgress.value;
|
||||||
|
if (error != null) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 8.0),
|
||||||
|
// NOT use Offstage to wrap LinearProgressIndicator
|
||||||
|
if (inProgress) const LinearProgressIndicator(),
|
||||||
|
if (!inProgress && error is! RequestException)
|
||||||
|
Text(
|
||||||
|
translate('network_error_tip'),
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
onPressed: inProgress ? null : fetchLoginOptions,
|
||||||
|
child: Text(translate('Retry')),
|
||||||
|
),
|
||||||
|
if (!inProgress)
|
||||||
|
SelectableText(
|
||||||
|
error.toString(),
|
||||||
|
style: const TextStyle(fontSize: 11, color: Colors.red),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage: loginOptions.isEmpty,
|
offstage: loginOptions.isEmpty,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -530,6 +907,9 @@ Future<bool?> loginDialog() async {
|
|||||||
.map((e) => ConfigOP(op: e['name'], icon: e['icon']))
|
.map((e) => ConfigOP(op: e['name'], icon: e['icon']))
|
||||||
.toList(),
|
.toList(),
|
||||||
curOP: curOP,
|
curOP: curOP,
|
||||||
|
startAuth: oidcAuth.start,
|
||||||
|
cancelAuth: oidcAuth.cancelCurrent,
|
||||||
|
canStartAuth: oidcAuth.canStart,
|
||||||
cbLogin: (Map<String, dynamic> authBody) async {
|
cbLogin: (Map<String, dynamic> authBody) async {
|
||||||
LoginResponse? resp;
|
LoginResponse? resp;
|
||||||
try {
|
try {
|
||||||
@@ -611,7 +991,7 @@ Future<bool?> loginDialog() async {
|
|||||||
onCancel: onDialogCancel,
|
onCancel: onDialogCancel,
|
||||||
onSubmit: onLogin,
|
onSubmit: onLogin,
|
||||||
);
|
);
|
||||||
});
|
}).whenComplete(oidcAuth.close);
|
||||||
|
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
await UserModel.updateOtherModels();
|
await UserModel.updateOtherModels();
|
||||||
|
|||||||
@@ -158,12 +158,18 @@ class _MyGroupState extends State<MyGroup> {
|
|||||||
return Obx(() {
|
return Obx(() {
|
||||||
final userItems = gFFI.groupModel.users.where((p0) {
|
final userItems = gFFI.groupModel.users.where((p0) {
|
||||||
if (searchAccessibleItemNameText.isNotEmpty) {
|
if (searchAccessibleItemNameText.isNotEmpty) {
|
||||||
return p0.name
|
final search = searchAccessibleItemNameText.value.toLowerCase();
|
||||||
.toLowerCase()
|
return p0.name.toLowerCase().contains(search) ||
|
||||||
.contains(searchAccessibleItemNameText.value.toLowerCase());
|
p0.displayNameOrName.toLowerCase().contains(search);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
// Count occurrences of each displayNameOrName to detect duplicates
|
||||||
|
final displayNameCount = <String, int>{};
|
||||||
|
for (final u in userItems) {
|
||||||
|
final dn = u.displayNameOrName;
|
||||||
|
displayNameCount[dn] = (displayNameCount[dn] ?? 0) + 1;
|
||||||
|
}
|
||||||
final deviceGroupItems = gFFI.groupModel.deviceGroups.where((p0) {
|
final deviceGroupItems = gFFI.groupModel.deviceGroups.where((p0) {
|
||||||
if (searchAccessibleItemNameText.isNotEmpty) {
|
if (searchAccessibleItemNameText.isNotEmpty) {
|
||||||
return p0.name
|
return p0.name
|
||||||
@@ -177,7 +183,8 @@ class _MyGroupState extends State<MyGroup> {
|
|||||||
itemCount: deviceGroupItems.length + userItems.length,
|
itemCount: deviceGroupItems.length + userItems.length,
|
||||||
itemBuilder: (context, index) => index < deviceGroupItems.length
|
itemBuilder: (context, index) => index < deviceGroupItems.length
|
||||||
? _buildDeviceGroupItem(deviceGroupItems[index])
|
? _buildDeviceGroupItem(deviceGroupItems[index])
|
||||||
: _buildUserItem(userItems[index - deviceGroupItems.length]));
|
: _buildUserItem(userItems[index - deviceGroupItems.length],
|
||||||
|
displayNameCount));
|
||||||
var maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
|
var maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
|
||||||
return Obx(() => stateGlobal.isPortrait.isFalse
|
return Obx(() => stateGlobal.isPortrait.isFalse
|
||||||
? listView(false)
|
? listView(false)
|
||||||
@@ -185,8 +192,14 @@ class _MyGroupState extends State<MyGroup> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildUserItem(UserPayload user) {
|
Widget _buildUserItem(UserPayload user, Map<String, int> displayNameCount) {
|
||||||
final username = user.name;
|
final username = user.name;
|
||||||
|
final dn = user.displayNameOrName;
|
||||||
|
final isDuplicate = (displayNameCount[dn] ?? 0) > 1;
|
||||||
|
final displayName =
|
||||||
|
isDuplicate && user.displayName.trim().isNotEmpty
|
||||||
|
? '${user.displayName} (@$username)'
|
||||||
|
: dn;
|
||||||
return InkWell(onTap: () {
|
return InkWell(onTap: () {
|
||||||
isSelectedDeviceGroup.value = false;
|
isSelectedDeviceGroup.value = false;
|
||||||
if (selectedAccessibleItemName.value != username) {
|
if (selectedAccessibleItemName.value != username) {
|
||||||
@@ -222,14 +235,14 @@ class _MyGroupState extends State<MyGroup> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
username.characters.first.toUpperCase(),
|
displayName.characters.first.toUpperCase(),
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
).marginOnly(right: 4),
|
).marginOnly(right: 4),
|
||||||
if (isMe) Flexible(child: Text(username)),
|
if (isMe) Flexible(child: Text(displayName)),
|
||||||
if (isMe)
|
if (isMe)
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -246,7 +259,7 @@ class _MyGroupState extends State<MyGroup> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isMe) Expanded(child: Text(username)),
|
if (!isMe) Expanded(child: Text(displayName)),
|
||||||
],
|
],
|
||||||
).paddingSymmetric(vertical: 4),
|
).paddingSymmetric(vertical: 4),
|
||||||
),
|
),
|
||||||
|
|||||||
157
flutter/lib/common/widgets/oidc_auth_status.dart
Normal file
157
flutter/lib/common/widgets/oidc_auth_status.dart
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
const _statusFontSize = 12.0;
|
||||||
|
const _statusSpacing = 4.0;
|
||||||
|
const _messageActionSpacing = 8.0;
|
||||||
|
const _desktopActionSize = 28.0;
|
||||||
|
const _touchPlatforms = <TargetPlatform>{
|
||||||
|
TargetPlatform.android,
|
||||||
|
TargetPlatform.iOS,
|
||||||
|
TargetPlatform.fuchsia,
|
||||||
|
};
|
||||||
|
|
||||||
|
class OidcAuthStatus extends StatelessWidget {
|
||||||
|
final String message;
|
||||||
|
final String browserFallbackPrompt;
|
||||||
|
final String authUrl;
|
||||||
|
final String copyLabel;
|
||||||
|
final VoidCallback? onCopy;
|
||||||
|
|
||||||
|
const OidcAuthStatus({
|
||||||
|
super.key,
|
||||||
|
required this.message,
|
||||||
|
required this.browserFallbackPrompt,
|
||||||
|
required this.authUrl,
|
||||||
|
required this.copyLabel,
|
||||||
|
this.onCopy,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final messageStyle =
|
||||||
|
DefaultTextStyle.of(context).style.copyWith(fontSize: _statusFontSize);
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SelectableText(message, style: messageStyle),
|
||||||
|
if (authUrl.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: _messageActionSpacing),
|
||||||
|
child: _OidcAuthFallback(
|
||||||
|
browserFallbackPrompt: browserFallbackPrompt,
|
||||||
|
authUrl: authUrl,
|
||||||
|
copyLabel: copyLabel,
|
||||||
|
onCopy: onCopy,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OidcAuthFallback extends StatefulWidget {
|
||||||
|
final String browserFallbackPrompt;
|
||||||
|
final String authUrl;
|
||||||
|
final String copyLabel;
|
||||||
|
final VoidCallback? onCopy;
|
||||||
|
|
||||||
|
const _OidcAuthFallback({
|
||||||
|
required this.browserFallbackPrompt,
|
||||||
|
required this.authUrl,
|
||||||
|
required this.copyLabel,
|
||||||
|
required this.onCopy,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_OidcAuthFallback> createState() => _OidcAuthFallbackState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OidcAuthFallbackState extends State<_OidcAuthFallback> {
|
||||||
|
bool _expanded = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant _OidcAuthFallback oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.authUrl != widget.authUrl) {
|
||||||
|
_expanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final helperStyle = DefaultTextStyle.of(context).style.copyWith(
|
||||||
|
fontSize: _statusFontSize,
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
);
|
||||||
|
final linkColor = theme.brightness == Brightness.dark
|
||||||
|
? Colors.blue.shade300
|
||||||
|
: Colors.blue.shade800;
|
||||||
|
final isTouchPlatform = _touchPlatforms.contains(theme.platform);
|
||||||
|
final actionSize =
|
||||||
|
isTouchPlatform ? kMinInteractiveDimension : _desktopActionSize;
|
||||||
|
final urlStyle =
|
||||||
|
DefaultTextStyle.of(context).style.copyWith(fontSize: _statusFontSize);
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.browserFallbackPrompt,
|
||||||
|
style: helperStyle,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: _statusSpacing),
|
||||||
|
child: _buildUrl(urlStyle, linkColor, actionSize),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _copyAndExpand() {
|
||||||
|
setState(() => _expanded = true);
|
||||||
|
widget.onCopy?.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildUrl(TextStyle urlStyle, Color linkColor, double actionSize) {
|
||||||
|
final collapsedUrl = SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: linkColor,
|
||||||
|
minimumSize: Size(0, actionSize),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
visualDensity: VisualDensity.standard,
|
||||||
|
),
|
||||||
|
onPressed: _copyAndExpand,
|
||||||
|
child: Text(
|
||||||
|
widget.authUrl,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
softWrap: false,
|
||||||
|
style: urlStyle.copyWith(
|
||||||
|
color: linkColor,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final collapsedChild = widget.onCopy == null
|
||||||
|
? collapsedUrl
|
||||||
|
: Tooltip(message: widget.copyLabel, child: collapsedUrl);
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
constraints: BoxConstraints(minHeight: actionSize),
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: _messageActionSpacing),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: Theme.of(context).dividerColor),
|
||||||
|
borderRadius: BorderRadius.circular(_statusSpacing),
|
||||||
|
),
|
||||||
|
child: _expanded
|
||||||
|
? SelectableText(widget.authUrl, style: urlStyle)
|
||||||
|
: collapsedChild,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -570,11 +570,14 @@ class MyGroupPeerView extends BasePeersView {
|
|||||||
static bool filter(Peer peer) {
|
static bool filter(Peer peer) {
|
||||||
final model = gFFI.groupModel;
|
final model = gFFI.groupModel;
|
||||||
if (model.searchAccessibleItemNameText.isNotEmpty) {
|
if (model.searchAccessibleItemNameText.isNotEmpty) {
|
||||||
final text = model.searchAccessibleItemNameText.value;
|
final text = model.searchAccessibleItemNameText.value.toLowerCase();
|
||||||
final searchPeersOfUser = peer.loginName.contains(text) &&
|
final searchPeersOfUser = model.users.any((user) =>
|
||||||
model.users.any((user) => user.name == peer.loginName);
|
user.name == peer.loginName &&
|
||||||
final searchPeersOfDeviceGroup = peer.device_group_name.contains(text) &&
|
(user.name.toLowerCase().contains(text) ||
|
||||||
model.deviceGroups.any((g) => g.name == peer.device_group_name);
|
user.displayNameOrName.toLowerCase().contains(text)));
|
||||||
|
final searchPeersOfDeviceGroup =
|
||||||
|
peer.device_group_name.toLowerCase().contains(text) &&
|
||||||
|
model.deviceGroups.any((g) => g.name == peer.device_group_name);
|
||||||
if (!searchPeersOfUser && !searchPeersOfDeviceGroup) {
|
if (!searchPeersOfUser && !searchPeersOfDeviceGroup) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class RawKeyFocusScope extends StatelessWidget {
|
|||||||
// https://github.com/flutter/flutter/issues/154053
|
// https://github.com/flutter/flutter/issues/154053
|
||||||
final useRawKeyEvents = isLinux && !isWeb;
|
final useRawKeyEvents = isLinux && !isWeb;
|
||||||
// FIXME: On Windows, `AltGr` will generate `Alt` and `Control` key events,
|
// FIXME: On Windows, `AltGr` will generate `Alt` and `Control` key events,
|
||||||
// while `Alt` and `Control` are seperated key events for en-US input method.
|
// while `Alt` and `Control` are separated key events for en-US input method.
|
||||||
return FocusScope(
|
return FocusScope(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
child: Focus(
|
child: Focus(
|
||||||
@@ -107,6 +107,8 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
// For mouse mode, we need to block the events when the cursor is in a blocked area.
|
// For mouse mode, we need to block the events when the cursor is in a blocked area.
|
||||||
// So we need to cache the last tap down position.
|
// So we need to cache the last tap down position.
|
||||||
Offset? _lastTapDownPositionForMouseMode;
|
Offset? _lastTapDownPositionForMouseMode;
|
||||||
|
// Cache global position for onTap (which lacks position info).
|
||||||
|
Offset? _lastTapDownGlobalPosition;
|
||||||
|
|
||||||
FFI get ffi => widget.ffi;
|
FFI get ffi => widget.ffi;
|
||||||
FfiModel get ffiModel => widget.ffiModel;
|
FfiModel get ffiModel => widget.ffiModel;
|
||||||
@@ -136,6 +138,7 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
|
|
||||||
onTapDown(TapDownDetails d) async {
|
onTapDown(TapDownDetails d) async {
|
||||||
lastDeviceKind = d.kind;
|
lastDeviceKind = d.kind;
|
||||||
|
_lastTapDownGlobalPosition = d.globalPosition;
|
||||||
if (isNotTouchBasedDevice()) {
|
if (isNotTouchBasedDevice()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -154,11 +157,16 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
if (isNotTouchBasedDevice()) {
|
if (isNotTouchBasedDevice()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Filter duplicate touch tap events on iOS (Magic Mouse issue).
|
||||||
|
if (inputModel.shouldIgnoreTouchTap(d.globalPosition)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (handleTouch) {
|
if (handleTouch) {
|
||||||
final isMoved =
|
final isMoved =
|
||||||
await ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
await ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
if (isMoved) {
|
if (isMoved) {
|
||||||
if (lastTapDownDetails != null) {
|
// If pan already handled 'down', don't send it again.
|
||||||
|
if (lastTapDownDetails != null && !_touchModePanStarted) {
|
||||||
await inputModel.tapDown(MouseButtons.left);
|
await inputModel.tapDown(MouseButtons.left);
|
||||||
}
|
}
|
||||||
await inputModel.tapUp(MouseButtons.left);
|
await inputModel.tapUp(MouseButtons.left);
|
||||||
@@ -170,6 +178,11 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
if (isNotTouchBasedDevice()) {
|
if (isNotTouchBasedDevice()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Filter duplicate touch tap events on iOS (Magic Mouse issue).
|
||||||
|
final lastPos = _lastTapDownGlobalPosition;
|
||||||
|
if (lastPos != null && inputModel.shouldIgnoreTouchTap(lastPos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!handleTouch) {
|
if (!handleTouch) {
|
||||||
// Cannot use `_lastTapDownDetails` because Flutter calls `onTapUp` before `onTap`, clearing the cached details.
|
// Cannot use `_lastTapDownDetails` because Flutter calls `onTapUp` before `onTap`, clearing the cached details.
|
||||||
// Using `_lastTapDownPositionForMouseMode` instead.
|
// Using `_lastTapDownPositionForMouseMode` instead.
|
||||||
@@ -424,6 +437,14 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset `_touchModePanStarted` if the one-finger pan gesture is cancelled
|
||||||
|
// or rejected by the gesture arena. Without this, the flag can remain
|
||||||
|
// stuck in the "started" state and cause issues such as the Magic Mouse
|
||||||
|
// double-click problem on iPad with magic mouse.
|
||||||
|
onOneFingerPanCancel() {
|
||||||
|
_touchModePanStarted = false;
|
||||||
|
}
|
||||||
|
|
||||||
// scale + pan event
|
// scale + pan event
|
||||||
onTwoFingerScaleStart(ScaleStartDetails d) {
|
onTwoFingerScaleStart(ScaleStartDetails d) {
|
||||||
_lastTapDownDetails = null;
|
_lastTapDownDetails = null;
|
||||||
@@ -557,6 +578,7 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
instance
|
instance
|
||||||
..onOneFingerPanUpdate = onOneFingerPanUpdate
|
..onOneFingerPanUpdate = onOneFingerPanUpdate
|
||||||
..onOneFingerPanEnd = onOneFingerPanEnd
|
..onOneFingerPanEnd = onOneFingerPanEnd
|
||||||
|
..onOneFingerPanCancel = onOneFingerPanCancel
|
||||||
..onTwoFingerScaleStart = onTwoFingerScaleStart
|
..onTwoFingerScaleStart = onTwoFingerScaleStart
|
||||||
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
||||||
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
||||||
|
|||||||
@@ -13,8 +13,84 @@ import 'package:flutter_hbb/models/model.dart';
|
|||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
bool isEditOsPassword = false;
|
bool isEditOsPassword = false;
|
||||||
|
const String kPeerOptionAllowWaylandKeyboard = 'allow-wayland-keyboard';
|
||||||
|
const String kWaylandKeyboardIssueUrl =
|
||||||
|
'https://github.com/rustdesk/rustdesk/issues/14586';
|
||||||
|
final Set<String> _waylandKeyboardPromptSuppressedConnectionIds = <String>{};
|
||||||
|
|
||||||
|
Future<bool> openWaylandKeyboardIssueUrl() {
|
||||||
|
return launchUrl(
|
||||||
|
Uri.parse(kWaylandKeyboardIssueUrl),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isWaylandKeyboardPromptSuppressedForConnection(String connectionId) {
|
||||||
|
return _waylandKeyboardPromptSuppressedConnectionIds.contains(connectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWaylandKeyboardPromptSuppressedForConnection(
|
||||||
|
String connectionId, bool suppressed) {
|
||||||
|
if (suppressed) {
|
||||||
|
_waylandKeyboardPromptSuppressedConnectionIds.add(connectionId);
|
||||||
|
} else {
|
||||||
|
_waylandKeyboardPromptSuppressedConnectionIds.remove(connectionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearWaylandKeyboardPromptSuppressedForConnection(String connectionId) {
|
||||||
|
_waylandKeyboardPromptSuppressedConnectionIds.remove(connectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool shouldShowWaylandKeyboardPrompt({
|
||||||
|
required String connectionId,
|
||||||
|
required bool isWaylandPeer,
|
||||||
|
required bool allowWaylandKeyboardRemembered,
|
||||||
|
}) {
|
||||||
|
return isWaylandPeer &&
|
||||||
|
!allowWaylandKeyboardRemembered &&
|
||||||
|
!isWaylandKeyboardPromptSuppressedForConnection(connectionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget waylandKeyboardScopeChip(BuildContext context, String text) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
border: Border.all(color: colorScheme.primary.withOpacity(0.35)),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isWindowsMode1PrivacyImpl(String privacyModeImpl) {
|
||||||
|
return privacyModeImpl == kPrivacyModeImplMag ||
|
||||||
|
privacyModeImpl == kPrivacyModeImplExcludeFromCapture;
|
||||||
|
}
|
||||||
|
|
||||||
|
// macOS privacy mode blacks out all online displays. Windows Mode 1 also
|
||||||
|
// covers every local monitor with privacy overlay windows, so remote display
|
||||||
|
// switching does not weaken local privacy protection.
|
||||||
|
//
|
||||||
|
// Keep this separate from the capture backend capability. The legacy Windows
|
||||||
|
// magnifier capturer is not reliable for multi-monitor capture; WebRTC's
|
||||||
|
// screen_capturer_win_magnifier also disables it when SM_CMONITORS != 1:
|
||||||
|
// https://webrtc.googlesource.com/src/+/1845922d5a1bf9c27deeffb4a8c8daea124434c1/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
|
||||||
|
bool allowDisplaySwitchInPrivacyMode(PeerInfo pi, String privacyModeImpl) {
|
||||||
|
return pi.platform == kPeerPlatformMacOS ||
|
||||||
|
(pi.platform == kPeerPlatformWindows &&
|
||||||
|
_isWindowsMode1PrivacyImpl(privacyModeImpl) &&
|
||||||
|
versionCmp(pi.version, '1.4.8') >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
class TTextMenu {
|
class TTextMenu {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@@ -87,12 +163,179 @@ handleOsPasswordAction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showWaylandKeyboardInputWarningDialog(
|
||||||
|
{required String id,
|
||||||
|
required String connectionId,
|
||||||
|
required FFI ffi,
|
||||||
|
required Future<void> Function() onEnable}) {
|
||||||
|
bool remember = false;
|
||||||
|
bool consentInProgress = false;
|
||||||
|
bool dialogClosed = false;
|
||||||
|
|
||||||
|
final dialogFuture = ffi.dialogManager.show((setState, close, context) {
|
||||||
|
void safeSetState(VoidCallback fn) {
|
||||||
|
if (dialogClosed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
setState(fn);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Ignore setState after dialog disposal: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void closeDialog() {
|
||||||
|
if (dialogClosed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialogClosed = true;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> enableAndContinue() async {
|
||||||
|
if (consentInProgress || dialogClosed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
consentInProgress = true;
|
||||||
|
safeSetState(() {});
|
||||||
|
try {
|
||||||
|
await onEnable();
|
||||||
|
} catch (e, st) {
|
||||||
|
debugPrint('Failed to enable Wayland keyboard input consent: $e');
|
||||||
|
debugPrintStack(stackTrace: st);
|
||||||
|
consentInProgress = false;
|
||||||
|
safeSetState(() {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ffi.inputModel.keyboardInputAllowed = true;
|
||||||
|
var rememberPersisted = true;
|
||||||
|
if (remember) {
|
||||||
|
try {
|
||||||
|
await bind.mainSetPeerOption(
|
||||||
|
id: id,
|
||||||
|
key: kPeerOptionAllowWaylandKeyboard,
|
||||||
|
value: bool2option(kPeerOptionAllowWaylandKeyboard, true));
|
||||||
|
} catch (e) {
|
||||||
|
rememberPersisted = false;
|
||||||
|
debugPrint('Failed to persist Wayland keyboard input consent: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Always suppress prompt for current connection after explicit consent.
|
||||||
|
setWaylandKeyboardPromptSuppressedForConnection(connectionId, true);
|
||||||
|
closeDialog();
|
||||||
|
if (remember && !rememberPersisted) {
|
||||||
|
// It's a rare edge case that persisting the user's choice fails.
|
||||||
|
// Failed to persist the user's choice, but still allow keyboard input for current session.
|
||||||
|
showToast(translate('Failed'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancel() {
|
||||||
|
if (consentInProgress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
closeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: null,
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
msgboxContent(
|
||||||
|
'',
|
||||||
|
'wayland-keyboard-input-disabled-tip',
|
||||||
|
'wayland-keyboard-input-consent-tip',
|
||||||
|
),
|
||||||
|
SizedBox(height: isMobile ? 2 : 6),
|
||||||
|
if (isMobile) ...[
|
||||||
|
Text(
|
||||||
|
translate('wayland-keyboard-input-applies-to-tip'),
|
||||||
|
style: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.w600),
|
||||||
|
).marginOnly(bottom: 6),
|
||||||
|
Wrap(
|
||||||
|
spacing: 6,
|
||||||
|
runSpacing: 6,
|
||||||
|
children: [
|
||||||
|
waylandKeyboardScopeChip(
|
||||||
|
context, translate('Send clipboard keystrokes')),
|
||||||
|
waylandKeyboardScopeChip(
|
||||||
|
context, translate('wayland-soft-keyboard-input-label')),
|
||||||
|
],
|
||||||
|
).marginOnly(bottom: 10),
|
||||||
|
],
|
||||||
|
TextButton(
|
||||||
|
onPressed: consentInProgress
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
try {
|
||||||
|
final opened = await openWaylandKeyboardIssueUrl();
|
||||||
|
if (!opened) {
|
||||||
|
// Opening this optional help link almost never fails in
|
||||||
|
// normal desktop environments. Keep the result handled
|
||||||
|
// for review hygiene, but avoid a low-value user toast.
|
||||||
|
debugPrint('Failed to open Wayland keyboard issue URL');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(
|
||||||
|
'Failed to open Wayland keyboard issue URL: $e');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: Colors.blue,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: Size.zero,
|
||||||
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
translate('Why this happens'),
|
||||||
|
style: const TextStyle(decoration: TextDecoration.underline),
|
||||||
|
),
|
||||||
|
).marginOnly(bottom: 6),
|
||||||
|
CheckboxListTile(
|
||||||
|
value: remember,
|
||||||
|
dense: true,
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
|
title: Text(translate('remember-wayland-keyboard-choice-tip')),
|
||||||
|
onChanged: consentInProgress
|
||||||
|
? null
|
||||||
|
: (v) {
|
||||||
|
safeSetState(() => remember = v == true);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
dialogButton(
|
||||||
|
'Cancel',
|
||||||
|
onPressed: consentInProgress ? null : cancel,
|
||||||
|
isOutline: true,
|
||||||
|
),
|
||||||
|
dialogButton(
|
||||||
|
'OK',
|
||||||
|
onPressed:
|
||||||
|
consentInProgress ? null : () => unawaited(enableAndContinue()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onCancel: consentInProgress ? null : cancel,
|
||||||
|
onSubmit: consentInProgress ? null : () => unawaited(enableAndContinue()),
|
||||||
|
);
|
||||||
|
}, clickMaskDismiss: false, backDismiss: false);
|
||||||
|
unawaited(dialogFuture.whenComplete(() => dialogClosed = true));
|
||||||
|
}
|
||||||
|
|
||||||
List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||||
final ffiModel = ffi.ffiModel;
|
final ffiModel = ffi.ffiModel;
|
||||||
final pi = ffiModel.pi;
|
final pi = ffiModel.pi;
|
||||||
final perms = ffiModel.permissions;
|
final perms = ffiModel.permissions;
|
||||||
final sessionId = ffi.sessionId;
|
final sessionId = ffi.sessionId;
|
||||||
final isDefaultConn = ffi.connType == ConnType.defaultConn;
|
final isDefaultConn = ffi.connType == ConnType.defaultConn;
|
||||||
|
final isWaylandPeer = pi.platform == kPeerPlatformLinux && pi.isWayland;
|
||||||
|
|
||||||
List<TTextMenu> v = [];
|
List<TTextMenu> v = [];
|
||||||
// elevation
|
// elevation
|
||||||
@@ -142,11 +385,60 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
|||||||
v.add(TTextMenu(
|
v.add(TTextMenu(
|
||||||
child: Text(translate('Send clipboard keystrokes')),
|
child: Text(translate('Send clipboard keystrokes')),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
Future<void> sendClipboardKeystrokes() async {
|
||||||
if (data != null && data.text != null) {
|
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
bind.sessionInputString(
|
if (data != null && data.text != null) {
|
||||||
sessionId: sessionId, value: data.text ?? "");
|
bind.sessionInputString(
|
||||||
|
sessionId: sessionId, value: data.text ?? "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final allowWaylandKeyboard =
|
||||||
|
mainGetPeerBoolOptionSync(id, kPeerOptionAllowWaylandKeyboard);
|
||||||
|
if (shouldShowWaylandKeyboardPrompt(
|
||||||
|
connectionId: sessionId.toString(),
|
||||||
|
isWaylandPeer: isWaylandPeer,
|
||||||
|
allowWaylandKeyboardRemembered: allowWaylandKeyboard,
|
||||||
|
)) {
|
||||||
|
ffi.inputModel.keyboardInputAllowed = false;
|
||||||
|
showWaylandKeyboardInputWarningDialog(
|
||||||
|
id: id,
|
||||||
|
connectionId: sessionId.toString(),
|
||||||
|
ffi: ffi,
|
||||||
|
onEnable: sendClipboardKeystrokes,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await sendClipboardKeystrokes();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (isDefaultConn &&
|
||||||
|
isWaylandPeer &&
|
||||||
|
(mainGetPeerBoolOptionSync(id, kPeerOptionAllowWaylandKeyboard) ||
|
||||||
|
isWaylandKeyboardPromptSuppressedForConnection(
|
||||||
|
sessionId.toString()))) {
|
||||||
|
v.add(TTextMenu(
|
||||||
|
child: Text(translate('wayland-keyboard-input-reset-choice-tip')),
|
||||||
|
onPressed: () async {
|
||||||
|
var persistedCleared = false;
|
||||||
|
try {
|
||||||
|
await bind.mainSetPeerOption(
|
||||||
|
id: id,
|
||||||
|
key: kPeerOptionAllowWaylandKeyboard,
|
||||||
|
value: bool2option(kPeerOptionAllowWaylandKeyboard, false));
|
||||||
|
persistedCleared = true;
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(
|
||||||
|
'Failed to clear persisted Wayland keyboard permission: $e');
|
||||||
|
} finally {
|
||||||
|
clearWaylandKeyboardPromptSuppressedForConnection(
|
||||||
|
sessionId.toString());
|
||||||
|
ffi.inputModel.keyboardInputAllowed = false;
|
||||||
|
if (isMobile) {
|
||||||
|
await ffi.invokeMethod("enable_soft_keyboard", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showToast(translate(persistedCleared ? 'Successful' : 'Failed'));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// reset canvas
|
// reset canvas
|
||||||
@@ -275,7 +567,6 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
|||||||
isDesktop &&
|
isDesktop &&
|
||||||
ffiModel.keyboard &&
|
ffiModel.keyboard &&
|
||||||
pi.platform != kPeerPlatformAndroid &&
|
pi.platform != kPeerPlatformAndroid &&
|
||||||
pi.platform != kPeerPlatformMacOS &&
|
|
||||||
versionCmp(pi.version, '1.2.0') >= 0 &&
|
versionCmp(pi.version, '1.2.0') >= 0 &&
|
||||||
bind.peerGetSessionsCount(id: id, connType: ffi.connType.index) == 1) {
|
bind.peerGetSessionsCount(id: id, connType: ffi.connType.index) == 1) {
|
||||||
v.add(TTextMenu(
|
v.add(TTextMenu(
|
||||||
@@ -292,6 +583,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
|||||||
}
|
}
|
||||||
// record
|
// record
|
||||||
if (!(isDesktop || isWeb) &&
|
if (!(isDesktop || isWeb) &&
|
||||||
|
bind.mainGetLocalOption(key: kOptionHideRecordingButton) != 'Y' &&
|
||||||
(ffi.recordingModel.start || (perms["recording"] != false))) {
|
(ffi.recordingModel.start || (perms["recording"] != false))) {
|
||||||
v.add(TTextMenu(
|
v.add(TTextMenu(
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -315,7 +607,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
|||||||
// to-do:
|
// to-do:
|
||||||
// 1. Web desktop
|
// 1. Web desktop
|
||||||
// 2. Mobile, copy the image to the clipboard
|
// 2. Mobile, copy the image to the clipboard
|
||||||
if (isDesktop) {
|
if ((isDefaultConn || ffi.connType == ConnType.viewCamera) && isDesktop) {
|
||||||
final isScreenshotSupported = bind.sessionGetCommonSync(
|
final isScreenshotSupported = bind.sessionGetCommonSync(
|
||||||
sessionId: sessionId, key: 'is_screenshot_supported', param: '');
|
sessionId: sessionId, key: 'is_screenshot_supported', param: '');
|
||||||
if ('true' == isScreenshotSupported) {
|
if ('true' == isScreenshotSupported) {
|
||||||
@@ -685,8 +977,10 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
|
|||||||
child: Text(translate('Lock after session end'))));
|
child: Text(translate('Lock after session end'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final privacyModeState = PrivacyModeState.find(id);
|
||||||
if (pi.isSupportMultiDisplay &&
|
if (pi.isSupportMultiDisplay &&
|
||||||
PrivacyModeState.find(id).isEmpty &&
|
(privacyModeState.isEmpty ||
|
||||||
|
allowDisplaySwitchInPrivacyMode(pi, privacyModeState.value)) &&
|
||||||
pi.displaysCount.value > 1 &&
|
pi.displaysCount.value > 1 &&
|
||||||
bind.mainGetUserDefaultOption(key: kKeyShowMonitorsToolbar) == 'Y') {
|
bind.mainGetUserDefaultOption(key: kKeyShowMonitorsToolbar) == 'Y') {
|
||||||
final value =
|
final value =
|
||||||
@@ -760,23 +1054,38 @@ List<TToggleMenu> toolbarPrivacyMode(
|
|||||||
final ffiModel = ffi.ffiModel;
|
final ffiModel = ffi.ffiModel;
|
||||||
final pi = ffiModel.pi;
|
final pi = ffiModel.pi;
|
||||||
final sessionId = ffi.sessionId;
|
final sessionId = ffi.sessionId;
|
||||||
|
final hasPrivacyModePermission =
|
||||||
|
ffiModel.permissions['privacy_mode'] != false;
|
||||||
|
|
||||||
getDefaultMenu(Future<void> Function(SessionID sid, String opt) toggleFunc) {
|
// Backend revocation already attempts to turn privacy mode off.
|
||||||
final enabled = !ffi.ffiModel.viewOnly;
|
// Still keep this menu when privacy mode is active, so users can turn it off
|
||||||
|
// if there is a sync delay, version mismatch, or off attempt failure.
|
||||||
|
if (!hasPrivacyModePermission && privacyModeState.isEmpty) {
|
||||||
|
return []; // No permission and not active, hide options.
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkDisplayAllowedForPrivacyMode(String targetImplKey, bool turnOn) {
|
||||||
|
if (!turnOn ||
|
||||||
|
allowDisplaySwitchInPrivacyMode(pi, targetImplKey) ||
|
||||||
|
(ffiModel.pi.currentDisplay == 0 &&
|
||||||
|
!bind.sessionIsMultiUiSession(sessionId: sessionId))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
msgBox(sessionId, 'custom-nook-nocancel-hasclose', 'info',
|
||||||
|
'Please switch to Display 1 first', '', ffi.dialogManager);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDefaultMenu(Future<void> Function(SessionID sid, String opt) toggleFunc,
|
||||||
|
String targetImplKey) {
|
||||||
|
final enabled = !ffiModel.viewOnly &&
|
||||||
|
(hasPrivacyModePermission || privacyModeState.isNotEmpty);
|
||||||
return TToggleMenu(
|
return TToggleMenu(
|
||||||
value: privacyModeState.isNotEmpty,
|
value: privacyModeState.isNotEmpty,
|
||||||
onChanged: enabled
|
onChanged: enabled
|
||||||
? (value) {
|
? (value) {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
if (ffiModel.pi.currentDisplay != 0 &&
|
if (!checkDisplayAllowedForPrivacyMode(targetImplKey, value)) {
|
||||||
ffiModel.pi.currentDisplay != kAllDisplayValue) {
|
|
||||||
msgBox(
|
|
||||||
sessionId,
|
|
||||||
'custom-nook-nocancel-hasclose',
|
|
||||||
'info',
|
|
||||||
'Please switch to Display 1 first',
|
|
||||||
'',
|
|
||||||
ffi.dialogManager);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final option = 'privacy-mode';
|
final option = 'privacy-mode';
|
||||||
@@ -794,7 +1103,7 @@ List<TToggleMenu> toolbarPrivacyMode(
|
|||||||
getDefaultMenu((sid, opt) async {
|
getDefaultMenu((sid, opt) async {
|
||||||
bind.sessionToggleOption(sessionId: sid, value: opt);
|
bind.sessionToggleOption(sessionId: sid, value: opt);
|
||||||
togglePrivacyModeTime = DateTime.now();
|
togglePrivacyModeTime = DateTime.now();
|
||||||
})
|
}, kPrivacyModeImplMag)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (privacyModeImpls.isEmpty) {
|
if (privacyModeImpls.isEmpty) {
|
||||||
@@ -808,21 +1117,35 @@ List<TToggleMenu> toolbarPrivacyMode(
|
|||||||
bind.sessionTogglePrivacyMode(
|
bind.sessionTogglePrivacyMode(
|
||||||
sessionId: sid, implKey: implKey, on: privacyModeState.isEmpty);
|
sessionId: sid, implKey: implKey, on: privacyModeState.isEmpty);
|
||||||
togglePrivacyModeTime = DateTime.now();
|
togglePrivacyModeTime = DateTime.now();
|
||||||
})
|
}, implKey)
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return privacyModeImpls.map((e) {
|
final visibleImpls = hasPrivacyModePermission
|
||||||
|
? privacyModeImpls
|
||||||
|
: privacyModeImpls.where((e) {
|
||||||
|
final implKey = (e as List<dynamic>)[0] as String;
|
||||||
|
return privacyModeState.value == implKey;
|
||||||
|
}).toList();
|
||||||
|
return visibleImpls.map((e) {
|
||||||
final implKey = (e as List<dynamic>)[0] as String;
|
final implKey = (e as List<dynamic>)[0] as String;
|
||||||
final implName = (e)[1] as String;
|
final implName = (e)[1] as String;
|
||||||
|
final enabled = !ffiModel.viewOnly &&
|
||||||
|
(hasPrivacyModePermission || privacyModeState.value == implKey);
|
||||||
return TToggleMenu(
|
return TToggleMenu(
|
||||||
child: Text(translate(implName)),
|
child: Text(translate(implName)),
|
||||||
value: privacyModeState.value == implKey,
|
value: privacyModeState.value == implKey,
|
||||||
onChanged: (value) {
|
onChanged: enabled
|
||||||
if (value == null) return;
|
? (value) {
|
||||||
togglePrivacyModeTime = DateTime.now();
|
if (value == null) return;
|
||||||
bind.sessionTogglePrivacyMode(
|
if (value && !hasPrivacyModePermission) return;
|
||||||
sessionId: sessionId, implKey: implKey, on: value);
|
if (!checkDisplayAllowedForPrivacyMode(implKey, value)) {
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
togglePrivacyModeTime = DateTime.now();
|
||||||
|
bind.sessionTogglePrivacyMode(
|
||||||
|
sessionId: sessionId, implKey: implKey, on: value);
|
||||||
|
}
|
||||||
|
: null);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ const String kPlatformAdditionsHasFileClipboard = "has_file_clipboard";
|
|||||||
const String kPlatformAdditionsSupportedPrivacyModeImpl =
|
const String kPlatformAdditionsSupportedPrivacyModeImpl =
|
||||||
"supported_privacy_mode_impl";
|
"supported_privacy_mode_impl";
|
||||||
|
|
||||||
|
const String kPrivacyModeImplMag = 'privacy_mode_impl_mag';
|
||||||
|
const String kPrivacyModeImplExcludeFromCapture =
|
||||||
|
'privacy_mode_impl_exclude_from_capture';
|
||||||
|
|
||||||
const String kPeerPlatformWindows = "Windows";
|
const String kPeerPlatformWindows = "Windows";
|
||||||
const String kPeerPlatformLinux = "Linux";
|
const String kPeerPlatformLinux = "Linux";
|
||||||
const String kPeerPlatformMacOS = "Mac OS";
|
const String kPeerPlatformMacOS = "Mac OS";
|
||||||
@@ -84,6 +88,7 @@ const String kOptionEdgeScrollEdgeThickness = "edge-scroll-edge-thickness";
|
|||||||
const String kOptionImageQuality = "image_quality";
|
const String kOptionImageQuality = "image_quality";
|
||||||
const String kOptionOpenNewConnInTabs = "enable-open-new-connections-in-tabs";
|
const String kOptionOpenNewConnInTabs = "enable-open-new-connections-in-tabs";
|
||||||
const String kOptionTextureRender = "use-texture-render";
|
const String kOptionTextureRender = "use-texture-render";
|
||||||
|
const String kOptionTextureRenderHealth = "texture-render-health";
|
||||||
const String kOptionD3DRender = "allow-d3d-render";
|
const String kOptionD3DRender = "allow-d3d-render";
|
||||||
const String kOptionOpenInTabs = "allow-open-in-tabs";
|
const String kOptionOpenInTabs = "allow-open-in-tabs";
|
||||||
const String kOptionOpenInWindows = "allow-open-in-windows";
|
const String kOptionOpenInWindows = "allow-open-in-windows";
|
||||||
@@ -91,6 +96,7 @@ const String kOptionForceAlwaysRelay = "force-always-relay";
|
|||||||
const String kOptionViewOnly = "view_only";
|
const String kOptionViewOnly = "view_only";
|
||||||
const String kOptionEnableLanDiscovery = "enable-lan-discovery";
|
const String kOptionEnableLanDiscovery = "enable-lan-discovery";
|
||||||
const String kOptionWhitelist = "whitelist";
|
const String kOptionWhitelist = "whitelist";
|
||||||
|
const String kOptionIdWhitelist = "id-whitelist";
|
||||||
const String kOptionEnableAbr = "enable-abr";
|
const String kOptionEnableAbr = "enable-abr";
|
||||||
const String kOptionEnableRecordSession = "enable-record-session";
|
const String kOptionEnableRecordSession = "enable-record-session";
|
||||||
const String kOptionDirectServer = "direct-server";
|
const String kOptionDirectServer = "direct-server";
|
||||||
@@ -100,6 +106,7 @@ const String kOptionAutoDisconnectTimeout = "auto-disconnect-timeout";
|
|||||||
const String kOptionEnableHwcodec = "enable-hwcodec";
|
const String kOptionEnableHwcodec = "enable-hwcodec";
|
||||||
const String kOptionAllowAutoRecordIncoming = "allow-auto-record-incoming";
|
const String kOptionAllowAutoRecordIncoming = "allow-auto-record-incoming";
|
||||||
const String kOptionAllowAutoRecordOutgoing = "allow-auto-record-outgoing";
|
const String kOptionAllowAutoRecordOutgoing = "allow-auto-record-outgoing";
|
||||||
|
const String kOptionHideRecordingButton = "hide-recording-button";
|
||||||
const String kOptionVideoSaveDirectory = "video-save-directory";
|
const String kOptionVideoSaveDirectory = "video-save-directory";
|
||||||
const String kOptionAccessMode = "access-mode";
|
const String kOptionAccessMode = "access-mode";
|
||||||
const String kOptionEnableKeyboard = "enable-keyboard";
|
const String kOptionEnableKeyboard = "enable-keyboard";
|
||||||
@@ -114,6 +121,9 @@ const String kOptionTerminalPersistent = "terminal-persistent";
|
|||||||
const String kOptionEnableTunnel = "enable-tunnel";
|
const String kOptionEnableTunnel = "enable-tunnel";
|
||||||
const String kOptionEnableRemoteRestart = "enable-remote-restart";
|
const String kOptionEnableRemoteRestart = "enable-remote-restart";
|
||||||
const String kOptionEnableBlockInput = "enable-block-input";
|
const String kOptionEnableBlockInput = "enable-block-input";
|
||||||
|
const String kOptionEnablePrivacyMode = "enable-privacy-mode";
|
||||||
|
const String kOptionEnablePermChangeInAcceptWindow =
|
||||||
|
"enable-perm-change-in-accept-window";
|
||||||
const String kOptionAllowRemoteConfigModification =
|
const String kOptionAllowRemoteConfigModification =
|
||||||
"allow-remote-config-modification";
|
"allow-remote-config-modification";
|
||||||
const String kOptionVerificationMethod = "verification-method";
|
const String kOptionVerificationMethod = "verification-method";
|
||||||
@@ -139,6 +149,10 @@ const String kOptionSwapLeftRightMouse = "swap-left-right-mouse";
|
|||||||
const String kOptionCodecPreference = "codec-preference";
|
const String kOptionCodecPreference = "codec-preference";
|
||||||
const String kOptionRemoteMenubarDragLeft = "remote-menubar-drag-left";
|
const String kOptionRemoteMenubarDragLeft = "remote-menubar-drag-left";
|
||||||
const String kOptionRemoteMenubarDragRight = "remote-menubar-drag-right";
|
const String kOptionRemoteMenubarDragRight = "remote-menubar-drag-right";
|
||||||
|
const String kOptionRemoteMenubarEdge = "remote-menubar-edge";
|
||||||
|
const String kOptionRemoteMenubarFraction = "remote-menubar-frac";
|
||||||
|
const String kOptionAllowMultiEdgeToolbarDock =
|
||||||
|
"allow-multi-edge-toolbar-dock";
|
||||||
const String kOptionHideAbTagsPanel = "hideAbTagsPanel";
|
const String kOptionHideAbTagsPanel = "hideAbTagsPanel";
|
||||||
const String kOptionRemoteMenubarState = "remoteMenubarState";
|
const String kOptionRemoteMenubarState = "remoteMenubarState";
|
||||||
const String kOptionPeerSorting = "peer-sorting";
|
const String kOptionPeerSorting = "peer-sorting";
|
||||||
@@ -163,7 +177,10 @@ const String kOptionShowVirtualMouse = "show-virtual-mouse";
|
|||||||
const String kOptionVirtualMouseScale = "virtual-mouse-scale";
|
const String kOptionVirtualMouseScale = "virtual-mouse-scale";
|
||||||
const String kOptionShowVirtualJoystick = "show-virtual-joystick";
|
const String kOptionShowVirtualJoystick = "show-virtual-joystick";
|
||||||
const String kOptionAllowAskForNoteAtEndOfConnection = "allow-ask-for-note";
|
const String kOptionAllowAskForNoteAtEndOfConnection = "allow-ask-for-note";
|
||||||
|
const String kOptionAllowMonitorSwitchMainToolbar = "allow-monitor-switch-main-toolbar";
|
||||||
|
const String kOptionAllowMonitorSwitchMinToolbar = "allow-monitor-switch-min-toolbar";
|
||||||
const String kOptionEnableShowTerminalExtraKeys = "enable-show-terminal-extra-keys";
|
const String kOptionEnableShowTerminalExtraKeys = "enable-show-terminal-extra-keys";
|
||||||
|
const String kOptionShowTerminalCtrlKeys = "show-terminal-extra-ctrl-keys";
|
||||||
|
|
||||||
// network options
|
// network options
|
||||||
const String kOptionAllowWebSocket = "allow-websocket";
|
const String kOptionAllowWebSocket = "allow-websocket";
|
||||||
@@ -175,6 +192,7 @@ const String kOptionEnableFlutterHttpOnRust = "enable-flutter-http-on-rust";
|
|||||||
const String kOptionHideServerSetting = "hide-server-settings";
|
const String kOptionHideServerSetting = "hide-server-settings";
|
||||||
const String kOptionHideProxySetting = "hide-proxy-settings";
|
const String kOptionHideProxySetting = "hide-proxy-settings";
|
||||||
const String kOptionHideWebSocketSetting = "hide-websocket-settings";
|
const String kOptionHideWebSocketSetting = "hide-websocket-settings";
|
||||||
|
const String kOptionHideStopService = "hide-stop-service";
|
||||||
const String kOptionHideRemotePrinterSetting = "hide-remote-printer-settings";
|
const String kOptionHideRemotePrinterSetting = "hide-remote-printer-settings";
|
||||||
const String kOptionHideSecuritySetting = "hide-security-settings";
|
const String kOptionHideSecuritySetting = "hide-security-settings";
|
||||||
const String kOptionHideNetworkSetting = "hide-network-settings";
|
const String kOptionHideNetworkSetting = "hide-network-settings";
|
||||||
@@ -186,6 +204,9 @@ const String kOptionDisableChangeId = "disable-change-id";
|
|||||||
const String kOptionDisableUnlockPin = "disable-unlock-pin";
|
const String kOptionDisableUnlockPin = "disable-unlock-pin";
|
||||||
const kHideUsernameOnCard = "hide-username-on-card";
|
const kHideUsernameOnCard = "hide-username-on-card";
|
||||||
const String kOptionHideHelpCards = "hide-help-cards";
|
const String kOptionHideHelpCards = "hide-help-cards";
|
||||||
|
const String kOptionAllowDeepLinkPassword = "allow-deep-link-password";
|
||||||
|
const String kOptionAllowDeepLinkServerSettings =
|
||||||
|
"allow-deep-link-server-settings";
|
||||||
|
|
||||||
const String kOptionToggleViewOnly = "view-only";
|
const String kOptionToggleViewOnly = "view-only";
|
||||||
const String kOptionToggleShowMyCursor = "show-my-cursor";
|
const String kOptionToggleShowMyCursor = "show-my-cursor";
|
||||||
@@ -194,6 +215,9 @@ const String kOptionDisableFloatingWindow = "disable-floating-window";
|
|||||||
|
|
||||||
const String kOptionKeepScreenOn = "keep-screen-on";
|
const String kOptionKeepScreenOn = "keep-screen-on";
|
||||||
|
|
||||||
|
const String kOptionKeepAwakeDuringIncomingSessions = "keep-awake-during-incoming-sessions";
|
||||||
|
const String kOptionKeepAwakeDuringOutgoingSessions = "keep-awake-during-outgoing-sessions";
|
||||||
|
|
||||||
const String kOptionShowMobileAction = "showMobileActions";
|
const String kOptionShowMobileAction = "showMobileActions";
|
||||||
|
|
||||||
const String kUrlActionClose = "close";
|
const String kUrlActionClose = "close";
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
.contains(textToFind) ||
|
.contains(textToFind) ||
|
||||||
peer.alias.toLowerCase().contains(textToFind))
|
peer.alias.toLowerCase().contains(textToFind))
|
||||||
.toList();
|
.toList();
|
||||||
|
_allPeersLoader.queryOnlines(_autocompleteOpts);
|
||||||
}
|
}
|
||||||
return _autocompleteOpts;
|
return _autocompleteOpts;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
import 'package:window_size/window_size.dart' as window_size;
|
import 'package:window_size/window_size.dart' as window_size;
|
||||||
import '../widgets/button.dart';
|
import '../widgets/button.dart';
|
||||||
|
import '../widgets/texture_render_probe.dart';
|
||||||
|
|
||||||
class DesktopHomePage extends StatefulWidget {
|
class DesktopHomePage extends StatefulWidget {
|
||||||
const DesktopHomePage({Key? key}) : super(key: key);
|
const DesktopHomePage({Key? key}) : super(key: key);
|
||||||
@@ -60,15 +61,20 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
final isIncomingOnly = bind.isIncomingOnly();
|
final isIncomingOnly = bind.isIncomingOnly();
|
||||||
return _buildBlock(
|
return Stack(
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
buildLeftPane(context),
|
_buildBlock(
|
||||||
if (!isIncomingOnly) const VerticalDivider(width: 1),
|
child: Row(
|
||||||
if (!isIncomingOnly) Expanded(child: buildRightPane(context)),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
buildLeftPane(context),
|
||||||
|
if (!isIncomingOnly) const VerticalDivider(width: 1),
|
||||||
|
if (!isIncomingOnly) Expanded(child: buildRightPane(context)),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
const Positioned(left: 0, top: 0, child: TextureRenderProbe()),
|
||||||
],
|
],
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBlock({required Widget child}) {
|
Widget _buildBlock({required Widget child}) {
|
||||||
@@ -450,7 +456,11 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
"${translate("new-version-of-{${bind.mainGetAppNameSync()}}-tip")} (${bind.mainGetNewVersion()}).",
|
"${translate("new-version-of-{${bind.mainGetAppNameSync()}}-tip")} (${bind.mainGetNewVersion()}).",
|
||||||
btnText,
|
btnText,
|
||||||
onPressed,
|
onPressed,
|
||||||
closeButton: true);
|
closeButton: true,
|
||||||
|
help: isToUpdate ? 'Changelog' : null,
|
||||||
|
link: isToUpdate
|
||||||
|
? 'https://github.com/rustdesk/rustdesk/releases/tag/${bind.mainGetNewVersion()}'
|
||||||
|
: null);
|
||||||
}
|
}
|
||||||
if (systemError.isNotEmpty) {
|
if (systemError.isNotEmpty) {
|
||||||
return buildInstallCard("", systemError, "", () {});
|
return buildInstallCard("", systemError, "", () {});
|
||||||
@@ -904,12 +914,17 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
||||||
final pw = await bind.mainGetPermanentPassword();
|
final p0 = TextEditingController(text: "");
|
||||||
final p0 = TextEditingController(text: pw);
|
final p1 = TextEditingController(text: "");
|
||||||
final p1 = TextEditingController(text: pw);
|
|
||||||
var errMsg0 = "";
|
var errMsg0 = "";
|
||||||
var errMsg1 = "";
|
var errMsg1 = "";
|
||||||
final RxString rxPass = pw.trim().obs;
|
final localPasswordSet =
|
||||||
|
(await bind.mainGetCommon(key: "local-permanent-password-set")) == "true";
|
||||||
|
final permanentPasswordSet =
|
||||||
|
(await bind.mainGetCommon(key: "permanent-password-set")) == "true";
|
||||||
|
final presetPassword = permanentPasswordSet && !localPasswordSet;
|
||||||
|
var canSubmit = false;
|
||||||
|
final RxString rxPass = "".obs;
|
||||||
final rules = [
|
final rules = [
|
||||||
DigitValidationRule(),
|
DigitValidationRule(),
|
||||||
UppercaseValidationRule(),
|
UppercaseValidationRule(),
|
||||||
@@ -918,9 +933,21 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
MinCharactersValidationRule(8),
|
MinCharactersValidationRule(8),
|
||||||
];
|
];
|
||||||
final maxLength = bind.mainMaxEncryptLen();
|
final maxLength = bind.mainMaxEncryptLen();
|
||||||
|
final statusTip = localPasswordSet
|
||||||
|
? translate('password-hidden-tip')
|
||||||
|
: (presetPassword ? translate('preset-password-in-use-tip') : '');
|
||||||
|
final showStatusTipOnMobile =
|
||||||
|
statusTip.isNotEmpty && !isDesktop && !isWebDesktop;
|
||||||
|
|
||||||
gFFI.dialogManager.show((setState, close, context) {
|
gFFI.dialogManager.show((setState, close, context) {
|
||||||
submit() {
|
updateCanSubmit() {
|
||||||
|
canSubmit = p0.text.trim().isNotEmpty || p1.text.trim().isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() async {
|
||||||
|
if (!canSubmit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
errMsg0 = "";
|
errMsg0 = "";
|
||||||
errMsg1 = "";
|
errMsg1 = "";
|
||||||
@@ -943,7 +970,13 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bind.mainSetPermanentPassword(password: pass);
|
final ok = await bind.mainSetPermanentPasswordWithResult(password: pass);
|
||||||
|
if (!ok) {
|
||||||
|
setState(() {
|
||||||
|
errMsg0 = '${translate('Prompt')}: ${translate("Failed")}';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (pass.isNotEmpty) {
|
if (pass.isNotEmpty) {
|
||||||
notEmptyCallback?.call();
|
notEmptyCallback?.call();
|
||||||
}
|
}
|
||||||
@@ -951,14 +984,20 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate("Set Password")),
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.key, color: MyTheme.accent),
|
||||||
|
Text(translate("Set Password")).paddingOnly(left: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
content: ConstrainedBox(
|
content: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(minWidth: 500),
|
constraints: const BoxConstraints(minWidth: 500),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 8.0,
|
height: showStatusTipOnMobile ? 0.0 : 6.0,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -974,6 +1013,7 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
rxPass.value = value.trim();
|
rxPass.value = value.trim();
|
||||||
setState(() {
|
setState(() {
|
||||||
errMsg0 = '';
|
errMsg0 = '';
|
||||||
|
updateCanSubmit();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
maxLength: maxLength,
|
maxLength: maxLength,
|
||||||
@@ -985,9 +1025,9 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(child: PasswordStrengthIndicator(password: rxPass)),
|
Expanded(child: PasswordStrengthIndicator(password: rxPass)),
|
||||||
],
|
],
|
||||||
).marginSymmetric(vertical: 8),
|
).marginOnly(top: 2, bottom: showStatusTipOnMobile ? 2 : 8),
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 8.0,
|
height: showStatusTipOnMobile ? 0.0 : 8.0,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -1001,6 +1041,7 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
errMsg1 = '';
|
errMsg1 = '';
|
||||||
|
updateCanSubmit();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
maxLength: maxLength,
|
maxLength: maxLength,
|
||||||
@@ -1008,11 +1049,23 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
if (statusTip.isNotEmpty)
|
||||||
height: 8.0,
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.info, color: Colors.amber, size: 18)
|
||||||
|
.marginOnly(right: 6),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
statusTip,
|
||||||
|
style: const TextStyle(fontSize: 13, height: 1.1),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
).marginOnly(top: 6, bottom: 2),
|
||||||
|
SizedBox(
|
||||||
|
height: showStatusTipOnMobile ? 0.0 : 8.0,
|
||||||
),
|
),
|
||||||
Obx(() => Wrap(
|
Obx(() => Wrap(
|
||||||
runSpacing: 8,
|
runSpacing: showStatusTipOnMobile ? 2.0 : 8.0,
|
||||||
spacing: 4,
|
spacing: 4,
|
||||||
children: rules.map((e) {
|
children: rules.map((e) {
|
||||||
var checked = e.validate(rxPass.value.trim());
|
var checked = e.validate(rxPass.value.trim());
|
||||||
@@ -1032,11 +1085,67 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: (() {
|
||||||
dialogButton("Cancel", onPressed: close, isOutline: true),
|
final cancelButton = dialogButton(
|
||||||
dialogButton("OK", onPressed: submit),
|
"Cancel",
|
||||||
],
|
icon: Icon(Icons.close_rounded),
|
||||||
onSubmit: submit,
|
onPressed: close,
|
||||||
|
isOutline: true,
|
||||||
|
);
|
||||||
|
final removeButton = dialogButton(
|
||||||
|
"Remove",
|
||||||
|
icon: Icon(Icons.delete_outline_rounded),
|
||||||
|
onPressed: () async {
|
||||||
|
setState(() {
|
||||||
|
errMsg0 = "";
|
||||||
|
errMsg1 = "";
|
||||||
|
});
|
||||||
|
final ok =
|
||||||
|
await bind.mainSetPermanentPasswordWithResult(password: "");
|
||||||
|
if (!ok) {
|
||||||
|
setState(() {
|
||||||
|
errMsg0 = '${translate('Prompt')}: ${translate("Failed")}';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
buttonStyle: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStatePropertyAll(Colors.red)),
|
||||||
|
);
|
||||||
|
final okButton = dialogButton(
|
||||||
|
"OK",
|
||||||
|
icon: Icon(Icons.done_rounded),
|
||||||
|
onPressed: canSubmit ? submit : null,
|
||||||
|
);
|
||||||
|
if (!isDesktop && !isWebDesktop && localPasswordSet) {
|
||||||
|
return [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
cancelButton,
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
removeButton,
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
okButton,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
cancelButton,
|
||||||
|
if (localPasswordSet) removeButton,
|
||||||
|
okButton,
|
||||||
|
];
|
||||||
|
})(),
|
||||||
|
onSubmit: canSubmit ? submit : null,
|
||||||
onCancel: close,
|
onCancel: close,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -407,6 +407,7 @@ class _GeneralState extends State<_General> {
|
|||||||
final RxBool serviceStop =
|
final RxBool serviceStop =
|
||||||
isWeb ? RxBool(false) : Get.find<RxBool>(tag: 'stop-service');
|
isWeb ? RxBool(false) : Get.find<RxBool>(tag: 'stop-service');
|
||||||
RxBool serviceBtnEnabled = true.obs;
|
RxBool serviceBtnEnabled = true.obs;
|
||||||
|
final GlobalKey _minToolbarOptionKey = GlobalKey();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -458,31 +459,53 @@ class _GeneralState extends State<_General> {
|
|||||||
return const Offstage();
|
return const Offstage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _Card(title: 'Service', children: [
|
final hideStopService =
|
||||||
Obx(() => _Button(serviceStop.value ? 'Start' : 'Stop', () {
|
bind.mainGetBuildinOption(key: kOptionHideStopService) == 'Y';
|
||||||
() async {
|
|
||||||
serviceBtnEnabled.value = false;
|
return Obx(() {
|
||||||
await start_service(serviceStop.value);
|
if (hideStopService && !serviceStop.value) {
|
||||||
// enable the button after 1 second
|
return const Offstage();
|
||||||
Future.delayed(const Duration(seconds: 1), () {
|
}
|
||||||
serviceBtnEnabled.value = true;
|
|
||||||
});
|
return _Card(title: 'Service', children: [
|
||||||
}();
|
_Button(serviceStop.value ? 'Start' : 'Stop', () {
|
||||||
}, enabled: serviceBtnEnabled.value))
|
() async {
|
||||||
]);
|
serviceBtnEnabled.value = false;
|
||||||
|
await start_service(serviceStop.value);
|
||||||
|
// enable the button after 1 second
|
||||||
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
serviceBtnEnabled.value = true;
|
||||||
|
});
|
||||||
|
}();
|
||||||
|
}, enabled: serviceBtnEnabled.value)
|
||||||
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget other() {
|
Widget other() {
|
||||||
final showAutoUpdate =
|
final incomingOnly = bind.isIncomingOnly();
|
||||||
isWindows && bind.mainIsInstalled() && !bind.isCustomClient();
|
final outgoingOnly = bind.isOutgoingOnly();
|
||||||
|
final showAutoUpdate = (isWindows && bind.mainIsInstalled()) ||
|
||||||
|
(isMacOS && bind.mainIsInstalled() && bind.mainIsInstalledDaemon(prompt: false) && !bind.isCustomClient());
|
||||||
final children = <Widget>[
|
final children = <Widget>[
|
||||||
if (!isWeb && !bind.isIncomingOnly())
|
if (!isWeb && !incomingOnly)
|
||||||
_OptionCheckBox(context, 'Confirm before closing multiple tabs',
|
_OptionCheckBox(context, 'Confirm before closing multiple tabs',
|
||||||
kOptionEnableConfirmClosingTabs,
|
kOptionEnableConfirmClosingTabs,
|
||||||
isServer: false),
|
isServer: false),
|
||||||
_OptionCheckBox(context, 'Adaptive bitrate', kOptionEnableAbr),
|
if (!incomingOnly)
|
||||||
|
_OptionCheckBox(
|
||||||
|
context,
|
||||||
|
'allow-remote-toolbar-docking-any-edge',
|
||||||
|
kOptionAllowMultiEdgeToolbarDock,
|
||||||
|
isServer: false,
|
||||||
|
update: (_) {
|
||||||
|
reloadAllWindows();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (!isWeb && !outgoingOnly)
|
||||||
|
_OptionCheckBox(context, 'Adaptive bitrate', kOptionEnableAbr),
|
||||||
if (!isWeb) wallpaper(),
|
if (!isWeb) wallpaper(),
|
||||||
if (!isWeb && !bind.isIncomingOnly()) ...[
|
if (!isWeb && !incomingOnly) ...[
|
||||||
_OptionCheckBox(
|
_OptionCheckBox(
|
||||||
context,
|
context,
|
||||||
'Open connection in new tab',
|
'Open connection in new tab',
|
||||||
@@ -521,42 +544,53 @@ class _GeneralState extends State<_General> {
|
|||||||
isServer: false,
|
isServer: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isWeb && !bind.isCustomClient())
|
],
|
||||||
_OptionCheckBox(
|
if (!isWeb && !bind.isCustomClient())
|
||||||
context,
|
_OptionCheckBox(
|
||||||
'Check for software update on startup',
|
context,
|
||||||
kOptionEnableCheckUpdate,
|
'Check for software update on startup',
|
||||||
isServer: false,
|
kOptionEnableCheckUpdate,
|
||||||
),
|
isServer: false,
|
||||||
if (showAutoUpdate)
|
),
|
||||||
_OptionCheckBox(
|
if (showAutoUpdate)
|
||||||
context,
|
_OptionCheckBox(
|
||||||
'Auto update',
|
context,
|
||||||
kOptionAllowAutoUpdate,
|
'Auto update',
|
||||||
isServer: true,
|
kOptionAllowAutoUpdate,
|
||||||
),
|
isServer: true,
|
||||||
if (isWindows && !bind.isOutgoingOnly())
|
),
|
||||||
_OptionCheckBox(
|
if (isWindows && !outgoingOnly)
|
||||||
context,
|
_OptionCheckBox(
|
||||||
'Capture screen using DirectX',
|
context,
|
||||||
kOptionDirectxCapture,
|
'Capture screen using DirectX',
|
||||||
),
|
kOptionDirectxCapture,
|
||||||
if (!bind.isIncomingOnly()) ...[
|
),
|
||||||
_OptionCheckBox(
|
if (!isWeb && !incomingOnly) ...[
|
||||||
context,
|
_OptionCheckBox(
|
||||||
'Enable UDP hole punching',
|
context,
|
||||||
kOptionEnableUdpPunch,
|
'Enable UDP hole punching',
|
||||||
isServer: false,
|
kOptionEnableUdpPunch,
|
||||||
),
|
isServer: false,
|
||||||
_OptionCheckBox(
|
),
|
||||||
context,
|
_OptionCheckBox(
|
||||||
'Enable IPv6 P2P connection',
|
context,
|
||||||
kOptionEnableIpv6Punch,
|
'Enable IPv6 P2P connection',
|
||||||
isServer: false,
|
kOptionEnableIpv6Punch,
|
||||||
),
|
isServer: false,
|
||||||
],
|
),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Add client-side wakelock option for desktop platforms
|
||||||
|
if (!bind.isIncomingOnly()) {
|
||||||
|
children.add(_OptionCheckBox(
|
||||||
|
context,
|
||||||
|
'keep-awake-during-outgoing-sessions-label',
|
||||||
|
kOptionKeepAwakeDuringOutgoingSessions,
|
||||||
|
isServer: false,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (!isWeb && bind.mainShowOption(key: kOptionAllowLinuxHeadless)) {
|
if (!isWeb && bind.mainShowOption(key: kOptionAllowLinuxHeadless)) {
|
||||||
children.add(_OptionCheckBox(
|
children.add(_OptionCheckBox(
|
||||||
context, 'Allow linux headless', kOptionAllowLinuxHeadless));
|
context, 'Allow linux headless', kOptionAllowLinuxHeadless));
|
||||||
@@ -576,6 +610,47 @@ class _GeneralState extends State<_General> {
|
|||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
children.add(_OptionCheckBox(
|
||||||
|
context,
|
||||||
|
'Show monitor switch button on the main toolbar',
|
||||||
|
kOptionAllowMonitorSwitchMainToolbar,
|
||||||
|
isServer: false,
|
||||||
|
update: (enabled) async {
|
||||||
|
if (!enabled) {
|
||||||
|
await mainSetLocalBoolOption(
|
||||||
|
kOptionAllowMonitorSwitchMinToolbar, false);
|
||||||
|
}
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
reloadAllWindows();
|
||||||
|
if (enabled) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
final ctx = _minToolbarOptionKey.currentContext;
|
||||||
|
if (ctx != null) {
|
||||||
|
Scrollable.ensureVisible(
|
||||||
|
ctx,
|
||||||
|
alignment: 0.5,
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
if (mainGetLocalBoolOptionSync(kOptionAllowMonitorSwitchMainToolbar)) {
|
||||||
|
children.add(KeyedSubtree(
|
||||||
|
key: _minToolbarOptionKey,
|
||||||
|
child: _OptionCheckBox(
|
||||||
|
context,
|
||||||
|
'Show on the minimized toolbar',
|
||||||
|
kOptionAllowMonitorSwitchMinToolbar,
|
||||||
|
isServer: false,
|
||||||
|
update: (_) {
|
||||||
|
reloadAllWindows();
|
||||||
|
},
|
||||||
|
).marginOnly(left: _kCheckBoxLeftMargin * 3),
|
||||||
|
));
|
||||||
|
}
|
||||||
return _Card(title: 'Other', children: children);
|
return _Card(title: 'Other', children: children);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1043,6 +1118,10 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
|||||||
_OptionCheckBox(context, 'Enable blocking user input',
|
_OptionCheckBox(context, 'Enable blocking user input',
|
||||||
kOptionEnableBlockInput,
|
kOptionEnableBlockInput,
|
||||||
enabled: enabled, fakeValue: fakeValue),
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
|
if (bind.mainSupportedPrivacyModeImpls() != '[]')
|
||||||
|
_OptionCheckBox(
|
||||||
|
context, 'Enable privacy mode', kOptionEnablePrivacyMode,
|
||||||
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable remote configuration modification',
|
_OptionCheckBox(context, 'Enable remote configuration modification',
|
||||||
kOptionAllowRemoteConfigModification,
|
kOptionAllowRemoteConfigModification,
|
||||||
enabled: enabled, fakeValue: fakeValue),
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
@@ -1090,8 +1169,9 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
|||||||
if (value ==
|
if (value ==
|
||||||
passwordValues[passwordKeys
|
passwordValues[passwordKeys
|
||||||
.indexOf(kUsePermanentPassword)] &&
|
.indexOf(kUsePermanentPassword)] &&
|
||||||
(await bind.mainGetPermanentPassword())
|
(await bind.mainGetCommon(
|
||||||
.isEmpty) {
|
key: "permanent-password-set")) !=
|
||||||
|
"true") {
|
||||||
if (isChangePermanentPasswordDisabled()) {
|
if (isChangePermanentPasswordDisabled()) {
|
||||||
await callback();
|
await callback();
|
||||||
return;
|
return;
|
||||||
@@ -1218,7 +1298,11 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
|||||||
reverse: true, enabled: enabled),
|
reverse: true, enabled: enabled),
|
||||||
...directIp(context),
|
...directIp(context),
|
||||||
whitelist(),
|
whitelist(),
|
||||||
|
idWhitelist(),
|
||||||
...autoDisconnect(context),
|
...autoDisconnect(context),
|
||||||
|
_OptionCheckBox(context, 'keep-awake-during-incoming-sessions-label',
|
||||||
|
kOptionKeepAwakeDuringIncomingSessions,
|
||||||
|
reverse: false, enabled: enabled),
|
||||||
if (bind.mainIsInstalled())
|
if (bind.mainIsInstalled())
|
||||||
_OptionCheckBox(context, 'allow-only-conn-window-open-tip',
|
_OptionCheckBox(context, 'allow-only-conn-window-open-tip',
|
||||||
'allow-only-conn-window-open',
|
'allow-only-conn-window-open',
|
||||||
@@ -1372,6 +1456,52 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
|||||||
return tmpWrapper();
|
return tmpWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget idWhitelist() {
|
||||||
|
bool enabled = !locked;
|
||||||
|
RxBool hasIdWhitelist = idWhitelistNotEmpty().obs;
|
||||||
|
update() async {
|
||||||
|
hasIdWhitelist.value = idWhitelistNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
onChanged(bool? checked) async {
|
||||||
|
changeIdWhiteList(callback: update);
|
||||||
|
}
|
||||||
|
|
||||||
|
final isOptFixed = isOptionFixed(kOptionIdWhitelist);
|
||||||
|
return GestureDetector(
|
||||||
|
child: Tooltip(
|
||||||
|
message: translate('id_whitelist_tip'),
|
||||||
|
child: Obx(() => Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: hasIdWhitelist.value,
|
||||||
|
onChanged: enabled && !isOptFixed ? onChanged : null)
|
||||||
|
.marginOnly(right: 5),
|
||||||
|
Offstage(
|
||||||
|
offstage: !hasIdWhitelist.value,
|
||||||
|
child: MouseRegion(
|
||||||
|
child: const Icon(Icons.warning_amber_rounded,
|
||||||
|
color: Color.fromARGB(255, 255, 204, 0))
|
||||||
|
.marginOnly(right: 5),
|
||||||
|
cursor: SystemMouseCursors.click,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
translate('Use ID whitelisting'),
|
||||||
|
style: TextStyle(color: disabledTextColor(context, enabled)),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
onTap: enabled
|
||||||
|
? () {
|
||||||
|
onChanged(!hasIdWhitelist.value);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
).marginOnly(left: _kCheckBoxLeftMargin);
|
||||||
|
}
|
||||||
|
|
||||||
Widget hide_cm(bool enabled) {
|
Widget hide_cm(bool enabled) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: gFFI.serverModel,
|
value: gFFI.serverModel,
|
||||||
@@ -2002,7 +2132,9 @@ class _AccountState extends State<_Account> {
|
|||||||
|
|
||||||
Widget accountAction() {
|
Widget accountAction() {
|
||||||
return Obx(() => _Button(
|
return Obx(() => _Button(
|
||||||
gFFI.userModel.userName.value.isEmpty ? 'Login' : 'Logout',
|
gFFI.userModel.userName.value.isEmpty
|
||||||
|
? 'Login'
|
||||||
|
: '${translate('Logout')} (${gFFI.userModel.accountLabelWithHandle})',
|
||||||
() => {
|
() => {
|
||||||
gFFI.userModel.userName.value.isEmpty
|
gFFI.userModel.userName.value.isEmpty
|
||||||
? loginDialog()
|
? loginDialog()
|
||||||
@@ -2011,24 +2143,65 @@ class _AccountState extends State<_Account> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget useInfo() {
|
Widget useInfo() {
|
||||||
text(String key, String value) {
|
|
||||||
return Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: SelectionArea(child: Text('${translate(key)}: $value'))
|
|
||||||
.marginSymmetric(vertical: 4),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Obx(() => Offstage(
|
return Obx(() => Offstage(
|
||||||
offstage: gFFI.userModel.userName.value.isEmpty,
|
offstage: gFFI.userModel.userName.value.isEmpty,
|
||||||
child: Column(
|
child: Container(
|
||||||
children: [
|
padding: const EdgeInsets.all(12),
|
||||||
text('Username', gFFI.userModel.userName.value),
|
decoration: BoxDecoration(
|
||||||
// text('Group', gFFI.groupModel.groupName.value),
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
],
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Builder(builder: (context) {
|
||||||
|
final avatarWidget = _buildUserAvatar();
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
if (avatarWidget != null) avatarWidget,
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
gFFI.userModel.displayNameOrUserName,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
SelectionArea(
|
||||||
|
child: Text(
|
||||||
|
'@${gFFI.userModel.userName.value}',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color:
|
||||||
|
Theme.of(context).textTheme.bodySmall?.color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
)).marginOnly(left: 18, top: 16);
|
)).marginOnly(left: 18, top: 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget? _buildUserAvatar() {
|
||||||
|
// Resolve relative avatar path at display time
|
||||||
|
final avatar =
|
||||||
|
bind.mainResolveAvatarUrl(avatar: gFFI.userModel.avatar.value);
|
||||||
|
return buildAvatarWidget(
|
||||||
|
avatar: avatar,
|
||||||
|
size: 44,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Checkbox extends StatefulWidget {
|
class _Checkbox extends StatefulWidget {
|
||||||
@@ -2116,7 +2289,9 @@ class _PluginState extends State<_Plugin> {
|
|||||||
|
|
||||||
Widget accountAction() {
|
Widget accountAction() {
|
||||||
return Obx(() => _Button(
|
return Obx(() => _Button(
|
||||||
gFFI.userModel.userName.value.isEmpty ? 'Login' : 'Logout',
|
gFFI.userModel.userName.value.isEmpty
|
||||||
|
? 'Login'
|
||||||
|
: '${translate('Logout')} (${gFFI.userModel.accountLabelWithHandle})',
|
||||||
() => {
|
() => {
|
||||||
gFFI.userModel.userName.value.isEmpty
|
gFFI.userModel.userName.value.isEmpty
|
||||||
? loginDialog()
|
? loginDialog()
|
||||||
@@ -2287,17 +2462,20 @@ class _AboutState extends State<_About> {
|
|||||||
final version = await bind.mainGetVersion();
|
final version = await bind.mainGetVersion();
|
||||||
final buildDate = await bind.mainGetBuildDate();
|
final buildDate = await bind.mainGetBuildDate();
|
||||||
final fingerprint = await bind.mainGetFingerprint();
|
final fingerprint = await bind.mainGetFingerprint();
|
||||||
|
final myId = await bind.mainGetMyId();
|
||||||
return {
|
return {
|
||||||
'license': license,
|
'license': license,
|
||||||
'version': version,
|
'version': version,
|
||||||
'buildDate': buildDate,
|
'buildDate': buildDate,
|
||||||
'fingerprint': fingerprint
|
'fingerprint': fingerprint,
|
||||||
|
'myId': myId
|
||||||
};
|
};
|
||||||
}(), hasData: (data) {
|
}(), hasData: (data) {
|
||||||
final license = data['license'].toString();
|
final license = data['license'].toString();
|
||||||
final version = data['version'].toString();
|
final version = data['version'].toString();
|
||||||
final buildDate = data['buildDate'].toString();
|
final buildDate = data['buildDate'].toString();
|
||||||
final fingerprint = data['fingerprint'].toString();
|
final fingerprint = data['fingerprint'].toString();
|
||||||
|
final myId = data['myId'].toString();
|
||||||
const linkStyle = TextStyle(decoration: TextDecoration.underline);
|
const linkStyle = TextStyle(decoration: TextDecoration.underline);
|
||||||
final scrollController = ScrollController();
|
final scrollController = ScrollController();
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
@@ -2319,6 +2497,9 @@ class _AboutState extends State<_About> {
|
|||||||
SelectionArea(
|
SelectionArea(
|
||||||
child: Text('${translate('Fingerprint')}: $fingerprint')
|
child: Text('${translate('Fingerprint')}: $fingerprint')
|
||||||
.marginSymmetric(vertical: 4.0)),
|
.marginSymmetric(vertical: 4.0)),
|
||||||
|
SelectionArea(
|
||||||
|
child: Text('${translate('ID')}: $myId')
|
||||||
|
.marginSymmetric(vertical: 4.0)),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
launchUrlString('https://rustdesk.com/privacy.html');
|
launchUrlString('https://rustdesk.com/privacy.html');
|
||||||
@@ -2347,7 +2528,7 @@ class _AboutState extends State<_About> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Copyright © ${DateTime.now().toString().substring(0, 4)} Purslane Ltd.\n$license',
|
'Copyright © ${DateTime.now().toString().substring(0, 4)} Purslane Tech Pte. Ltd.\n$license',
|
||||||
style: const TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
@@ -2524,6 +2705,49 @@ class WaylandCard extends StatefulWidget {
|
|||||||
|
|
||||||
class _WaylandCardState extends State<WaylandCard> {
|
class _WaylandCardState extends State<WaylandCard> {
|
||||||
final restoreTokenKey = 'wayland-restore-token';
|
final restoreTokenKey = 'wayland-restore-token';
|
||||||
|
static const _kClearShortcutsInhibitorEventKey =
|
||||||
|
'clear-gnome-shortcuts-inhibitor-permission-res';
|
||||||
|
final _clearShortcutsInhibitorFailedMsg = ''.obs;
|
||||||
|
// Don't show the shortcuts permission reset button for now.
|
||||||
|
// Users can change it manually:
|
||||||
|
// "Settings" -> "Apps" -> "RustDesk" -> "Permissions" -> "Inhibit Shortcuts".
|
||||||
|
// For resetting(clearing) the permission from the portal permission store, you can
|
||||||
|
// use (replace <desktop-id> with the RustDesk desktop file ID):
|
||||||
|
// busctl --user call org.freedesktop.impl.portal.PermissionStore \
|
||||||
|
// /org/freedesktop/impl/portal/PermissionStore org.freedesktop.impl.portal.PermissionStore \
|
||||||
|
// DeletePermission sss "gnome" "shortcuts-inhibitor" "<desktop-id>"
|
||||||
|
// On a native install this is typically "rustdesk.desktop"; on Flatpak it is usually
|
||||||
|
// the exported desktop ID derived from the Flatpak app-id (e.g. "com.rustdesk.RustDesk.desktop").
|
||||||
|
//
|
||||||
|
// We may add it back in the future if needed.
|
||||||
|
final showResetInhibitorPermission = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (showResetInhibitorPermission) {
|
||||||
|
platformFFI.registerEventHandler(
|
||||||
|
_kClearShortcutsInhibitorEventKey, _kClearShortcutsInhibitorEventKey,
|
||||||
|
(evt) async {
|
||||||
|
if (!mounted) return;
|
||||||
|
if (evt['success'] == true) {
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
_clearShortcutsInhibitorFailedMsg.value =
|
||||||
|
evt['msg'] as String? ?? 'Unknown error';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
if (showResetInhibitorPermission) {
|
||||||
|
platformFFI.unregisterEventHandler(
|
||||||
|
_kClearShortcutsInhibitorEventKey, _kClearShortcutsInhibitorEventKey);
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -2531,9 +2755,16 @@ class _WaylandCardState extends State<WaylandCard> {
|
|||||||
future: bind.mainHandleWaylandScreencastRestoreToken(
|
future: bind.mainHandleWaylandScreencastRestoreToken(
|
||||||
key: restoreTokenKey, value: "get"),
|
key: restoreTokenKey, value: "get"),
|
||||||
hasData: (restoreToken) {
|
hasData: (restoreToken) {
|
||||||
|
final hasShortcutsPermission = showResetInhibitorPermission &&
|
||||||
|
bind.mainGetCommonSync(
|
||||||
|
key: "has-gnome-shortcuts-inhibitor-permission") ==
|
||||||
|
"true";
|
||||||
|
|
||||||
final children = [
|
final children = [
|
||||||
if (restoreToken.isNotEmpty)
|
if (restoreToken.isNotEmpty)
|
||||||
_buildClearScreenSelection(context, restoreToken),
|
_buildClearScreenSelection(context, restoreToken),
|
||||||
|
if (hasShortcutsPermission)
|
||||||
|
_buildClearShortcutsInhibitorPermission(context),
|
||||||
];
|
];
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage: children.isEmpty,
|
offstage: children.isEmpty,
|
||||||
@@ -2578,6 +2809,50 @@ class _WaylandCardState extends State<WaylandCard> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildClearShortcutsInhibitorPermission(BuildContext context) {
|
||||||
|
onConfirm() {
|
||||||
|
_clearShortcutsInhibitorFailedMsg.value = '';
|
||||||
|
bind.mainSetCommon(
|
||||||
|
key: "clear-gnome-shortcuts-inhibitor-permission", value: "");
|
||||||
|
gFFI.dialogManager.dismissAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
showConfirmMsgBox() => msgBoxCommon(
|
||||||
|
gFFI.dialogManager,
|
||||||
|
'Confirmation',
|
||||||
|
Text(
|
||||||
|
translate('confirm-clear-shortcuts-inhibitor-permission-tip'),
|
||||||
|
),
|
||||||
|
[
|
||||||
|
dialogButton('OK', onPressed: onConfirm),
|
||||||
|
dialogButton('Cancel',
|
||||||
|
onPressed: () => gFFI.dialogManager.dismissAll())
|
||||||
|
]);
|
||||||
|
|
||||||
|
return Column(children: [
|
||||||
|
Obx(
|
||||||
|
() => _clearShortcutsInhibitorFailedMsg.value.isEmpty
|
||||||
|
? Offstage()
|
||||||
|
: Align(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: Text(_clearShortcutsInhibitorFailedMsg.value,
|
||||||
|
style: DefaultTextStyle.of(context)
|
||||||
|
.style
|
||||||
|
.copyWith(color: Colors.red))
|
||||||
|
.marginOnly(bottom: 10.0)),
|
||||||
|
),
|
||||||
|
_Button(
|
||||||
|
'Reset keyboard shortcuts permission',
|
||||||
|
showConfirmMsgBox,
|
||||||
|
tip: 'clear-shortcuts-inhibitor-permission-tip',
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStateProperty.all<Color>(
|
||||||
|
Theme.of(context).colorScheme.error.withOpacity(0.75)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class _InstallPageBodyState extends State<_InstallPageBody>
|
|||||||
late final TextEditingController controller;
|
late final TextEditingController controller;
|
||||||
final RxBool startmenu = true.obs;
|
final RxBool startmenu = true.obs;
|
||||||
final RxBool desktopicon = true.obs;
|
final RxBool desktopicon = true.obs;
|
||||||
final RxBool printer = true.obs;
|
final RxBool printer = false.obs;
|
||||||
final RxBool showProgress = false.obs;
|
final RxBool showProgress = false.obs;
|
||||||
final RxBool btnEnabled = true.obs;
|
final RxBool btnEnabled = true.obs;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ class _InstallPageBodyState extends State<_InstallPageBody>
|
|||||||
final installOptions = jsonDecode(bind.installInstallOptions());
|
final installOptions = jsonDecode(bind.installInstallOptions());
|
||||||
startmenu.value = installOptions['STARTMENUSHORTCUTS'] != '0';
|
startmenu.value = installOptions['STARTMENUSHORTCUTS'] != '0';
|
||||||
desktopicon.value = installOptions['DESKTOPSHORTCUTS'] != '0';
|
desktopicon.value = installOptions['DESKTOPSHORTCUTS'] != '0';
|
||||||
printer.value = installOptions['PRINTER'] != '0';
|
printer.value = installOptions['PRINTER'] == '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
class MacOSFullScreenFocusRecovery {
|
||||||
|
int _generation = 0;
|
||||||
|
int? _pendingGeneration;
|
||||||
|
|
||||||
|
int? get pendingGeneration => _pendingGeneration;
|
||||||
|
|
||||||
|
int queue() {
|
||||||
|
_generation += 1;
|
||||||
|
_pendingGeneration = _generation;
|
||||||
|
return _generation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancel() {
|
||||||
|
_pendingGeneration = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCurrent(int generation) => _pendingGeneration == generation;
|
||||||
|
|
||||||
|
bool consume(int generation) {
|
||||||
|
if (!isCurrent(generation)) return false;
|
||||||
|
_pendingGeneration = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,9 @@ import '../../common/shared_state.dart';
|
|||||||
import '../../utils/image.dart';
|
import '../../utils/image.dart';
|
||||||
import '../widgets/remote_toolbar.dart';
|
import '../widgets/remote_toolbar.dart';
|
||||||
import '../widgets/kb_layout_type_chooser.dart';
|
import '../widgets/kb_layout_type_chooser.dart';
|
||||||
|
import '../widgets/raster_stall_monitor.dart';
|
||||||
import '../widgets/tabbar_widget.dart';
|
import '../widgets/tabbar_widget.dart';
|
||||||
|
import 'macos_full_screen_focus_recovery.dart';
|
||||||
|
|
||||||
import 'package:flutter_hbb/native/custom_cursor.dart'
|
import 'package:flutter_hbb/native/custom_cursor.dart'
|
||||||
if (dart.library.html) 'package:flutter_hbb/web/custom_cursor.dart';
|
if (dart.library.html) 'package:flutter_hbb/web/custom_cursor.dart';
|
||||||
@@ -64,6 +66,13 @@ class RemotePage extends StatefulWidget {
|
|||||||
|
|
||||||
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
|
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
|
||||||
|
|
||||||
|
void releaseMacOSInputForTabTransfer() {
|
||||||
|
if (!isMacOS) return;
|
||||||
|
// Release before removing the source tab. Its delayed disposal must not
|
||||||
|
// disable a native keyboard hook already acquired by the destination page.
|
||||||
|
(_lastState.value! as _RemotePageState)._releaseMacOSRemoteInput();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RemotePage> createState() {
|
State<RemotePage> createState() {
|
||||||
final state = _RemotePageState(id);
|
final state = _RemotePageState(id);
|
||||||
@@ -76,10 +85,28 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
with
|
with
|
||||||
AutomaticKeepAliveClientMixin,
|
AutomaticKeepAliveClientMixin,
|
||||||
MultiWindowListener,
|
MultiWindowListener,
|
||||||
|
WidgetsBindingObserver,
|
||||||
TickerProviderStateMixin {
|
TickerProviderStateMixin {
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
String keyboardMode = "legacy";
|
String keyboardMode = "legacy";
|
||||||
bool _isWindowBlur = false;
|
bool _isWindowBlur = false;
|
||||||
|
// Known macOS remote-input trade-offs (kept simple intentionally):
|
||||||
|
// 1. Dialogs rely on FocusNode loss plus middleBlocked, not mirrored dialog
|
||||||
|
// state. Reproduce: activate remote input, open a dialog, then type.
|
||||||
|
// 2. Delayed fullscreen recovery can race a local-control focus change; no
|
||||||
|
// owner state is added. Reproduce: focus the toolbar during a Space switch.
|
||||||
|
// 3. Input-source switching releases native input without updating this
|
||||||
|
// page's cache. Reproduce: switch sources, then type before and after
|
||||||
|
// clicking the remote image; the click reasserts input.
|
||||||
|
// These latches compensate for out-of-order macOS focus events. Treat them
|
||||||
|
// as coupled when changing a transition or _syncMacOSKeyboardGrab().
|
||||||
|
AppLifecycleState? _macOSLifecycleState;
|
||||||
|
bool _macOSLocalFocusLost = false;
|
||||||
|
bool _macOSInputActive = false;
|
||||||
|
bool _macOSInputSuppressed = false;
|
||||||
|
final _macOSFullScreenFocusRecovery = MacOSFullScreenFocusRecovery();
|
||||||
|
bool _macOSExplicitFocusRequestPending = false;
|
||||||
|
StreamSubscription<DesktopTabState>? _tabStateSubscription;
|
||||||
final _cursorOverImage = false.obs;
|
final _cursorOverImage = false.obs;
|
||||||
late RxBool _showRemoteCursor;
|
late RxBool _showRemoteCursor;
|
||||||
late RxBool _zoomCursor;
|
late RxBool _zoomCursor;
|
||||||
@@ -101,6 +128,9 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
Function(bool)? _onEnterOrLeaveImage4Toolbar;
|
Function(bool)? _onEnterOrLeaveImage4Toolbar;
|
||||||
|
|
||||||
late FFI _ffi;
|
late FFI _ffi;
|
||||||
|
Worker? _waylandKeyboardModeWorker;
|
||||||
|
bool _waylandKeyboardModeNormalized = false;
|
||||||
|
bool _waylandKeyboardModeNormalizing = false;
|
||||||
|
|
||||||
SessionID get sessionId => _ffi.sessionId;
|
SessionID get sessionId => _ffi.sessionId;
|
||||||
|
|
||||||
@@ -119,7 +149,15 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_ffi = FFI(widget.sessionId);
|
_ffi = FFI(widget.sessionId);
|
||||||
|
if (isMacOS) {
|
||||||
|
// SchedulerBinding.instance.lifecycleState is null in the first connection in a new window.
|
||||||
|
_macOSLifecycleState = SchedulerBinding.instance.lifecycleState;
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
_tabStateSubscription =
|
||||||
|
widget.tabController?.state.listen(_onMacOSTabStateChanged);
|
||||||
|
}
|
||||||
Get.put<FFI>(_ffi, tag: widget.id);
|
Get.put<FFI>(_ffi, tag: widget.id);
|
||||||
|
RasterStallMonitor.start();
|
||||||
_ffi.imageModel.addCallbackOnFirstImage((String peerId) {
|
_ffi.imageModel.addCallbackOnFirstImage((String peerId) {
|
||||||
_ffi.canvasModel.activateLocalCursor();
|
_ffi.canvasModel.activateLocalCursor();
|
||||||
showKBLayoutTypeChooserIfNeeded(
|
showKBLayoutTypeChooserIfNeeded(
|
||||||
@@ -178,6 +216,48 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
// Register callback to cancel debounce timer when relative mouse mode is disabled
|
// Register callback to cancel debounce timer when relative mouse mode is disabled
|
||||||
_ffi.inputModel.onRelativeMouseModeDisabled =
|
_ffi.inputModel.onRelativeMouseModeDisabled =
|
||||||
_cancelPointerLockCenterDebounceTimer;
|
_cancelPointerLockCenterDebounceTimer;
|
||||||
|
|
||||||
|
_waylandKeyboardModeWorker = ever(_ffi.ffiModel.pi.isSet, (bool isSet) {
|
||||||
|
if (isSet) {
|
||||||
|
unawaited(_normalizeWaylandKeyboardModeIfNeeded());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (_ffi.ffiModel.pi.isSet.value) {
|
||||||
|
unawaited(_normalizeWaylandKeyboardModeIfNeeded());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _normalizeWaylandKeyboardModeIfNeeded() async {
|
||||||
|
if (!mounted ||
|
||||||
|
_waylandKeyboardModeNormalized ||
|
||||||
|
_waylandKeyboardModeNormalizing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_waylandKeyboardModeNormalizing = true;
|
||||||
|
try {
|
||||||
|
final pi = _ffi.ffiModel.pi;
|
||||||
|
if (pi.platform != kPeerPlatformLinux || !pi.isWayland) return;
|
||||||
|
final mapSupported = bind.sessionIsKeyboardModeSupported(
|
||||||
|
sessionId: sessionId, mode: kKeyMapMode);
|
||||||
|
if (!mapSupported) return;
|
||||||
|
final current = await bind.sessionGetKeyboardMode(sessionId: sessionId);
|
||||||
|
if (!mounted) return;
|
||||||
|
if (current == kKeyMapMode) {
|
||||||
|
_waylandKeyboardModeNormalized = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await bind.sessionSetKeyboardMode(
|
||||||
|
sessionId: sessionId, value: kKeyMapMode);
|
||||||
|
if (!mounted) return;
|
||||||
|
await _ffi.inputModel.updateKeyboardMode();
|
||||||
|
if (!mounted) return;
|
||||||
|
_waylandKeyboardModeNormalized = true;
|
||||||
|
} catch (e, st) {
|
||||||
|
debugPrint('Failed to normalize Wayland keyboard mode: $e');
|
||||||
|
debugPrintStack(stackTrace: st);
|
||||||
|
} finally {
|
||||||
|
_waylandKeyboardModeNormalizing = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cancel the pointer lock center debounce timer
|
/// Cancel the pointer lock center debounce timer
|
||||||
@@ -186,19 +266,224 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_pointerLockCenterDebounceTimer = null;
|
_pointerLockCenterDebounceTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get _isSelectedTab {
|
||||||
|
final controller = widget.tabController;
|
||||||
|
if (controller == null) return true;
|
||||||
|
final tabState = controller.state.value;
|
||||||
|
final selected = tabState.selected;
|
||||||
|
return selected >= 0 &&
|
||||||
|
selected < tabState.tabs.length &&
|
||||||
|
tabState.tabs[selected].key == widget.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get _isMacOSKeyboardContextActive {
|
||||||
|
return stateGlobal.isFocused.value && !_isWindowBlur && _isSelectedTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onMacOSTabStateChanged(DesktopTabState _) {
|
||||||
|
if (!_isSelectedTab) {
|
||||||
|
_macOSFullScreenFocusRecovery.cancel();
|
||||||
|
_syncMacOSKeyboardGrab();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Tab listeners run synchronously. Defer the selected page so the previous
|
||||||
|
// page releases first; a late leave from it can disable the new session.
|
||||||
|
scheduleMicrotask(() {
|
||||||
|
if (mounted) {
|
||||||
|
_syncMacOSKeyboardGrab(reassert: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _releaseMacOSRemoteInput() {
|
||||||
|
_macOSFullScreenFocusRecovery.cancel();
|
||||||
|
_macOSExplicitFocusRequestPending = false;
|
||||||
|
_macOSInputSuppressed = true;
|
||||||
|
_macOSLocalFocusLost = true;
|
||||||
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
|
_macOSInputActive = false;
|
||||||
|
_rawKeyFocusNode.unfocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onMacOSFocusChange() {
|
||||||
|
// requestFocus() notifies later; only a recorded explicit request may clear
|
||||||
|
// the local-focus-loss latch.
|
||||||
|
if (_rawKeyFocusNode.hasPrimaryFocus) {
|
||||||
|
final explicitRequest = _macOSExplicitFocusRequestPending;
|
||||||
|
_macOSExplicitFocusRequestPending = false;
|
||||||
|
if (explicitRequest && _isMacOSKeyboardContextActive) {
|
||||||
|
_macOSLocalFocusLost = false;
|
||||||
|
}
|
||||||
|
_syncMacOSKeyboardGrab(allowInactiveLifecycle: explicitRequest);
|
||||||
|
} else {
|
||||||
|
if (_macOSInputActive) {
|
||||||
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
|
_macOSInputActive = false;
|
||||||
|
}
|
||||||
|
if (_isMacOSKeyboardContextActive) {
|
||||||
|
_macOSLocalFocusLost = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Sync the keyboard grab state with the current context.
|
||||||
|
// 2. Call enterOrLeave() to update the input state in the FFI layer.
|
||||||
|
// 3. Request or unfocus the raw key focus node based on the current context.
|
||||||
|
// Flutter focus and native input are separate; native input activates only
|
||||||
|
// after the FocusNode has primary focus.
|
||||||
|
void _syncMacOSKeyboardGrab({
|
||||||
|
bool reassert = false,
|
||||||
|
bool allowInactiveLifecycle = false,
|
||||||
|
}) {
|
||||||
|
if (!isMacOS) return;
|
||||||
|
// A secondary engine may stay hidden while its window is visible, so
|
||||||
|
// explicit pointer/fullscreen recovery must bypass the global lifecycle.
|
||||||
|
final lifecycleAllowsInput = allowInactiveLifecycle ||
|
||||||
|
_macOSLifecycleState == null ||
|
||||||
|
_macOSLifecycleState == AppLifecycleState.resumed;
|
||||||
|
// Input stays pointer-gated except for focused fullscreen recovery, which
|
||||||
|
// compensates when macOS omits PointerEnter during a Space switch.
|
||||||
|
final shouldFocus = lifecycleAllowsInput &&
|
||||||
|
_isMacOSKeyboardContextActive &&
|
||||||
|
!_macOSInputSuppressed &&
|
||||||
|
_blockableOverlayState.middleBlocked.isFalse &&
|
||||||
|
_cursorOverImage.value &&
|
||||||
|
!_macOSLocalFocusLost;
|
||||||
|
final hasFocus = _rawKeyFocusNode.hasPrimaryFocus;
|
||||||
|
final shouldActivateInput = shouldFocus && hasFocus;
|
||||||
|
|
||||||
|
if (shouldActivateInput != _macOSInputActive ||
|
||||||
|
(shouldActivateInput && reassert)) {
|
||||||
|
_ffi.inputModel.enterOrLeave(shouldActivateInput);
|
||||||
|
}
|
||||||
|
_macOSInputActive = shouldActivateInput;
|
||||||
|
|
||||||
|
if (!shouldFocus) {
|
||||||
|
_macOSExplicitFocusRequestPending = false;
|
||||||
|
if (hasFocus) _rawKeyFocusNode.unfocus();
|
||||||
|
} else if (!hasFocus) {
|
||||||
|
_macOSExplicitFocusRequestPending = allowInactiveLifecycle;
|
||||||
|
_rawKeyFocusNode.requestFocus();
|
||||||
|
} else {
|
||||||
|
_macOSExplicitFocusRequestPending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _restoreMacOSKeyboardAfterFullScreen({
|
||||||
|
required int generation,
|
||||||
|
bool allowHiddenLifecycle = false,
|
||||||
|
}) {
|
||||||
|
// Fullscreen callbacks preserve recovery while hidden. Native window focus
|
||||||
|
// may bypass a stale hidden lifecycle for the newly visible Space.
|
||||||
|
if (!_macOSFullScreenFocusRecovery.isCurrent(generation) ||
|
||||||
|
(!allowHiddenLifecycle &&
|
||||||
|
_macOSLifecycleState == AppLifecycleState.hidden)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final contextActive =
|
||||||
|
stateGlobal.isFocused.value && !_isWindowBlur && _isSelectedTab;
|
||||||
|
// macOS can focus a fullscreen Space without sending PointerEnter. Native
|
||||||
|
// window focus is authoritative here; a later blur cancels this generation
|
||||||
|
// before an off-screen window can restore input.
|
||||||
|
final shouldInferPointerInside = !_cursorOverImage.value &&
|
||||||
|
allowHiddenLifecycle &&
|
||||||
|
stateGlobal.fullscreen.isTrue &&
|
||||||
|
contextActive;
|
||||||
|
final canRestore = contextActive &&
|
||||||
|
_blockableOverlayState.middleBlocked.isFalse &&
|
||||||
|
(_cursorOverImage.value || shouldInferPointerInside);
|
||||||
|
if (!_macOSFullScreenFocusRecovery.consume(generation)) return;
|
||||||
|
if (!canRestore) {
|
||||||
|
// Consuming recovery here requires a later pointer/window/tab event.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (shouldInferPointerInside) {
|
||||||
|
_cursorOverImage.value = true;
|
||||||
|
}
|
||||||
|
_macOSLocalFocusLost = false;
|
||||||
|
stateGlobal.getInputSource(force: true);
|
||||||
|
_syncMacOSKeyboardGrab(reassert: true, allowInactiveLifecycle: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _scheduleMacOSKeyboardAfterFullScreen({
|
||||||
|
required int generation,
|
||||||
|
bool allowHiddenLifecycle = false,
|
||||||
|
}) {
|
||||||
|
// Fullscreen can deliver FocusNode loss after its callback; wait for frame
|
||||||
|
// completion and then advance one event-loop turn before restoring.
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
Timer.run(() {
|
||||||
|
if (mounted) {
|
||||||
|
_restoreMacOSKeyboardAfterFullScreen(
|
||||||
|
generation: generation,
|
||||||
|
allowHiddenLifecycle: allowHiddenLifecycle,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
WidgetsBinding.instance.ensureVisualUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _queueMacOSKeyboardAfterFullScreen({
|
||||||
|
bool allowHiddenLifecycle = false,
|
||||||
|
}) {
|
||||||
|
final generation = _macOSFullScreenFocusRecovery.queue();
|
||||||
|
if (_macOSLifecycleState == AppLifecycleState.paused ||
|
||||||
|
_macOSLifecycleState == AppLifecycleState.detached) {
|
||||||
|
_macOSFullScreenFocusRecovery.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_scheduleMacOSKeyboardAfterFullScreen(
|
||||||
|
generation: generation,
|
||||||
|
allowHiddenLifecycle: allowHiddenLifecycle,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
super.didChangeAppLifecycleState(state);
|
||||||
|
if (!isMacOS || _macOSLifecycleState == state) return;
|
||||||
|
_macOSLifecycleState = state;
|
||||||
|
if (state == AppLifecycleState.resumed) {
|
||||||
|
_syncMacOSKeyboardGrab(reassert: true);
|
||||||
|
} else if (_macOSInputActive) {
|
||||||
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
|
_macOSInputActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final generation = _macOSFullScreenFocusRecovery.pendingGeneration;
|
||||||
|
if (generation == null) return;
|
||||||
|
if (state == AppLifecycleState.inactive ||
|
||||||
|
state == AppLifecycleState.resumed) {
|
||||||
|
_scheduleMacOSKeyboardAfterFullScreen(generation: generation);
|
||||||
|
} else if (state == AppLifecycleState.paused ||
|
||||||
|
state == AppLifecycleState.detached) {
|
||||||
|
_macOSFullScreenFocusRecovery.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowBlur() {
|
void onWindowBlur() {
|
||||||
super.onWindowBlur();
|
super.onWindowBlur();
|
||||||
// On windows, we use `focus` way to handle keyboard better.
|
// On windows, we use `focus` way to handle keyboard better.
|
||||||
// Now on Linux, there's some rdev issues which will break the input.
|
// Now on Linux, there's some rdev issues which will break the input.
|
||||||
// We disable the `focus` way for non-Windows temporarily.
|
// We disable the `focus` way for Linux temporarily.
|
||||||
if (isWindows) {
|
if (isWindows || isMacOS) {
|
||||||
_isWindowBlur = true;
|
_isWindowBlur = true;
|
||||||
|
}
|
||||||
|
if (isMacOS) {
|
||||||
|
_macOSFullScreenFocusRecovery.cancel();
|
||||||
|
// A blur or Space switch may not emit PointerExit, so cursor state alone
|
||||||
|
// cannot prevent the old remote surface from reclaiming the keyboard.
|
||||||
|
_macOSLocalFocusLost = true;
|
||||||
|
}
|
||||||
|
if (isWindows) {
|
||||||
// unfocus the primary-focus when the whole window is lost focus,
|
// unfocus the primary-focus when the whole window is lost focus,
|
||||||
// and let OS to handle events instead.
|
// and let OS to handle events instead.
|
||||||
_rawKeyFocusNode.unfocus();
|
_rawKeyFocusNode.unfocus();
|
||||||
}
|
}
|
||||||
stateGlobal.isFocused.value = false;
|
stateGlobal.isFocused.value = false;
|
||||||
|
_syncMacOSKeyboardGrab();
|
||||||
|
|
||||||
// When window loses focus, temporarily release relative mouse mode constraints
|
// When window loses focus, temporarily release relative mouse mode constraints
|
||||||
// to allow user to interact with other applications normally.
|
// to allow user to interact with other applications normally.
|
||||||
@@ -212,16 +497,41 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
void onWindowFocus() {
|
void onWindowFocus() {
|
||||||
super.onWindowFocus();
|
super.onWindowFocus();
|
||||||
// See [onWindowBlur].
|
// See [onWindowBlur].
|
||||||
if (isWindows) {
|
if (isWindows || isMacOS) {
|
||||||
_isWindowBlur = false;
|
_isWindowBlur = false;
|
||||||
}
|
}
|
||||||
|
if (isMacOS) stateGlobal.getInputSource(force: true);
|
||||||
stateGlobal.isFocused.value = true;
|
stateGlobal.isFocused.value = true;
|
||||||
|
|
||||||
|
// Normal macOS windows wait for PointerEnter or PointerDown. A focused
|
||||||
|
// fullscreen Space queues delayed recovery; if this window blurs again, the
|
||||||
|
// pending recovery is cancelled before native input can reactivate.
|
||||||
|
// Regression: switch directly between fullscreen remote Spaces without
|
||||||
|
// moving or clicking; only the newly focused session may receive input.
|
||||||
|
if (isMacOS &&
|
||||||
|
stateGlobal.fullscreen.isTrue &&
|
||||||
|
!_ffi.inputModel.relativeMouseMode.value) {
|
||||||
|
// Native window focus is authoritative when a secondary engine retains a
|
||||||
|
// stale hidden lifecycle state after its fullscreen Space becomes visible.
|
||||||
|
_queueMacOSKeyboardAfterFullScreen(allowHiddenLifecycle: true);
|
||||||
|
}
|
||||||
|
|
||||||
// Restore relative mouse mode constraints when window regains focus.
|
// Restore relative mouse mode constraints when window regains focus.
|
||||||
if (_ffi.inputModel.relativeMouseMode.value) {
|
if (_ffi.inputModel.relativeMouseMode.value) {
|
||||||
_rawKeyFocusNode.requestFocus();
|
if (isMacOS) {
|
||||||
|
// Native relative mode retains pointer capture and does not emit
|
||||||
|
// PointerEnter after window focus returns. Restore both latches unless
|
||||||
|
// a local overlay still owns input.
|
||||||
|
if (_blockableOverlayState.middleBlocked.isFalse) {
|
||||||
|
_cursorOverImage.value = true;
|
||||||
|
_macOSLocalFocusLost = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_rawKeyFocusNode.requestFocus();
|
||||||
|
}
|
||||||
_ffi.inputModel.onWindowFocus();
|
_ffi.inputModel.onWindowFocus();
|
||||||
}
|
}
|
||||||
|
_syncMacOSKeyboardGrab(reassert: true, allowInactiveLifecycle: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -282,6 +592,13 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
void onWindowMinimize() {
|
void onWindowMinimize() {
|
||||||
super.onWindowMinimize();
|
super.onWindowMinimize();
|
||||||
WakelockManager.disable(_uniqueKey);
|
WakelockManager.disable(_uniqueKey);
|
||||||
|
if (isMacOS) {
|
||||||
|
_macOSFullScreenFocusRecovery.cancel();
|
||||||
|
_isWindowBlur = true;
|
||||||
|
_cursorOverImage.value = false;
|
||||||
|
stateGlobal.isFocused.value = false;
|
||||||
|
_syncMacOSKeyboardGrab();
|
||||||
|
}
|
||||||
// Release cursor constraints when minimized
|
// Release cursor constraints when minimized
|
||||||
if (_ffi.inputModel.relativeMouseMode.value) {
|
if (_ffi.inputModel.relativeMouseMode.value) {
|
||||||
_ffi.inputModel.onWindowBlur();
|
_ffi.inputModel.onWindowBlur();
|
||||||
@@ -293,6 +610,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
super.onWindowEnterFullScreen();
|
super.onWindowEnterFullScreen();
|
||||||
if (isMacOS) {
|
if (isMacOS) {
|
||||||
stateGlobal.setFullscreen(true);
|
stateGlobal.setFullscreen(true);
|
||||||
|
_queueMacOSKeyboardAfterFullScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +619,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
super.onWindowLeaveFullScreen();
|
super.onWindowLeaveFullScreen();
|
||||||
if (isMacOS) {
|
if (isMacOS) {
|
||||||
stateGlobal.setFullscreen(false);
|
stateGlobal.setFullscreen(false);
|
||||||
|
_queueMacOSKeyboardAfterFullScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,6 +628,14 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
final closeSession = closeSessionOnDispose.remove(widget.id) ?? true;
|
final closeSession = closeSessionOnDispose.remove(widget.id) ?? true;
|
||||||
|
|
||||||
// https://github.com/flutter/flutter/issues/64935
|
// https://github.com/flutter/flutter/issues/64935
|
||||||
|
if (isMacOS) {
|
||||||
|
// Tab moves release before transfer to avoid a late retained-session leave.
|
||||||
|
if (closeSession) {
|
||||||
|
_releaseMacOSRemoteInput();
|
||||||
|
}
|
||||||
|
_tabStateSubscription?.cancel();
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
debugPrint("REMOTE PAGE dispose session $sessionId ${widget.id}");
|
debugPrint("REMOTE PAGE dispose session $sessionId ${widget.id}");
|
||||||
|
|
||||||
@@ -318,12 +645,14 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
|
|
||||||
_pointerLockCenterDebounceTimer?.cancel();
|
_pointerLockCenterDebounceTimer?.cancel();
|
||||||
_pointerLockCenterDebounceTimer = null;
|
_pointerLockCenterDebounceTimer = null;
|
||||||
|
_waylandKeyboardModeWorker?.dispose();
|
||||||
// Clear callback reference to prevent memory leaks and stale references
|
// Clear callback reference to prevent memory leaks and stale references
|
||||||
_ffi.inputModel.onRelativeMouseModeDisabled = null;
|
_ffi.inputModel.onRelativeMouseModeDisabled = null;
|
||||||
// Relative mouse mode cleanup is centralized in FFI.close(closeSession: ...).
|
// Relative mouse mode cleanup is centralized in FFI.close(closeSession: ...).
|
||||||
_ffi.textureModel.onRemotePageDispose(closeSession);
|
_ffi.textureModel.onRemotePageDispose();
|
||||||
if (closeSession) {
|
if (closeSession && !isMacOS) {
|
||||||
// ensure we leave this session, this is a double check
|
// ensure we leave this session, this is a double check
|
||||||
|
// enterOrLeave() is already called previously in _releaseMacOSRemoteInput() for macOS.
|
||||||
_ffi.inputModel.enterOrLeave(false);
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
}
|
}
|
||||||
DesktopMultiWindow.removeListener(this);
|
DesktopMultiWindow.removeListener(this);
|
||||||
@@ -331,6 +660,9 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_ffi.imageModel.disposeImage();
|
_ffi.imageModel.disposeImage();
|
||||||
_ffi.cursorModel.disposeImages();
|
_ffi.cursorModel.disposeImages();
|
||||||
_rawKeyFocusNode.dispose();
|
_rawKeyFocusNode.dispose();
|
||||||
|
if (closeSession) {
|
||||||
|
clearWaylandKeyboardPromptSuppressedForConnection(sessionId.toString());
|
||||||
|
}
|
||||||
await _ffi.close(closeSession: closeSession);
|
await _ffi.close(closeSession: closeSession);
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_ffi.dialogManager.dismissAll();
|
_ffi.dialogManager.dismissAll();
|
||||||
@@ -395,6 +727,8 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
} else {
|
} else {
|
||||||
_ffi.inputModel.enterOrLeave(false);
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
}
|
}
|
||||||
|
} else if (isMacOS) {
|
||||||
|
_onMacOSFocusChange();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputModel: _ffi.inputModel,
|
inputModel: _ffi.inputModel,
|
||||||
@@ -500,7 +834,11 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See [onWindowBlur].
|
// See [onWindowBlur].
|
||||||
if (!isWindows) {
|
if (isMacOS) {
|
||||||
|
_macOSLocalFocusLost = false;
|
||||||
|
stateGlobal.getInputSource(force: true);
|
||||||
|
_syncMacOSKeyboardGrab(reassert: true, allowInactiveLifecycle: true);
|
||||||
|
} else if (!isWindows) {
|
||||||
if (!_rawKeyFocusNode.hasFocus) {
|
if (!_rawKeyFocusNode.hasFocus) {
|
||||||
_rawKeyFocusNode.requestFocus();
|
_rawKeyFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
@@ -526,7 +864,9 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See [onWindowBlur].
|
// See [onWindowBlur].
|
||||||
if (!isWindows) {
|
if (isMacOS) {
|
||||||
|
_syncMacOSKeyboardGrab();
|
||||||
|
} else if (!isWindows) {
|
||||||
_ffi.inputModel.enterOrLeave(false);
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,17 +891,29 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
onEnter: onEnter,
|
onEnter: onEnter,
|
||||||
onExit: onExit,
|
onExit: onExit,
|
||||||
onPointerDown: (event) {
|
onPointerDown: (event) {
|
||||||
// A double check for blur status.
|
// A double check for blur status on Windows and macOS.
|
||||||
// Note: If there's an `onPointerDown` event is triggered, `_isWindowBlur` is expected being false.
|
// Note: If there's an `onPointerDown` event is triggered, `_isWindowBlur` is expected being false.
|
||||||
// Sometimes the system does not send the necessary focus event to flutter. We should manually
|
// Sometimes the system does not send the necessary focus event to flutter. We should manually
|
||||||
// handle this inconsistent status by setting `_isWindowBlur` to false. So we can
|
// handle this inconsistent status by setting `_isWindowBlur` to false. So we can
|
||||||
// ensure the grab-key thread is running when our users are clicking the remote canvas.
|
// ensure the grab-key thread is running when our users are clicking the remote canvas.
|
||||||
if (_isWindowBlur) {
|
if ((isWindows || isMacOS) && _isWindowBlur) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"Unexpected status: onPointerDown is triggered while the remote window is in blur status");
|
"Unexpected status: onPointerDown is triggered while the remote window is in blur status");
|
||||||
_isWindowBlur = false;
|
_isWindowBlur = false;
|
||||||
}
|
}
|
||||||
if (!_rawKeyFocusNode.hasFocus) {
|
if (isMacOS) {
|
||||||
|
// Regions without matching enter/exit callbacks cannot safely own
|
||||||
|
// keyboard state.
|
||||||
|
if (onEnter == null || onExit == null) return;
|
||||||
|
if (!stateGlobal.isFocused.value) {
|
||||||
|
stateGlobal.isFocused.value = true;
|
||||||
|
}
|
||||||
|
_cursorOverImage.value = true;
|
||||||
|
_macOSLocalFocusLost = false;
|
||||||
|
stateGlobal.getInputSource(force: true);
|
||||||
|
_syncMacOSKeyboardGrab(
|
||||||
|
reassert: !isInputSourceFlutter, allowInactiveLifecycle: true);
|
||||||
|
} else if (!_rawKeyFocusNode.hasFocus) {
|
||||||
_rawKeyFocusNode.requestFocus();
|
_rawKeyFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1052,3 +1404,4 @@ class CursorPaint extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -513,15 +513,17 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
final args = jsonDecode(call.arguments);
|
final args = jsonDecode(call.arguments);
|
||||||
final id = args['id'];
|
final id = args['id'];
|
||||||
final close = args['close'];
|
final close = args['close'];
|
||||||
|
RemotePage? remotePage;
|
||||||
try {
|
try {
|
||||||
final remotePage = tabController.state.value.tabs
|
remotePage = tabController.state.value.tabs
|
||||||
.firstWhere((tab) => tab.key == id)
|
.firstWhere((tab) => tab.key == id)
|
||||||
.page as RemotePage;
|
.page as RemotePage;
|
||||||
returnValue = remotePage.ffi.ffiModel.cachedPeerData.toString();
|
returnValue = remotePage.ffi.ffiModel.cachedPeerData.toString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Failed to get cached session data: $e');
|
debugPrint('Failed to get cached session data: $e');
|
||||||
}
|
}
|
||||||
if (close && returnValue != null) {
|
if (close && returnValue != null && remotePage != null) {
|
||||||
|
remotePage.releaseMacOSInputForTabTransfer();
|
||||||
closeSessionOnDispose[id] = false;
|
closeSessionOnDispose[id] = false;
|
||||||
tabController.closeBy(id);
|
tabController.closeBy(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -462,23 +462,7 @@ class _CmHeaderState extends State<_CmHeader>
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
_buildClientAvatar().marginOnly(right: 10.0),
|
||||||
width: 70,
|
|
||||||
height: 70,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: str2color(client.name),
|
|
||||||
borderRadius: BorderRadius.circular(15.0),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
client.name[0],
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 55,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
).marginOnly(right: 10.0),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@@ -511,14 +495,14 @@ class _CmHeaderState extends State<_CmHeader>
|
|||||||
if (client.type_() == ClientType.file)
|
if (client.type_() == ClientType.file)
|
||||||
FittedBox(
|
FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
translate("File Transfer"),
|
translate("Transfer file"),
|
||||||
style: TextStyle(color: Colors.white70, fontSize: 12),
|
style: TextStyle(color: Colors.white70, fontSize: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (client.type_() == ClientType.camera)
|
if (client.type_() == ClientType.camera)
|
||||||
FittedBox(
|
FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
translate("View Camera"),
|
translate("View camera"),
|
||||||
style: TextStyle(color: Colors.white70, fontSize: 12),
|
style: TextStyle(color: Colors.white70, fontSize: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -582,6 +566,36 @@ class _CmHeaderState extends State<_CmHeader>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
|
Widget _buildClientAvatar() {
|
||||||
|
return buildAvatarWidget(
|
||||||
|
avatar: client.avatar,
|
||||||
|
size: 70,
|
||||||
|
borderRadius: 15,
|
||||||
|
fallback: _buildInitialAvatar(),
|
||||||
|
) ??
|
||||||
|
_buildInitialAvatar();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildInitialAvatar() {
|
||||||
|
return Container(
|
||||||
|
width: 70,
|
||||||
|
height: 70,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: str2color(client.name),
|
||||||
|
borderRadius: BorderRadius.circular(15.0),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
client.name.isNotEmpty ? client.name[0] : '?',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 55,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PrivilegeBoard extends StatefulWidget {
|
class _PrivilegeBoard extends StatefulWidget {
|
||||||
@@ -596,19 +610,24 @@ class _PrivilegeBoard extends StatefulWidget {
|
|||||||
class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
||||||
late final client = widget.client;
|
late final client = widget.client;
|
||||||
Widget buildPermissionIcon(bool enabled, IconData iconData,
|
Widget buildPermissionIcon(bool enabled, IconData iconData,
|
||||||
Function(bool)? onTap, String tooltipText) {
|
Function(bool)? onTap, String tooltipText,
|
||||||
|
{required bool canModify}) {
|
||||||
return Tooltip(
|
return Tooltip(
|
||||||
message: "$tooltipText: ${enabled ? "ON" : "OFF"}",
|
message: "$tooltipText: ${enabled ? "ON" : "OFF"}",
|
||||||
waitDuration: Duration.zero,
|
waitDuration: Duration.zero,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: enabled ? MyTheme.accent : Colors.grey[700],
|
color: enabled
|
||||||
|
? (canModify ? MyTheme.accent : MyTheme.accent.withOpacity(0.6))
|
||||||
|
: Colors.grey[700],
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () =>
|
onTap: canModify
|
||||||
checkClickTime(widget.client.id, () => onTap?.call(!enabled)),
|
? () =>
|
||||||
|
checkClickTime(widget.client.id, () => onTap?.call(!enabled))
|
||||||
|
: null,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
@@ -629,6 +648,9 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final crossAxisCount = 4;
|
final crossAxisCount = 4;
|
||||||
final spacing = 10.0;
|
final spacing = 10.0;
|
||||||
|
final canModifyPermission =
|
||||||
|
bind.mainGetBuildinOption(key: kOptionEnablePermChangeInAcceptWindow) !=
|
||||||
|
'N';
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 160.0,
|
height: 160.0,
|
||||||
@@ -675,6 +697,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable audio'),
|
translate('Enable audio'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
buildPermissionIcon(
|
buildPermissionIcon(
|
||||||
client.recording,
|
client.recording,
|
||||||
@@ -689,6 +712,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable recording session'),
|
translate('Enable recording session'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
@@ -705,6 +729,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable keyboard/mouse'),
|
translate('Enable keyboard/mouse'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
buildPermissionIcon(
|
buildPermissionIcon(
|
||||||
client.clipboard,
|
client.clipboard,
|
||||||
@@ -719,6 +744,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable clipboard'),
|
translate('Enable clipboard'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
buildPermissionIcon(
|
buildPermissionIcon(
|
||||||
client.audio,
|
client.audio,
|
||||||
@@ -733,6 +759,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable audio'),
|
translate('Enable audio'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
buildPermissionIcon(
|
buildPermissionIcon(
|
||||||
client.file,
|
client.file,
|
||||||
@@ -747,6 +774,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable file copy and paste'),
|
translate('Enable file copy and paste'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
buildPermissionIcon(
|
buildPermissionIcon(
|
||||||
client.restart,
|
client.restart,
|
||||||
@@ -761,6 +789,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable remote restart'),
|
translate('Enable remote restart'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
buildPermissionIcon(
|
buildPermissionIcon(
|
||||||
client.recording,
|
client.recording,
|
||||||
@@ -775,6 +804,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable recording session'),
|
translate('Enable recording session'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
),
|
),
|
||||||
// only windows support block input
|
// only windows support block input
|
||||||
if (isWindows)
|
if (isWindows)
|
||||||
@@ -791,6 +821,23 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
translate('Enable blocking user input'),
|
translate('Enable blocking user input'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
|
),
|
||||||
|
if (bind.mainSupportedPrivacyModeImpls() != '[]')
|
||||||
|
buildPermissionIcon(
|
||||||
|
client.privacyMode,
|
||||||
|
Icons.visibility_off,
|
||||||
|
(enabled) {
|
||||||
|
bind.cmSwitchPermission(
|
||||||
|
connId: client.id,
|
||||||
|
name: "privacy_mode",
|
||||||
|
enabled: enabled);
|
||||||
|
setState(() {
|
||||||
|
client.privacyMode = enabled;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
translate('Enable privacy mode'),
|
||||||
|
canModify: canModifyPermission,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
@@ -15,6 +16,7 @@ class TerminalPage extends StatefulWidget {
|
|||||||
required this.tabController,
|
required this.tabController,
|
||||||
required this.isSharedPassword,
|
required this.isSharedPassword,
|
||||||
required this.terminalId,
|
required this.terminalId,
|
||||||
|
required this.tabKey,
|
||||||
this.forceRelay,
|
this.forceRelay,
|
||||||
this.connToken,
|
this.connToken,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@@ -25,6 +27,9 @@ class TerminalPage extends StatefulWidget {
|
|||||||
final bool? isSharedPassword;
|
final bool? isSharedPassword;
|
||||||
final String? connToken;
|
final String? connToken;
|
||||||
final int terminalId;
|
final int terminalId;
|
||||||
|
|
||||||
|
/// Tab key for focus management, passed from parent to avoid duplicate construction
|
||||||
|
final String tabKey;
|
||||||
final SimpleWrapper<State<TerminalPage>?> _lastState = SimpleWrapper(null);
|
final SimpleWrapper<State<TerminalPage>?> _lastState = SimpleWrapper(null);
|
||||||
|
|
||||||
FFI get ffi => (_lastState.value! as _TerminalPageState)._ffi;
|
FFI get ffi => (_lastState.value! as _TerminalPageState)._ffi;
|
||||||
@@ -39,14 +44,22 @@ class TerminalPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _TerminalPageState extends State<TerminalPage>
|
class _TerminalPageState extends State<TerminalPage>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
static const EdgeInsets _defaultTerminalPadding =
|
||||||
|
EdgeInsets.symmetric(horizontal: 5.0, vertical: 2.0);
|
||||||
|
|
||||||
late FFI _ffi;
|
late FFI _ffi;
|
||||||
late TerminalModel _terminalModel;
|
late TerminalModel _terminalModel;
|
||||||
double? _cellHeight;
|
double? _cellHeight;
|
||||||
|
final FocusNode _terminalFocusNode = FocusNode(canRequestFocus: false);
|
||||||
|
StreamSubscription<DesktopTabState>? _tabStateSubscription;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
// Listen for tab selection changes to request focus
|
||||||
|
_tabStateSubscription = widget.tabController.state.listen(_onTabStateChanged);
|
||||||
|
|
||||||
// Use shared FFI instance from connection manager
|
// Use shared FFI instance from connection manager
|
||||||
_ffi = TerminalConnectionManager.getConnection(
|
_ffi = TerminalConnectionManager.getConnection(
|
||||||
peerId: widget.id,
|
peerId: widget.id,
|
||||||
@@ -64,6 +77,13 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
_terminalModel.onResizeExternal = (w, h, pw, ph) {
|
_terminalModel.onResizeExternal = (w, h, pw, ph) {
|
||||||
_cellHeight = ph * 1.0;
|
_cellHeight = ph * 1.0;
|
||||||
|
|
||||||
|
// Enable focus once terminal has valid dimensions (first valid resize)
|
||||||
|
if (!_terminalFocusNode.canRequestFocus && w > 0 && h > 0) {
|
||||||
|
_terminalFocusNode.canRequestFocus = true;
|
||||||
|
// Auto-focus if this tab is currently selected
|
||||||
|
_requestFocusIfSelected();
|
||||||
|
}
|
||||||
|
|
||||||
// Schedule the setState for the next frame
|
// Schedule the setState for the next frame
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
@@ -75,6 +95,13 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
// Register this terminal model with FFI for event routing
|
// Register this terminal model with FFI for event routing
|
||||||
_ffi.registerTerminalModel(widget.terminalId, _terminalModel);
|
_ffi.registerTerminalModel(widget.terminalId, _terminalModel);
|
||||||
|
|
||||||
|
// Auto-close tab when shell exits
|
||||||
|
_terminalModel.onClosed = () {
|
||||||
|
if (mounted) {
|
||||||
|
widget.tabController.closeBy(widget.tabKey);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize terminal connection
|
// Initialize terminal connection
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
widget.tabController.onSelected?.call(widget.id);
|
widget.tabController.onSelected?.call(widget.id);
|
||||||
@@ -99,25 +126,67 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
// Cancel tab state subscription to prevent memory leak
|
||||||
|
_tabStateSubscription?.cancel();
|
||||||
// Unregister terminal model from FFI
|
// Unregister terminal model from FFI
|
||||||
_ffi.unregisterTerminalModel(widget.terminalId);
|
_ffi.unregisterTerminalModel(widget.terminalId);
|
||||||
_terminalModel.dispose();
|
_terminalModel.dispose();
|
||||||
|
_terminalFocusNode.dispose();
|
||||||
// Release connection reference instead of closing directly
|
// Release connection reference instead of closing directly
|
||||||
TerminalConnectionManager.releaseConnection(widget.id);
|
TerminalConnectionManager.releaseConnection(widget.id);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onTabStateChanged(DesktopTabState state) {
|
||||||
|
// Check if this tab is now selected and request focus
|
||||||
|
if (state.selected >= 0 && state.selected < state.tabs.length) {
|
||||||
|
final selectedTab = state.tabs[state.selected];
|
||||||
|
if (selectedTab.key == widget.tabKey && mounted) {
|
||||||
|
_requestFocusIfSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _requestFocusIfSelected() {
|
||||||
|
if (!mounted || !_terminalFocusNode.canRequestFocus) return;
|
||||||
|
// Use post-frame callback to ensure widget is fully laid out in focus tree
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
// Re-check conditions after frame: mounted, focusable, still selected, not already focused
|
||||||
|
if (!mounted || !_terminalFocusNode.canRequestFocus || _terminalFocusNode.hasFocus) return;
|
||||||
|
final state = widget.tabController.state.value;
|
||||||
|
if (state.selected >= 0 && state.selected < state.tabs.length) {
|
||||||
|
if (state.tabs[state.selected].key == widget.tabKey) {
|
||||||
|
_terminalFocusNode.requestFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// This method ensures that the number of visible rows is an integer by computing the
|
// This method ensures that the number of visible rows is an integer by computing the
|
||||||
// extra space left after dividing the available height by the height of a single
|
// extra space left after dividing the available height by the height of a single
|
||||||
// terminal row (`_cellHeight`) and distributing it evenly as top and bottom padding.
|
// terminal row (`_cellHeight`) and distributing it evenly as top and bottom padding.
|
||||||
EdgeInsets _calculatePadding(double heightPx) {
|
EdgeInsets _calculatePadding(double heightPx) {
|
||||||
if (_cellHeight == null) {
|
final cellHeight = _cellHeight;
|
||||||
return const EdgeInsets.symmetric(horizontal: 5.0, vertical: 2.0);
|
if (!heightPx.isFinite ||
|
||||||
|
heightPx <= 0 ||
|
||||||
|
cellHeight == null ||
|
||||||
|
!cellHeight.isFinite ||
|
||||||
|
cellHeight <= 0) {
|
||||||
|
return _defaultTerminalPadding;
|
||||||
|
}
|
||||||
|
final rows = (heightPx / cellHeight).floor();
|
||||||
|
if (rows <= 0) {
|
||||||
|
return _defaultTerminalPadding;
|
||||||
|
}
|
||||||
|
final extraSpace = heightPx - rows * cellHeight;
|
||||||
|
if (!extraSpace.isFinite || extraSpace < 0) {
|
||||||
|
return _defaultTerminalPadding;
|
||||||
}
|
}
|
||||||
final rows = (heightPx / _cellHeight!).floor();
|
|
||||||
final extraSpace = heightPx - rows * _cellHeight!;
|
|
||||||
final topBottom = extraSpace / 2.0;
|
final topBottom = extraSpace / 2.0;
|
||||||
return EdgeInsets.symmetric(horizontal: 5.0, vertical: topBottom);
|
return EdgeInsets.symmetric(
|
||||||
|
horizontal: _defaultTerminalPadding.horizontal / 2,
|
||||||
|
vertical: topBottom,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -131,7 +200,9 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
return TerminalView(
|
return TerminalView(
|
||||||
_terminalModel.terminal,
|
_terminalModel.terminal,
|
||||||
controller: _terminalModel.terminalController,
|
controller: _terminalModel.terminalController,
|
||||||
autofocus: true,
|
focusNode: _terminalFocusNode,
|
||||||
|
// Note: autofocus is not used here because focus is managed manually
|
||||||
|
// via _onTabStateChanged() to handle tab switching properly.
|
||||||
backgroundOpacity: 0.7,
|
backgroundOpacity: 0.7,
|
||||||
padding: _calculatePadding(heightPx),
|
padding: _calculatePadding(heightPx),
|
||||||
onSecondaryTapDown: (details, offset) async {
|
onSecondaryTapDown: (details, offset) async {
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
static const IconData selectedIcon = Icons.terminal;
|
static const IconData selectedIcon = Icons.terminal;
|
||||||
static const IconData unselectedIcon = Icons.terminal_outlined;
|
static const IconData unselectedIcon = Icons.terminal_outlined;
|
||||||
int _nextTerminalId = 1;
|
int _nextTerminalId = 1;
|
||||||
|
// Lightweight idempotency guard for async close operations
|
||||||
|
final Set<String> _closingTabs = {};
|
||||||
|
// When true, all session cleanup should persist (window-level close in progress)
|
||||||
|
bool _windowClosing = false;
|
||||||
|
|
||||||
_TerminalTabPageState(Map<String, dynamic> params) {
|
_TerminalTabPageState(Map<String, dynamic> params) {
|
||||||
Get.put(DesktopTabController(tabType: DesktopTabType.terminal));
|
Get.put(DesktopTabController(tabType: DesktopTabType.terminal));
|
||||||
@@ -42,6 +46,7 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
.setTitle(getWindowNameWithId(id));
|
.setTitle(getWindowNameWithId(id));
|
||||||
};
|
};
|
||||||
tabController.onRemoved = (_, id) => onRemoveId(id);
|
tabController.onRemoved = (_, id) => onRemoveId(id);
|
||||||
|
tabController.onCloseWindow = _closeWindowFromConnection;
|
||||||
final terminalId = params['terminalId'] ?? _nextTerminalId++;
|
final terminalId = params['terminalId'] ?? _nextTerminalId++;
|
||||||
tabController.add(_createTerminalTab(
|
tabController.add(_createTerminalTab(
|
||||||
peerId: params['id'],
|
peerId: params['id'],
|
||||||
@@ -70,28 +75,12 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
label: tabLabel,
|
label: tabLabel,
|
||||||
selectedIcon: selectedIcon,
|
selectedIcon: selectedIcon,
|
||||||
unselectedIcon: unselectedIcon,
|
unselectedIcon: unselectedIcon,
|
||||||
onTabCloseButton: () async {
|
onTabCloseButton: () => _closeTab(tabKey),
|
||||||
if (await desktopTryShowTabAuditDialogCloseCancelled(
|
|
||||||
id: tabKey,
|
|
||||||
tabController: tabController,
|
|
||||||
)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Close the terminal session first
|
|
||||||
final ffi = TerminalConnectionManager.getExistingConnection(peerId);
|
|
||||||
if (ffi != null) {
|
|
||||||
final terminalModel = ffi.terminalModels[terminalId];
|
|
||||||
if (terminalModel != null) {
|
|
||||||
await terminalModel.closeTerminal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Then close the tab
|
|
||||||
tabController.closeBy(tabKey);
|
|
||||||
},
|
|
||||||
page: TerminalPage(
|
page: TerminalPage(
|
||||||
key: ValueKey(tabKey),
|
key: ValueKey(tabKey),
|
||||||
id: peerId,
|
id: peerId,
|
||||||
terminalId: terminalId,
|
terminalId: terminalId,
|
||||||
|
tabKey: tabKey,
|
||||||
password: password,
|
password: password,
|
||||||
isSharedPassword: isSharedPassword,
|
isSharedPassword: isSharedPassword,
|
||||||
tabController: tabController,
|
tabController: tabController,
|
||||||
@@ -101,6 +90,161 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unified tab close handler for all close paths (button, shortcut, programmatic).
|
||||||
|
/// Shows audit dialog, cleans up session if not persistent, then removes the UI tab.
|
||||||
|
Future<void> _closeTab(String tabKey) async {
|
||||||
|
// Idempotency guard: skip if already closing this tab
|
||||||
|
if (_closingTabs.contains(tabKey)) return;
|
||||||
|
_closingTabs.add(tabKey);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Snapshot peerTabCount BEFORE any await to avoid race with concurrent
|
||||||
|
// _closeAllTabs clearing tabController (which would make the live count
|
||||||
|
// drop to 0 and incorrectly trigger session persistence).
|
||||||
|
// Note: the snapshot may become stale if other individual tabs are closed
|
||||||
|
// during the audit dialog, but this is an acceptable trade-off.
|
||||||
|
int? snapshotPeerTabCount;
|
||||||
|
final parsed = _parseTabKey(tabKey);
|
||||||
|
if (parsed != null) {
|
||||||
|
final (peerId, _) = parsed;
|
||||||
|
snapshotPeerTabCount = tabController.state.value.tabs.where((t) {
|
||||||
|
final p = _parseTabKey(t.key);
|
||||||
|
return p != null && p.$1 == peerId;
|
||||||
|
}).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await desktopTryShowTabAuditDialogCloseCancelled(
|
||||||
|
id: tabKey,
|
||||||
|
tabController: tabController,
|
||||||
|
)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close terminal session if not in persistent mode.
|
||||||
|
// Wrapped separately so session cleanup failure never blocks UI tab removal.
|
||||||
|
try {
|
||||||
|
await _closeTerminalSessionIfNeeded(tabKey,
|
||||||
|
peerTabCount: snapshotPeerTabCount);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('[TerminalTabPage] Session cleanup failed for $tabKey: $e');
|
||||||
|
}
|
||||||
|
// Always close the tab from UI, regardless of session cleanup result
|
||||||
|
tabController.closeBy(tabKey);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('[TerminalTabPage] Error closing tab $tabKey: $e');
|
||||||
|
} finally {
|
||||||
|
_closingTabs.remove(tabKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Close all tabs with session cleanup.
|
||||||
|
/// Used for window-level close operations (onDestroy, handleWindowCloseButton).
|
||||||
|
/// UI tabs are removed immediately; session cleanup runs in parallel with a
|
||||||
|
/// bounded timeout so window close is not blocked indefinitely.
|
||||||
|
Future<void> _closeAllTabs() async {
|
||||||
|
_windowClosing = true;
|
||||||
|
final tabKeys = tabController.state.value.tabs.map((t) => t.key).toList();
|
||||||
|
// Remove all UI tabs immediately (same instant behavior as the old tabController.clear())
|
||||||
|
// Keep the cleanup target lookup below synchronous before its first await:
|
||||||
|
// it relies on the current frame still retaining each TerminalPage's FFI/model.
|
||||||
|
tabController.clear();
|
||||||
|
// Run session cleanup in parallel with bounded timeout (closeTerminal() has internal 3s timeout).
|
||||||
|
// Skip tabs already being closed by a concurrent _closeTab() to avoid duplicate FFI calls.
|
||||||
|
final futures = tabKeys
|
||||||
|
.where((tabKey) => !_closingTabs.contains(tabKey))
|
||||||
|
.map((tabKey) async {
|
||||||
|
try {
|
||||||
|
await _closeTerminalSessionIfNeeded(tabKey, persistAll: true);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('[TerminalTabPage] Session cleanup failed for $tabKey: $e');
|
||||||
|
}
|
||||||
|
}).toList();
|
||||||
|
if (futures.isNotEmpty) {
|
||||||
|
await Future.wait(futures).timeout(
|
||||||
|
const Duration(seconds: 4),
|
||||||
|
onTimeout: () {
|
||||||
|
debugPrint(
|
||||||
|
'[TerminalTabPage] Session cleanup timed out for batch close');
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Close the terminal session on server side based on persistent mode.
|
||||||
|
///
|
||||||
|
/// [persistAll] controls behavior when persistent mode is enabled:
|
||||||
|
/// - `true` (window close): persist all sessions, don't close any.
|
||||||
|
/// - `false` (tab close): only persist the last session for the peer,
|
||||||
|
/// close others so only the most recent disconnected session survives.
|
||||||
|
///
|
||||||
|
/// Note: if [_windowClosing] is true, persistAll is forced to true so that
|
||||||
|
/// in-flight _closeTab() calls don't accidentally close sessions that the
|
||||||
|
/// window-close flow intends to preserve.
|
||||||
|
Future<void> _closeTerminalSessionIfNeeded(String tabKey,
|
||||||
|
{bool persistAll = false, int? peerTabCount}) async {
|
||||||
|
// If window close is in progress, override to persist all sessions
|
||||||
|
// even if this call originated from an individual tab close.
|
||||||
|
if (_windowClosing) {
|
||||||
|
persistAll = true;
|
||||||
|
}
|
||||||
|
final parsed = _parseTabKey(tabKey);
|
||||||
|
if (parsed == null) return;
|
||||||
|
final (peerId, terminalId) = parsed;
|
||||||
|
|
||||||
|
final ffi = TerminalConnectionManager.getExistingConnection(peerId);
|
||||||
|
if (ffi == null) return;
|
||||||
|
|
||||||
|
final isPersistent = bind.sessionGetToggleOptionSync(
|
||||||
|
sessionId: ffi.sessionId,
|
||||||
|
arg: kOptionTerminalPersistent,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isPersistent) {
|
||||||
|
if (persistAll) {
|
||||||
|
// Window close: persist all sessions
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Tab close: only persist if this is the last tab for this peer.
|
||||||
|
// Use the snapshot value if provided (avoids race with concurrent tab removal).
|
||||||
|
final effectivePeerTabCount = peerTabCount ??
|
||||||
|
tabController.state.value.tabs.where((t) {
|
||||||
|
final p = _parseTabKey(t.key);
|
||||||
|
return p != null && p.$1 == peerId;
|
||||||
|
}).length;
|
||||||
|
if (effectivePeerTabCount <= 1) {
|
||||||
|
// Last tab for this peer — persist the session
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Not the last tab — fall through to close the session
|
||||||
|
}
|
||||||
|
|
||||||
|
final terminalModel = ffi.terminalModels[terminalId];
|
||||||
|
if (terminalModel != null) {
|
||||||
|
// closeTerminal() has internal 3s timeout, no need for external timeout
|
||||||
|
await terminalModel.closeTerminal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse tabKey (format: "peerId_terminalId") into its components.
|
||||||
|
/// Note: peerId may contain underscores, so we use lastIndexOf('_').
|
||||||
|
/// Returns null if tabKey format is invalid.
|
||||||
|
(String peerId, int terminalId)? _parseTabKey(String tabKey) {
|
||||||
|
final lastUnderscore = tabKey.lastIndexOf('_');
|
||||||
|
if (lastUnderscore <= 0) {
|
||||||
|
debugPrint('[TerminalTabPage] Invalid tabKey format: $tabKey');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final terminalIdStr = tabKey.substring(lastUnderscore + 1);
|
||||||
|
final terminalId = int.tryParse(terminalIdStr);
|
||||||
|
if (terminalId == null) {
|
||||||
|
debugPrint('[TerminalTabPage] Invalid terminalId in tabKey: $tabKey');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final peerId = tabKey.substring(0, lastUnderscore);
|
||||||
|
return (peerId, terminalId);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _tabMenuBuilder(String peerId, CancelFunc cancelFunc) {
|
Widget _tabMenuBuilder(String peerId, CancelFunc cancelFunc) {
|
||||||
final List<MenuEntryBase<String>> menu = [];
|
final List<MenuEntryBase<String>> menu = [];
|
||||||
const EdgeInsets padding = EdgeInsets.only(left: 8.0, right: 5.0);
|
const EdgeInsets padding = EdgeInsets.only(left: 8.0, right: 5.0);
|
||||||
@@ -184,7 +328,8 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
} else if (call.method == kWindowEventRestoreTerminalSessions) {
|
} else if (call.method == kWindowEventRestoreTerminalSessions) {
|
||||||
_restoreSessions(call.arguments);
|
_restoreSessions(call.arguments);
|
||||||
} else if (call.method == "onDestroy") {
|
} else if (call.method == "onDestroy") {
|
||||||
tabController.clear();
|
// Clean up sessions before window destruction (bounded wait)
|
||||||
|
await _closeAllTabs();
|
||||||
} else if (call.method == kWindowActionRebuild) {
|
} else if (call.method == kWindowActionRebuild) {
|
||||||
reloadCurrentWindow();
|
reloadCurrentWindow();
|
||||||
} else if (call.method == kWindowEventActiveSession) {
|
} else if (call.method == kWindowEventActiveSession) {
|
||||||
@@ -194,7 +339,10 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
final currentTab = tabController.state.value.selectedTabInfo;
|
final currentTab = tabController.state.value.selectedTabInfo;
|
||||||
assert(call.arguments is String,
|
assert(call.arguments is String,
|
||||||
"Expected String arguments for kWindowEventActiveSession, got ${call.arguments.runtimeType}");
|
"Expected String arguments for kWindowEventActiveSession, got ${call.arguments.runtimeType}");
|
||||||
if (currentTab.key.startsWith(call.arguments)) {
|
// Use lastIndexOf to handle peerIds containing underscores
|
||||||
|
final lastUnderscore = currentTab.key.lastIndexOf('_');
|
||||||
|
if (lastUnderscore > 0 &&
|
||||||
|
currentTab.key.substring(0, lastUnderscore) == call.arguments) {
|
||||||
windowOnTop(windowId());
|
windowOnTop(windowId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -223,8 +371,34 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
final persistentSessions =
|
final persistentSessions =
|
||||||
args['persistent_sessions'] as List<dynamic>? ?? [];
|
args['persistent_sessions'] as List<dynamic>? ?? [];
|
||||||
final sortedSessions = persistentSessions.whereType<int>().toList()..sort();
|
final sortedSessions = persistentSessions.whereType<int>().toList()..sort();
|
||||||
|
var peerId = args['peer_id'] as String? ?? '';
|
||||||
|
if (peerId.isEmpty) {
|
||||||
|
if (tabController.state.value.tabs.isEmpty ||
|
||||||
|
tabController.state.value.selected >=
|
||||||
|
tabController.state.value.tabs.length) {
|
||||||
|
debugPrint('[TerminalTabPage] Skip restore: no selected tab');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final currentTab = tabController.state.value.selectedTabInfo;
|
||||||
|
final parsed = _parseTabKey(currentTab.key);
|
||||||
|
if (parsed == null) return;
|
||||||
|
peerId = parsed.$1;
|
||||||
|
}
|
||||||
|
final existingTerminalIds = tabController.state.value.tabs
|
||||||
|
.map((tab) => _parseTabKey(tab.key))
|
||||||
|
.where((parsed) => parsed != null && parsed.$1 == peerId)
|
||||||
|
.map((parsed) => parsed!.$2)
|
||||||
|
.toSet();
|
||||||
|
if (existingTerminalIds.isEmpty) {
|
||||||
|
debugPrint(
|
||||||
|
'[TerminalTabPage] Skip restore: no seed tab for peer $peerId');
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (final terminalId in sortedSessions) {
|
for (final terminalId in sortedSessions) {
|
||||||
_addNewTerminalForCurrentPeer(terminalId: terminalId);
|
if (!existingTerminalIds.add(terminalId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_addNewTerminal(peerId, terminalId: terminalId);
|
||||||
// A delay is required to ensure the UI has sufficient time to update
|
// A delay is required to ensure the UI has sufficient time to update
|
||||||
// before adding the next terminal. Without this delay, `_TerminalPageState::dispose()`
|
// before adding the next terminal. Without this delay, `_TerminalPageState::dispose()`
|
||||||
// may be called prematurely while the tab widget is still in the tab controller.
|
// may be called prematurely while the tab widget is still in the tab controller.
|
||||||
@@ -265,7 +439,7 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
// macOS: Cmd+W (standard for close tab)
|
// macOS: Cmd+W (standard for close tab)
|
||||||
final currentTab = tabController.state.value.selectedTabInfo;
|
final currentTab = tabController.state.value.selectedTabInfo;
|
||||||
if (tabController.state.value.tabs.length > 1) {
|
if (tabController.state.value.tabs.length > 1) {
|
||||||
tabController.closeBy(currentTab.key);
|
_closeTab(currentTab.key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (!isMacOS &&
|
} else if (!isMacOS &&
|
||||||
@@ -274,7 +448,7 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
// Other platforms: Ctrl+Shift+W (to avoid conflict with Ctrl+W word delete)
|
// Other platforms: Ctrl+Shift+W (to avoid conflict with Ctrl+W word delete)
|
||||||
final currentTab = tabController.state.value.selectedTabInfo;
|
final currentTab = tabController.state.value.selectedTabInfo;
|
||||||
if (tabController.state.value.tabs.length > 1) {
|
if (tabController.state.value.tabs.length > 1) {
|
||||||
tabController.closeBy(currentTab.key);
|
_closeTab(currentTab.key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +503,10 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
void _addNewTerminal(String peerId, {int? terminalId}) {
|
void _addNewTerminal(String peerId, {int? terminalId}) {
|
||||||
// Find first tab for this peer to get connection parameters
|
// Find first tab for this peer to get connection parameters
|
||||||
final firstTab = tabController.state.value.tabs.firstWhere(
|
final firstTab = tabController.state.value.tabs.firstWhere(
|
||||||
(tab) => tab.key.startsWith('$peerId\_'),
|
(tab) {
|
||||||
|
final last = tab.key.lastIndexOf('_');
|
||||||
|
return last > 0 && tab.key.substring(0, last) == peerId;
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (firstTab.page is TerminalPage) {
|
if (firstTab.page is TerminalPage) {
|
||||||
final page = firstTab.page as TerminalPage;
|
final page = firstTab.page as TerminalPage;
|
||||||
@@ -350,11 +527,10 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
|
|
||||||
void _addNewTerminalForCurrentPeer({int? terminalId}) {
|
void _addNewTerminalForCurrentPeer({int? terminalId}) {
|
||||||
final currentTab = tabController.state.value.selectedTabInfo;
|
final currentTab = tabController.state.value.selectedTabInfo;
|
||||||
final parts = currentTab.key.split('_');
|
final parsed = _parseTabKey(currentTab.key);
|
||||||
if (parts.isNotEmpty) {
|
if (parsed == null) return;
|
||||||
final peerId = parts[0];
|
final (peerId, _) = parsed;
|
||||||
_addNewTerminal(peerId, terminalId: terminalId);
|
_addNewTerminal(peerId, terminalId: terminalId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -368,10 +544,9 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
selectedBorderColor: MyTheme.accent,
|
selectedBorderColor: MyTheme.accent,
|
||||||
labelGetter: DesktopTab.tablabelGetter,
|
labelGetter: DesktopTab.tablabelGetter,
|
||||||
tabMenuBuilder: (key) {
|
tabMenuBuilder: (key) {
|
||||||
// Extract peerId from tab key (format: "peerId_terminalId")
|
final parsed = _parseTabKey(key);
|
||||||
final parts = key.split('_');
|
if (parsed == null) return Container();
|
||||||
if (parts.isEmpty) return Container();
|
final (peerId, _) = parsed;
|
||||||
final peerId = parts[0];
|
|
||||||
return _tabMenuBuilder(peerId, () {});
|
return _tabMenuBuilder(peerId, () {});
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
@@ -400,6 +575,11 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _closeWindowFromConnection() async {
|
||||||
|
await _closeAllTabs();
|
||||||
|
await WindowController.fromWindowId(windowId()).close();
|
||||||
|
}
|
||||||
|
|
||||||
int windowId() {
|
int windowId() {
|
||||||
return widget.params["windowId"];
|
return widget.params["windowId"];
|
||||||
}
|
}
|
||||||
@@ -426,7 +606,7 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connLength <= 1) {
|
if (connLength <= 1) {
|
||||||
tabController.clear();
|
await _closeAllTabs();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
final bool res;
|
final bool res;
|
||||||
@@ -437,7 +617,7 @@ class _TerminalTabPageState extends State<TerminalTabPage> {
|
|||||||
res = await closeConfirmDialog();
|
res = await closeConfirmDialog();
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
tabController.clear();
|
await _closeAllTabs();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import '../../common/shared_state.dart';
|
|||||||
import '../../utils/image.dart';
|
import '../../utils/image.dart';
|
||||||
import '../widgets/remote_toolbar.dart';
|
import '../widgets/remote_toolbar.dart';
|
||||||
import '../widgets/kb_layout_type_chooser.dart';
|
import '../widgets/kb_layout_type_chooser.dart';
|
||||||
|
import '../widgets/raster_stall_monitor.dart';
|
||||||
import '../widgets/tabbar_widget.dart';
|
import '../widgets/tabbar_widget.dart';
|
||||||
|
|
||||||
import 'package:flutter_hbb/native/custom_cursor.dart'
|
import 'package:flutter_hbb/native/custom_cursor.dart'
|
||||||
@@ -102,6 +103,7 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
|||||||
super.initState();
|
super.initState();
|
||||||
_ffi = FFI(widget.sessionId);
|
_ffi = FFI(widget.sessionId);
|
||||||
Get.put<FFI>(_ffi, tag: widget.id);
|
Get.put<FFI>(_ffi, tag: widget.id);
|
||||||
|
RasterStallMonitor.start();
|
||||||
_ffi.imageModel.addCallbackOnFirstImage((String peerId) {
|
_ffi.imageModel.addCallbackOnFirstImage((String peerId) {
|
||||||
showKBLayoutTypeChooserIfNeeded(
|
showKBLayoutTypeChooserIfNeeded(
|
||||||
_ffi.ffiModel.pi.platform, _ffi.dialogManager);
|
_ffi.ffiModel.pi.platform, _ffi.dialogManager);
|
||||||
@@ -222,7 +224,7 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
|||||||
// https://github.com/flutter/flutter/issues/64935
|
// https://github.com/flutter/flutter/issues/64935
|
||||||
super.dispose();
|
super.dispose();
|
||||||
debugPrint("VIEW CAMERA PAGE dispose session $sessionId ${widget.id}");
|
debugPrint("VIEW CAMERA PAGE dispose session $sessionId ${widget.id}");
|
||||||
_ffi.textureModel.onViewCameraPageDispose(closeSession);
|
_ffi.textureModel.onViewCameraPageDispose();
|
||||||
if (closeSession) {
|
if (closeSession) {
|
||||||
// ensure we leave this session, this is a double check
|
// ensure we leave this session, this is a double check
|
||||||
_ffi.inputModel.enterOrLeave(false);
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
|
|||||||
52
flutter/lib/desktop/widgets/raster_stall_monitor.dart
Normal file
52
flutter/lib/desktop/widgets/raster_stall_monitor.dart
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
|
|
||||||
|
import '../../common.dart';
|
||||||
|
import '../../consts.dart';
|
||||||
|
import '../../models/platform_model.dart';
|
||||||
|
import '../../models/state_model.dart';
|
||||||
|
|
||||||
|
/// Records a hung raster thread (frames continuously scheduled but no frame
|
||||||
|
/// timings delivered for 30s) in `texture-render-health`; a hang cannot be
|
||||||
|
/// rescued in-process, so the next launch defaults texture rendering off.
|
||||||
|
class RasterStallMonitor {
|
||||||
|
static bool _started = false;
|
||||||
|
static bool _reported = false;
|
||||||
|
static DateTime? _lastTimings;
|
||||||
|
static DateTime _lastQuiet = DateTime.now();
|
||||||
|
|
||||||
|
static void start() {
|
||||||
|
if (_started || isWeb) return;
|
||||||
|
_started = true;
|
||||||
|
SchedulerBinding.instance.addTimingsCallback((_) {
|
||||||
|
_lastTimings = DateTime.now();
|
||||||
|
});
|
||||||
|
Timer.periodic(const Duration(seconds: 2), (_) {
|
||||||
|
if (_reported) return;
|
||||||
|
final now = DateTime.now();
|
||||||
|
final lifecycle = SchedulerBinding.instance.lifecycleState;
|
||||||
|
// Minimized/inactive (incl. screen lock) or idle (nothing scheduled):
|
||||||
|
// no timings is legitimate, keep moving the quiet anchor forward.
|
||||||
|
if (stateGlobal.isMinimized ||
|
||||||
|
(lifecycle != null && lifecycle != AppLifecycleState.resumed) ||
|
||||||
|
!SchedulerBinding.instance.hasScheduledFrame) {
|
||||||
|
_lastQuiet = now;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var ref = _lastQuiet;
|
||||||
|
final lastTimings = _lastTimings;
|
||||||
|
if (lastTimings != null && lastTimings.isAfter(ref)) {
|
||||||
|
ref = lastTimings;
|
||||||
|
}
|
||||||
|
if (now.difference(ref) > const Duration(seconds: 30)) {
|
||||||
|
_reported = true;
|
||||||
|
bind.mainSetLocalOption(
|
||||||
|
key: kOptionTextureRenderHealth, value: 'failed-raster-stall');
|
||||||
|
debugPrint(
|
||||||
|
'raster thread stall detected, texture rendering disabled for next launch');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@ import 'package:flutter_hbb/consts.dart';
|
|||||||
import 'package:flutter_hbb/desktop/pages/remote_page.dart';
|
import 'package:flutter_hbb/desktop/pages/remote_page.dart';
|
||||||
import 'package:flutter_hbb/desktop/pages/view_camera_page.dart';
|
import 'package:flutter_hbb/desktop/pages/view_camera_page.dart';
|
||||||
import 'package:flutter_hbb/main.dart';
|
import 'package:flutter_hbb/main.dart';
|
||||||
|
import 'package:flutter_hbb/models/model.dart';
|
||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:flutter_hbb/models/state_model.dart';
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -99,6 +100,7 @@ class DesktopTabController {
|
|||||||
/// index, key
|
/// index, key
|
||||||
Function(int, String)? onRemoved;
|
Function(int, String)? onRemoved;
|
||||||
Function(String)? onSelected;
|
Function(String)? onSelected;
|
||||||
|
Future<void> Function()? onCloseWindow;
|
||||||
|
|
||||||
DesktopTabController(
|
DesktopTabController(
|
||||||
{required this.tabType, this.onRemoved, this.onSelected});
|
{required this.tabType, this.onRemoved, this.onSelected});
|
||||||
@@ -387,6 +389,7 @@ class _DesktopTabState extends State<DesktopTab>
|
|||||||
void onWindowMinimize() {
|
void onWindowMinimize() {
|
||||||
stateGlobal.setMinimized(true);
|
stateGlobal.setMinimized(true);
|
||||||
stateGlobal.setMaximized(false);
|
stateGlobal.setMaximized(false);
|
||||||
|
_updateSessionsRenderVisible(false);
|
||||||
super.onWindowMinimize();
|
super.onWindowMinimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,6 +397,7 @@ class _DesktopTabState extends State<DesktopTab>
|
|||||||
void onWindowMaximize() {
|
void onWindowMaximize() {
|
||||||
stateGlobal.setMinimized(false);
|
stateGlobal.setMinimized(false);
|
||||||
_setMaximized(true);
|
_setMaximized(true);
|
||||||
|
_updateSessionsRenderVisible(true);
|
||||||
super.onWindowMaximize();
|
super.onWindowMaximize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,9 +405,34 @@ class _DesktopTabState extends State<DesktopTab>
|
|||||||
void onWindowUnmaximize() {
|
void onWindowUnmaximize() {
|
||||||
stateGlobal.setMinimized(false);
|
stateGlobal.setMinimized(false);
|
||||||
_setMaximized(false);
|
_setMaximized(false);
|
||||||
|
_updateSessionsRenderVisible(true);
|
||||||
super.onWindowUnmaximize();
|
super.onWindowUnmaximize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onWindowRestore() {
|
||||||
|
// A plain restore (no maximize involved) must clear the minimized flag.
|
||||||
|
stateGlobal.setMinimized(false);
|
||||||
|
_updateSessionsRenderVisible(true);
|
||||||
|
super.onWindowRestore();
|
||||||
|
}
|
||||||
|
|
||||||
|
// A hidden window composites nothing; pause the Rust-side texture watchdog
|
||||||
|
// for its sessions so it cannot record a false failure.
|
||||||
|
void _updateSessionsRenderVisible(bool visible) {
|
||||||
|
if (tabType != DesktopTabType.remoteScreen &&
|
||||||
|
tabType != DesktopTabType.viewCamera) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (final tab in controller.state.value.tabs) {
|
||||||
|
try {
|
||||||
|
final ffi = Get.find<FFI>(tag: tab.key);
|
||||||
|
bind.sessionSetRenderVisible(
|
||||||
|
sessionId: ffi.sessionId, visible: visible);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_saveFrame({bool? flush}) async {
|
_saveFrame({bool? flush}) async {
|
||||||
try {
|
try {
|
||||||
if (tabType == DesktopTabType.main) {
|
if (tabType == DesktopTabType.main) {
|
||||||
@@ -592,13 +621,13 @@ class _DesktopTabState extends State<DesktopTab>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBar() {
|
Widget _buildBar() {
|
||||||
|
final isIncomingHomePage = bind.isIncomingOnly() && isInHomePage();
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
// custom double tap handler
|
// custom double tap handler
|
||||||
onTap: !(bind.isIncomingOnly() && isInHomePage()) &&
|
onTap: !isIncomingHomePage && showMaximize
|
||||||
showMaximize
|
|
||||||
? () {
|
? () {
|
||||||
final current = DateTime.now().millisecondsSinceEpoch;
|
final current = DateTime.now().millisecondsSinceEpoch;
|
||||||
final elapsed = current - _lastClickTime;
|
final elapsed = current - _lastClickTime;
|
||||||
@@ -609,7 +638,7 @@ class _DesktopTabState extends State<DesktopTab>
|
|||||||
.then((value) => stateGlobal.setMaximized(value));
|
.then((value) => stateGlobal.setMaximized(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: null,
|
: (isIncomingHomePage ? () {} : null), // Keep tap recognizer for Windows touch.
|
||||||
onPanStart: (_) => startDragging(isMainWindow),
|
onPanStart: (_) => startDragging(isMainWindow),
|
||||||
onPanCancel: () {
|
onPanCancel: () {
|
||||||
// We want to disable dragging of the tab area in the tab bar.
|
// We want to disable dragging of the tab area in the tab bar.
|
||||||
|
|||||||
172
flutter/lib/desktop/widgets/texture_render_probe.dart
Normal file
172
flutter/lib/desktop/widgets/texture_render_probe.dart
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
|
|
||||||
|
import '../../common.dart';
|
||||||
|
import '../../consts.dart';
|
||||||
|
import '../../models/platform_model.dart';
|
||||||
|
import '../../models/state_model.dart';
|
||||||
|
|
||||||
|
import 'package:texture_rgba_renderer/texture_rgba_renderer.dart'
|
||||||
|
if (dart.library.html) 'package:flutter_hbb/web/texture_rgba_renderer.dart';
|
||||||
|
|
||||||
|
/// Startup probe: renders one frame through a 1x1 external texture and
|
||||||
|
/// records in `texture-render-health` whether the engine consumed it, so a
|
||||||
|
/// broken environment is detected before the first session goes black.
|
||||||
|
class TextureRenderProbe extends StatefulWidget {
|
||||||
|
const TextureRenderProbe({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TextureRenderProbe> createState() => _TextureRenderProbeState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TextureRenderProbeState extends State<TextureRenderProbe> {
|
||||||
|
static bool _ranThisLaunch = false;
|
||||||
|
final _renderer = TextureRgbaRenderer();
|
||||||
|
int _textureId = -1;
|
||||||
|
int _textureKey = -1;
|
||||||
|
int _ptr = 0;
|
||||||
|
Timer? _timer;
|
||||||
|
int _ticks = 0;
|
||||||
|
bool _sawTimings = false;
|
||||||
|
bool _wasEffectiveOn = false;
|
||||||
|
DateTime? _lastTimings;
|
||||||
|
DateTime? _firstPush;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (_ranThisLaunch || isWeb || !isDesktop) return;
|
||||||
|
_ranThisLaunch = true;
|
||||||
|
if (bind.isIncomingOnly()) return;
|
||||||
|
// An old plugin without the consumed counter cannot be judged, and a
|
||||||
|
// recorded raster-stall means compositing a texture may hang this window.
|
||||||
|
if (!bind.mainTextureRenderProbeSupported()) return;
|
||||||
|
if (bind
|
||||||
|
.mainGetLocalOption(key: kOptionTextureRenderHealth)
|
||||||
|
.startsWith('failed-raster-stall')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_wasEffectiveOn = bind.mainGetUseTextureRender();
|
||||||
|
// Only probe after the window has really rendered a frame: a hidden
|
||||||
|
// window (silent/tray start) must not record a false failure.
|
||||||
|
SchedulerBinding.instance.addTimingsCallback(_onTimings);
|
||||||
|
Future.delayed(const Duration(seconds: 5), () {
|
||||||
|
if (!_sawTimings) {
|
||||||
|
SchedulerBinding.instance.removeTimingsCallback(_onTimings);
|
||||||
|
_finish(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onTimings(List<FrameTiming> timings) {
|
||||||
|
_lastTimings = DateTime.now();
|
||||||
|
if (_sawTimings) return;
|
||||||
|
_sawTimings = true;
|
||||||
|
_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _start() async {
|
||||||
|
if (!mounted) return;
|
||||||
|
_textureKey = bind.getNextTextureKey();
|
||||||
|
final id = await _renderer.createTexture(_textureKey);
|
||||||
|
if (!mounted || id == -1) {
|
||||||
|
_finish(!mounted ? null : false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ptr = await _renderer.getTexturePtr(_textureKey);
|
||||||
|
if (!mounted || _ptr <= 0) {
|
||||||
|
_finish(!mounted ? null : false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() => _textureId = id);
|
||||||
|
_timer = Timer.periodic(const Duration(milliseconds: 100), (_) {
|
||||||
|
_ticks += 1;
|
||||||
|
_firstPush ??= DateTime.now();
|
||||||
|
bind.mainPushTextureProbeFrame(ptr: _ptr);
|
||||||
|
final consumed = bind.mainGetTextureProbeConsumed(ptr: _ptr) > 0;
|
||||||
|
// "Consumed" advances inside the plugin callback, before the GL/Metal
|
||||||
|
// upload; only a frame timing after the push proves a completed frame.
|
||||||
|
final frameCompleted = consumed &&
|
||||||
|
_lastTimings != null &&
|
||||||
|
_lastTimings!.isAfter(_firstPush!);
|
||||||
|
if (frameCompleted) {
|
||||||
|
_finish(true);
|
||||||
|
} else if (_ticks >= 10) {
|
||||||
|
if (consumed) {
|
||||||
|
_finish(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Only a window that is visibly compositing can prove a failure.
|
||||||
|
final lifecycle = SchedulerBinding.instance.lifecycleState;
|
||||||
|
final active =
|
||||||
|
lifecycle == null || lifecycle == AppLifecycleState.resumed;
|
||||||
|
final timingsFresh = _lastTimings != null &&
|
||||||
|
DateTime.now().difference(_lastTimings!) <
|
||||||
|
const Duration(milliseconds: 1500);
|
||||||
|
_finish(!stateGlobal.isMinimized && active && timingsFresh
|
||||||
|
? false
|
||||||
|
: null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _finish(bool? ok) {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = null;
|
||||||
|
SchedulerBinding.instance.removeTimingsCallback(_onTimings);
|
||||||
|
if (ok != null) {
|
||||||
|
final old = bind.mainGetLocalOption(key: kOptionTextureRenderHealth);
|
||||||
|
if (ok) {
|
||||||
|
// This rgba probe disproves only the rgba black-texture class: gpu
|
||||||
|
// failures and raster stalls clear via the option toggle alone.
|
||||||
|
final clearable = old.isEmpty ||
|
||||||
|
old.startsWith('failed-probe') ||
|
||||||
|
old.startsWith('failed-watchdog-rgba');
|
||||||
|
if (clearable) {
|
||||||
|
bind.mainSetLocalOption(key: kOptionTextureRenderHealth, value: 'ok');
|
||||||
|
}
|
||||||
|
} else if (!old.startsWith('failed')) {
|
||||||
|
debugPrint('texture render probe failed, disabling texture rendering');
|
||||||
|
bind.mainSetLocalOption(
|
||||||
|
key: kOptionTextureRenderHealth, value: 'failed-probe');
|
||||||
|
if (_wasEffectiveOn) {
|
||||||
|
showToast(translate('texture-render-fallback-tip'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_textureKey != -1) {
|
||||||
|
_renderer.closeTexture(_textureKey);
|
||||||
|
_textureKey = -1;
|
||||||
|
}
|
||||||
|
_ptr = 0;
|
||||||
|
if (mounted && _textureId != -1) {
|
||||||
|
setState(() => _textureId = -1);
|
||||||
|
} else {
|
||||||
|
_textureId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_timer?.cancel();
|
||||||
|
SchedulerBinding.instance.removeTimingsCallback(_onTimings);
|
||||||
|
if (_textureKey != -1) {
|
||||||
|
_renderer.closeTexture(_textureKey);
|
||||||
|
_textureKey = -1;
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (_textureId == -1) return const SizedBox.shrink();
|
||||||
|
// Must actually composite for the engine to sample the texture; the
|
||||||
|
// pushed pixel is fully transparent.
|
||||||
|
return IgnorePointer(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 1, height: 1, child: Texture(textureId: _textureId)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import 'common.dart';
|
|||||||
import 'consts.dart';
|
import 'consts.dart';
|
||||||
import 'mobile/pages/home_page.dart';
|
import 'mobile/pages/home_page.dart';
|
||||||
import 'mobile/pages/server_page.dart';
|
import 'mobile/pages/server_page.dart';
|
||||||
|
import 'mobile/widgets/deploy_dialog.dart';
|
||||||
import 'models/platform_model.dart';
|
import 'models/platform_model.dart';
|
||||||
|
|
||||||
import 'package:flutter_hbb/plugin/handlers.dart'
|
import 'package:flutter_hbb/plugin/handlers.dart'
|
||||||
@@ -575,11 +576,20 @@ _registerEventHandler() {
|
|||||||
NativeUiHandler.instance.onEvent(evt);
|
NativeUiHandler.instance.onEvent(evt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isAndroid) {
|
||||||
|
platformFFI.registerEventHandler(
|
||||||
|
'android_needs_deploy', 'android_needs_deploy', (_) async {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
showDeployPromptDialog();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget keyListenerBuilder(BuildContext context, Widget? child) {
|
Widget keyListenerBuilder(BuildContext context, Widget? child) {
|
||||||
return RawKeyboardListener(
|
return RawKeyboardListener(
|
||||||
focusNode: FocusNode(),
|
// `skipTraversal: isWeb` is to fix "Bad state: RenderBox was not laid out: minified:aeL#c19e4"
|
||||||
|
focusNode: FocusNode(skipTraversal: isWeb),
|
||||||
child: child ?? Container(),
|
child: child ?? Container(),
|
||||||
onKey: (RawKeyEvent event) {
|
onKey: (RawKeyEvent event) {
|
||||||
if (event.logicalKey == LogicalKeyboardKey.shiftLeft) {
|
if (event.logicalKey == LogicalKeyboardKey.shiftLeft) {
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
.contains(textToFind) ||
|
.contains(textToFind) ||
|
||||||
peer.alias.toLowerCase().contains(textToFind))
|
peer.alias.toLowerCase().contains(textToFind))
|
||||||
.toList();
|
.toList();
|
||||||
|
_allPeersLoader.queryOnlines(_autocompleteOpts);
|
||||||
}
|
}
|
||||||
return _autocompleteOpts;
|
return _autocompleteOpts;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
|||||||
import 'package:flutter_hbb/models/file_model.dart';
|
import 'package:flutter_hbb/models/file_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:toggle_switch/toggle_switch.dart';
|
import 'package:toggle_switch/toggle_switch.dart';
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../common/widgets/dialog.dart';
|
import '../../common/widgets/dialog.dart';
|
||||||
@@ -72,6 +71,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
showLocal ? model.localController : model.remoteController;
|
showLocal ? model.localController : model.remoteController;
|
||||||
FileDirectory get currentDir => currentFileController.directory.value;
|
FileDirectory get currentDir => currentFileController.directory.value;
|
||||||
DirectoryOptions get currentOptions => currentFileController.options.value;
|
DirectoryOptions get currentOptions => currentFileController.options.value;
|
||||||
|
final _uniqueKey = UniqueKey();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -86,7 +86,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
});
|
});
|
||||||
gFFI.ffiModel.updateEventListener(gFFI.sessionId, widget.id);
|
gFFI.ffiModel.updateEventListener(gFFI.sessionId, widget.id);
|
||||||
WakelockPlus.enable();
|
WakelockManager.enable(_uniqueKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -94,7 +94,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
model.close().whenComplete(() {
|
model.close().whenComplete(() {
|
||||||
gFFI.close();
|
gFFI.close();
|
||||||
gFFI.dialogManager.dismissAll();
|
gFFI.dialogManager.dismissAll();
|
||||||
WakelockPlus.disable();
|
WakelockManager.disable(_uniqueKey);
|
||||||
});
|
});
|
||||||
model.jobController.clear();
|
model.jobController.clear();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -14,7 +13,6 @@ import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../common/widgets/overlay.dart';
|
import '../../common/widgets/overlay.dart';
|
||||||
@@ -66,9 +64,8 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
bool _showGestureHelp = false;
|
bool _showGestureHelp = false;
|
||||||
String _value = '';
|
String _value = '';
|
||||||
Orientation? _currentOrientation;
|
Orientation? _currentOrientation;
|
||||||
double _viewInsetsBottom = 0;
|
final _uniqueKey = UniqueKey();
|
||||||
|
Timer? _iosKeyboardWorkaroundTimer;
|
||||||
Timer? _timerDidChangeMetrics;
|
|
||||||
|
|
||||||
final _blockableOverlayState = BlockableOverlayState();
|
final _blockableOverlayState = BlockableOverlayState();
|
||||||
|
|
||||||
@@ -78,6 +75,9 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
final FocusNode _physicalFocusNode = FocusNode();
|
final FocusNode _physicalFocusNode = FocusNode();
|
||||||
var _showEdit = false; // use soft keyboard
|
var _showEdit = false; // use soft keyboard
|
||||||
|
|
||||||
|
Worker? _waylandKeyboardGateWorker;
|
||||||
|
bool _waylandKeyboardGateInitialized = false;
|
||||||
|
|
||||||
InputModel get inputModel => gFFI.inputModel;
|
InputModel get inputModel => gFFI.inputModel;
|
||||||
SessionID get sessionId => gFFI.sessionId;
|
SessionID get sessionId => gFFI.sessionId;
|
||||||
|
|
||||||
@@ -105,9 +105,7 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
gFFI.dialogManager
|
gFFI.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
});
|
});
|
||||||
if (!isWeb) {
|
WakelockManager.enable(_uniqueKey);
|
||||||
WakelockPlus.enable();
|
|
||||||
}
|
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
gFFI.inputModel.listenToMouse(true);
|
gFFI.inputModel.listenToMouse(true);
|
||||||
gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId);
|
gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId);
|
||||||
@@ -126,11 +124,33 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
isKeyboardVisible: keyboardVisibilityController.isVisible);
|
isKeyboardVisible: keyboardVisibilityController.isVisible);
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
|
||||||
|
inputModel.keyboardInputAllowed = true;
|
||||||
|
|
||||||
|
// Wayland sessions may use clipboard-based text input on the controlled side.
|
||||||
|
// Require explicit user confirmation before allowing soft-keyboard and
|
||||||
|
// clipboard-assisted text input. Physical keyboard events are not gated here.
|
||||||
|
_waylandKeyboardGateWorker = ever(gFFI.ffiModel.pi.isSet, (bool isSet) {
|
||||||
|
if (isSet) {
|
||||||
|
_initWaylandKeyboardGateIfNeeded();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (gFFI.ffiModel.pi.isSet.value) {
|
||||||
|
_initWaylandKeyboardGateIfNeeded();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
// Close the session up-front. `gFFI.close()` below only calls `sessionClose`
|
||||||
|
// after several awaits (canvas save, image update, the `enable_soft_keyboard`
|
||||||
|
// platform call), so if the app is backgrounded while this page is disposing,
|
||||||
|
// dispose can be suspended before reaching it and the connection is never torn
|
||||||
|
// down. The reconnect then re-attaches to the leaked session and is stuck on
|
||||||
|
// "Connecting...". Dispatching it here makes teardown happen synchronously on
|
||||||
|
// pop; the `sessionClose` in `gFFI.close()` becomes a no-op once removed.
|
||||||
|
unawaited(bind.sessionClose(sessionId: sessionId));
|
||||||
// https://github.com/flutter/flutter/issues/64935
|
// https://github.com/flutter/flutter/issues/64935
|
||||||
super.dispose();
|
super.dispose();
|
||||||
gFFI.dialogManager.hideMobileActionsOverlay(store: false);
|
gFFI.dialogManager.hideMobileActionsOverlay(store: false);
|
||||||
@@ -140,15 +160,16 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
await gFFI.invokeMethod("enable_soft_keyboard", true);
|
await gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||||
_mobileFocusNode.dispose();
|
_mobileFocusNode.dispose();
|
||||||
_physicalFocusNode.dispose();
|
_physicalFocusNode.dispose();
|
||||||
|
clearWaylandKeyboardPromptSuppressedForConnection(sessionId.toString());
|
||||||
|
_waylandKeyboardGateWorker?.dispose();
|
||||||
|
inputModel.keyboardInputAllowed = true;
|
||||||
await gFFI.close();
|
await gFFI.close();
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timerDidChangeMetrics?.cancel();
|
_iosKeyboardWorkaroundTimer?.cancel();
|
||||||
gFFI.dialogManager.dismissAll();
|
gFFI.dialogManager.dismissAll();
|
||||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||||
overlays: SystemUiOverlay.values);
|
overlays: SystemUiOverlay.values);
|
||||||
if (!isWeb) {
|
WakelockManager.disable(_uniqueKey);
|
||||||
await WakelockPlus.disable();
|
|
||||||
}
|
|
||||||
await keyboardSubscription.cancel();
|
await keyboardSubscription.cancel();
|
||||||
removeSharedStates(widget.id);
|
removeSharedStates(widget.id);
|
||||||
// `on_voice_call_closed` should be called when the connection is ended.
|
// `on_voice_call_closed` should be called when the connection is ended.
|
||||||
@@ -170,24 +191,38 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
gFFI.invokeMethod("try_sync_clipboard");
|
gFFI.invokeMethod("try_sync_clipboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
bool _shouldGateKeyboardForWayland() {
|
||||||
void didChangeMetrics() {
|
if (!(isAndroid || isIOS)) return false;
|
||||||
// If the soft keyboard is visible and the canvas has been changed(panned or scaled)
|
final pi = gFFI.ffiModel.pi;
|
||||||
// Don't try reset the view style and focus the cursor.
|
return pi.platform == kPeerPlatformLinux && pi.isWayland;
|
||||||
if (gFFI.cursorModel.lastKeyboardIsVisible &&
|
}
|
||||||
gFFI.canvasModel.isMobileCanvasChanged) {
|
|
||||||
|
void _initWaylandKeyboardGateIfNeeded() {
|
||||||
|
if (!mounted) return;
|
||||||
|
if (_waylandKeyboardGateInitialized) return;
|
||||||
|
if (!_shouldGateKeyboardForWayland()) return;
|
||||||
|
|
||||||
|
_waylandKeyboardGateInitialized = true;
|
||||||
|
|
||||||
|
final allowWaylandKeyboard =
|
||||||
|
mainGetPeerBoolOptionSync(widget.id, kPeerOptionAllowWaylandKeyboard);
|
||||||
|
if (!shouldShowWaylandKeyboardPrompt(
|
||||||
|
connectionId: sessionId.toString(),
|
||||||
|
isWaylandPeer: _shouldGateKeyboardForWayland(),
|
||||||
|
allowWaylandKeyboardRemembered: allowWaylandKeyboard,
|
||||||
|
)) {
|
||||||
|
inputModel.keyboardInputAllowed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final newBottom = MediaQueryData.fromView(ui.window).viewInsets.bottom;
|
inputModel.keyboardInputAllowed = false;
|
||||||
_timerDidChangeMetrics?.cancel();
|
|
||||||
_timerDidChangeMetrics = Timer(Duration(milliseconds: 100), () async {
|
// Ensure soft keyboard is not active before user confirms.
|
||||||
// We need this comparation because poping up the floating action will also trigger `didChangeMetrics()`.
|
_showEdit = false;
|
||||||
if (newBottom != _viewInsetsBottom) {
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||||
gFFI.canvasModel.mobileFocusCanvasCursor();
|
_mobileFocusNode.unfocus();
|
||||||
_viewInsetsBottom = newBottom;
|
_physicalFocusNode.requestFocus();
|
||||||
}
|
setState(() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// to-do: It should be better to use transparent color instead of the bgColor.
|
// to-do: It should be better to use transparent color instead of the bgColor.
|
||||||
@@ -211,7 +246,24 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
gFFI.ffiModel.pi.version.isNotEmpty) {
|
gFFI.ffiModel.pi.version.isNotEmpty) {
|
||||||
gFFI.invokeMethod("enable_soft_keyboard", false);
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for iOS: physical keyboard input fails after virtual keyboard is hidden
|
||||||
|
// https://github.com/flutter/flutter/issues/39900
|
||||||
|
// https://github.com/rustdesk/rustdesk/discussions/11843#discussioncomment-13499698 - Virtual keyboard issue
|
||||||
|
if (isIOS) {
|
||||||
|
_iosKeyboardWorkaroundTimer?.cancel();
|
||||||
|
_iosKeyboardWorkaroundTimer = Timer(Duration(milliseconds: 100), () {
|
||||||
|
if (!mounted) return;
|
||||||
|
_physicalFocusNode.unfocus();
|
||||||
|
_iosKeyboardWorkaroundTimer = Timer(Duration(milliseconds: 50), () {
|
||||||
|
if (!mounted) return;
|
||||||
|
_physicalFocusNode.requestFocus();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
_iosKeyboardWorkaroundTimer?.cancel();
|
||||||
|
_iosKeyboardWorkaroundTimer = null;
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
|
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||||
@@ -304,7 +356,7 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
content == '【】')) {
|
content == '【】')) {
|
||||||
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
||||||
bind.sessionInputString(sessionId: sessionId, value: content);
|
bind.sessionInputString(sessionId: sessionId, value: content);
|
||||||
openKeyboard();
|
_openKeyboardUnlocked();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bind.sessionInputString(sessionId: sessionId, value: content);
|
bind.sessionInputString(sessionId: sessionId, value: content);
|
||||||
@@ -316,6 +368,9 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
// handle mobile virtual keyboard
|
// handle mobile virtual keyboard
|
||||||
void handleSoftKeyboardInput(String newValue) {
|
void handleSoftKeyboardInput(String newValue) {
|
||||||
|
if (!inputModel.keyboardInputAllowed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isIOS) {
|
if (isIOS) {
|
||||||
_handleIOSSoftKeyboardInput(newValue);
|
_handleIOSSoftKeyboardInput(newValue);
|
||||||
} else {
|
} else {
|
||||||
@@ -324,6 +379,9 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void inputChar(String char) {
|
void inputChar(String char) {
|
||||||
|
if (!inputModel.keyboardInputAllowed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (char == '\n') {
|
if (char == '\n') {
|
||||||
char = 'VK_RETURN';
|
char = 'VK_RETURN';
|
||||||
} else if (char == ' ') {
|
} else if (char == ' ') {
|
||||||
@@ -333,6 +391,29 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void openKeyboard() {
|
void openKeyboard() {
|
||||||
|
final allowWaylandKeyboard =
|
||||||
|
mainGetPeerBoolOptionSync(widget.id, kPeerOptionAllowWaylandKeyboard);
|
||||||
|
if (shouldShowWaylandKeyboardPrompt(
|
||||||
|
connectionId: sessionId.toString(),
|
||||||
|
isWaylandPeer: _shouldGateKeyboardForWayland(),
|
||||||
|
allowWaylandKeyboardRemembered: allowWaylandKeyboard,
|
||||||
|
)) {
|
||||||
|
inputModel.keyboardInputAllowed = false;
|
||||||
|
showWaylandKeyboardInputWarningDialog(
|
||||||
|
id: widget.id,
|
||||||
|
connectionId: sessionId.toString(),
|
||||||
|
ffi: gFFI,
|
||||||
|
onEnable: () async {
|
||||||
|
_openKeyboardUnlocked();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_openKeyboardUnlocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _openKeyboardUnlocked() {
|
||||||
|
inputModel.keyboardInputAllowed = true;
|
||||||
gFFI.invokeMethod("enable_soft_keyboard", true);
|
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||||
// destroy first, so that our _value trick can work
|
// destroy first, so that our _value trick can work
|
||||||
_value = initText;
|
_value = initText;
|
||||||
@@ -1139,7 +1220,11 @@ void showOptions(
|
|||||||
if (image != null) {
|
if (image != null) {
|
||||||
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
||||||
}
|
}
|
||||||
if (pi.displays.length > 1 && pi.currentDisplay != kAllDisplayValue) {
|
final privacyModeState = PrivacyModeState.find(id);
|
||||||
|
if (pi.displays.length > 1 &&
|
||||||
|
pi.currentDisplay != kAllDisplayValue &&
|
||||||
|
(privacyModeState.isEmpty ||
|
||||||
|
allowDisplaySwitchInPrivacyMode(pi, privacyModeState.value))) {
|
||||||
final cur = pi.currentDisplay;
|
final cur = pi.currentDisplay;
|
||||||
final children = <Widget>[];
|
final children = <Widget>[];
|
||||||
final isDarkTheme = MyTheme.currentThemeMode() == ThemeMode.dark;
|
final isDarkTheme = MyTheme.currentThemeMode() == ThemeMode.dark;
|
||||||
@@ -1193,9 +1278,8 @@ void showOptions(
|
|||||||
await toolbarDisplayToggle(context, id, gFFI);
|
await toolbarDisplayToggle(context, id, gFFI);
|
||||||
|
|
||||||
List<TToggleMenu> privacyModeList = [];
|
List<TToggleMenu> privacyModeList = [];
|
||||||
// privacy mode
|
if ((gFFI.ffiModel.pi.features.privacyMode && gFFI.ffiModel.keyboard) ||
|
||||||
final privacyModeState = PrivacyModeState.find(id);
|
privacyModeState.isNotEmpty) {
|
||||||
if (gFFI.ffiModel.keyboard && gFFI.ffiModel.pi.features.privacyMode) {
|
|
||||||
privacyModeList = toolbarPrivacyMode(privacyModeState, context, id, gFFI);
|
privacyModeList = toolbarPrivacyMode(privacyModeState, context, id, gFFI);
|
||||||
if (privacyModeList.length == 1) {
|
if (privacyModeList.length == 1) {
|
||||||
displayToggles.add(privacyModeList[0]);
|
displayToggles.add(privacyModeList[0]);
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ class _DropDownAction extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value == kUsePermanentPassword &&
|
if (value == kUsePermanentPassword &&
|
||||||
(await bind.mainGetPermanentPassword()).isEmpty) {
|
(await bind.mainGetCommon(key: "permanent-password-set")) !=
|
||||||
|
"true") {
|
||||||
if (isChangePermanentPasswordDisabled()) {
|
if (isChangePermanentPasswordDisabled()) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
@@ -582,10 +583,20 @@ class _PermissionCheckerState extends State<PermissionChecker> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final serverModel = Provider.of<ServerModel>(context);
|
final serverModel = Provider.of<ServerModel>(context);
|
||||||
final hasAudioPermission = androidVersion >= 30;
|
final hasAudioPermission = androidVersion >= 30;
|
||||||
|
final hideStopService = isAndroid &&
|
||||||
|
bind.mainGetBuildinOption(key: kOptionHideStopService) == 'Y';
|
||||||
|
final allowPermChangeInAcceptWindow = option2bool(
|
||||||
|
kOptionEnablePermChangeInAcceptWindow,
|
||||||
|
bind.mainGetBuildinOption(
|
||||||
|
key: kOptionEnablePermChangeInAcceptWindow,
|
||||||
|
));
|
||||||
|
final permissionChangeLocked = isAndroid &&
|
||||||
|
serverModel.clients.any((c) => !c.disconnected) &&
|
||||||
|
!allowPermChangeInAcceptWindow;
|
||||||
return PaddingCard(
|
return PaddingCard(
|
||||||
title: translate("Permissions"),
|
title: translate("Permissions"),
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
serverModel.mediaOk
|
serverModel.mediaOk && !hideStopService
|
||||||
? ElevatedButton.icon(
|
? ElevatedButton.icon(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
@@ -595,21 +606,30 @@ class _PermissionCheckerState extends State<PermissionChecker> {
|
|||||||
label: Text(translate("Stop service")))
|
label: Text(translate("Stop service")))
|
||||||
.marginOnly(bottom: 8)
|
.marginOnly(bottom: 8)
|
||||||
: SizedBox.shrink(),
|
: SizedBox.shrink(),
|
||||||
|
if (!hideStopService || !serverModel.mediaOk)
|
||||||
|
PermissionRow(
|
||||||
|
translate("Screen Capture"),
|
||||||
|
serverModel.mediaOk,
|
||||||
|
!serverModel.mediaOk &&
|
||||||
|
gFFI.userModel.userName.value.isEmpty &&
|
||||||
|
bind.mainGetLocalOption(key: "show-scam-warning") != "N"
|
||||||
|
? () => showScamWarning(context, serverModel)
|
||||||
|
: serverModel.toggleService),
|
||||||
PermissionRow(
|
PermissionRow(
|
||||||
translate("Screen Capture"),
|
translate("Input Control"),
|
||||||
serverModel.mediaOk,
|
serverModel.inputOk,
|
||||||
!serverModel.mediaOk &&
|
serverModel.toggleInput,
|
||||||
gFFI.userModel.userName.value.isEmpty &&
|
),
|
||||||
bind.mainGetLocalOption(key: "show-scam-warning") != "N"
|
PermissionRow(
|
||||||
? () => showScamWarning(context, serverModel)
|
translate("Transfer file"),
|
||||||
: serverModel.toggleService),
|
serverModel.fileOk,
|
||||||
PermissionRow(translate("Input Control"), serverModel.inputOk,
|
serverModel.toggleFile,
|
||||||
serverModel.toggleInput),
|
enabled: !permissionChangeLocked,
|
||||||
PermissionRow(translate("Transfer file"), serverModel.fileOk,
|
),
|
||||||
serverModel.toggleFile),
|
|
||||||
hasAudioPermission
|
hasAudioPermission
|
||||||
? PermissionRow(translate("Audio Capture"), serverModel.audioOk,
|
? PermissionRow(translate("Audio Capture"), serverModel.audioOk,
|
||||||
serverModel.toggleAudio)
|
serverModel.toggleAudio,
|
||||||
|
enabled: !permissionChangeLocked)
|
||||||
: Row(children: [
|
: Row(children: [
|
||||||
Icon(Icons.info_outline).marginOnly(right: 15),
|
Icon(Icons.info_outline).marginOnly(right: 15),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -618,19 +638,25 @@ class _PermissionCheckerState extends State<PermissionChecker> {
|
|||||||
style: const TextStyle(color: MyTheme.darkGray),
|
style: const TextStyle(color: MyTheme.darkGray),
|
||||||
))
|
))
|
||||||
]),
|
]),
|
||||||
PermissionRow(translate("Enable clipboard"), serverModel.clipboardOk,
|
PermissionRow(
|
||||||
serverModel.toggleClipboard),
|
translate("Enable clipboard"),
|
||||||
|
serverModel.clipboardOk,
|
||||||
|
serverModel.toggleClipboard,
|
||||||
|
enabled: !permissionChangeLocked,
|
||||||
|
),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PermissionRow extends StatelessWidget {
|
class PermissionRow extends StatelessWidget {
|
||||||
const PermissionRow(this.name, this.isOk, this.onPressed, {Key? key})
|
const PermissionRow(this.name, this.isOk, this.onPressed,
|
||||||
|
{Key? key, this.enabled = true})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final bool isOk;
|
final bool isOk;
|
||||||
final VoidCallback onPressed;
|
final VoidCallback onPressed;
|
||||||
|
final bool enabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -639,9 +665,11 @@ class PermissionRow extends StatelessWidget {
|
|||||||
contentPadding: EdgeInsets.all(0),
|
contentPadding: EdgeInsets.all(0),
|
||||||
title: Text(name),
|
title: Text(name),
|
||||||
value: isOk,
|
value: isOk,
|
||||||
onChanged: (bool value) {
|
onChanged: enabled
|
||||||
onPressed();
|
? (bool value) {
|
||||||
});
|
onPressed();
|
||||||
|
}
|
||||||
|
: null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,13 +869,7 @@ class ClientInfo extends StatelessWidget {
|
|||||||
flex: -1,
|
flex: -1,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(right: 12),
|
padding: const EdgeInsets.only(right: 12),
|
||||||
child: CircleAvatar(
|
child: _buildAvatar(context))),
|
||||||
backgroundColor: str2color(
|
|
||||||
client.name,
|
|
||||||
Theme.of(context).brightness == Brightness.light
|
|
||||||
? 255
|
|
||||||
: 150),
|
|
||||||
child: Text(client.name[0])))),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -860,6 +882,20 @@ class ClientInfo extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildAvatar(BuildContext context) {
|
||||||
|
final fallback = CircleAvatar(
|
||||||
|
backgroundColor: str2color(client.name,
|
||||||
|
Theme.of(context).brightness == Brightness.light ? 255 : 150),
|
||||||
|
child: Text(client.name.isNotEmpty ? client.name[0] : '?'),
|
||||||
|
);
|
||||||
|
return buildAvatarWidget(
|
||||||
|
avatar: client.avatar,
|
||||||
|
size: 40,
|
||||||
|
fallback: fallback,
|
||||||
|
) ??
|
||||||
|
fallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void androidChannelInit() {
|
void androidChannelInit() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import '../../common/widgets/login.dart';
|
|||||||
import '../../consts.dart';
|
import '../../consts.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import '../../models/platform_model.dart';
|
import '../../models/platform_model.dart';
|
||||||
|
import '../widgets/deploy_dialog.dart';
|
||||||
import '../widgets/dialog.dart';
|
import '../widgets/dialog.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
import 'scan_page.dart';
|
import 'scan_page.dart';
|
||||||
@@ -77,6 +78,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
var _enableAbr = false;
|
var _enableAbr = false;
|
||||||
var _denyLANDiscovery = false;
|
var _denyLANDiscovery = false;
|
||||||
var _onlyWhiteList = false;
|
var _onlyWhiteList = false;
|
||||||
|
var _onlyIdWhiteList = false;
|
||||||
var _enableDirectIPAccess = false;
|
var _enableDirectIPAccess = false;
|
||||||
var _enableRecordSession = false;
|
var _enableRecordSession = false;
|
||||||
var _enableHardwareCodec = false;
|
var _enableHardwareCodec = false;
|
||||||
@@ -88,6 +90,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
var _directAccessPort = "";
|
var _directAccessPort = "";
|
||||||
var _fingerprint = "";
|
var _fingerprint = "";
|
||||||
var _buildDate = "";
|
var _buildDate = "";
|
||||||
|
var _myId = "";
|
||||||
var _autoDisconnectTimeout = "";
|
var _autoDisconnectTimeout = "";
|
||||||
var _hideServer = false;
|
var _hideServer = false;
|
||||||
var _hideProxy = false;
|
var _hideProxy = false;
|
||||||
@@ -100,6 +103,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
var _enableIpv6Punch = false;
|
var _enableIpv6Punch = false;
|
||||||
var _isUsingPublicServer = false;
|
var _isUsingPublicServer = false;
|
||||||
var _allowAskForNoteAtEndOfConnection = false;
|
var _allowAskForNoteAtEndOfConnection = false;
|
||||||
|
var _preventSleepWhileConnected = true;
|
||||||
|
|
||||||
_SettingsState() {
|
_SettingsState() {
|
||||||
_enableAbr = option2bool(
|
_enableAbr = option2bool(
|
||||||
@@ -107,6 +111,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
_denyLANDiscovery = !option2bool(kOptionEnableLanDiscovery,
|
_denyLANDiscovery = !option2bool(kOptionEnableLanDiscovery,
|
||||||
bind.mainGetOptionSync(key: kOptionEnableLanDiscovery));
|
bind.mainGetOptionSync(key: kOptionEnableLanDiscovery));
|
||||||
_onlyWhiteList = whitelistNotEmpty();
|
_onlyWhiteList = whitelistNotEmpty();
|
||||||
|
_onlyIdWhiteList = idWhitelistNotEmpty();
|
||||||
_enableDirectIPAccess = option2bool(
|
_enableDirectIPAccess = option2bool(
|
||||||
kOptionDirectServer, bind.mainGetOptionSync(key: kOptionDirectServer));
|
kOptionDirectServer, bind.mainGetOptionSync(key: kOptionDirectServer));
|
||||||
_enableRecordSession = option2bool(kOptionEnableRecordSession,
|
_enableRecordSession = option2bool(kOptionEnableRecordSession,
|
||||||
@@ -140,6 +145,8 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
_enableIpv6Punch = mainGetLocalBoolOptionSync(kOptionEnableIpv6Punch);
|
_enableIpv6Punch = mainGetLocalBoolOptionSync(kOptionEnableIpv6Punch);
|
||||||
_allowAskForNoteAtEndOfConnection =
|
_allowAskForNoteAtEndOfConnection =
|
||||||
mainGetLocalBoolOptionSync(kOptionAllowAskForNoteAtEndOfConnection);
|
mainGetLocalBoolOptionSync(kOptionAllowAskForNoteAtEndOfConnection);
|
||||||
|
_preventSleepWhileConnected =
|
||||||
|
mainGetLocalBoolOptionSync(kOptionKeepAwakeDuringOutgoingSessions);
|
||||||
_showTerminalExtraKeys =
|
_showTerminalExtraKeys =
|
||||||
mainGetLocalBoolOptionSync(kOptionEnableShowTerminalExtraKeys);
|
mainGetLocalBoolOptionSync(kOptionEnableShowTerminalExtraKeys);
|
||||||
}
|
}
|
||||||
@@ -213,6 +220,12 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
_buildDate = buildDate;
|
_buildDate = buildDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final myId = await bind.mainGetMyId();
|
||||||
|
if (_myId != myId) {
|
||||||
|
update = true;
|
||||||
|
_myId = myId;
|
||||||
|
}
|
||||||
|
|
||||||
final isUsingPublicServer = await bind.mainIsUsingPublicServer();
|
final isUsingPublicServer = await bind.mainIsUsingPublicServer();
|
||||||
if (_isUsingPublicServer != isUsingPublicServer) {
|
if (_isUsingPublicServer != isUsingPublicServer) {
|
||||||
update = true;
|
update = true;
|
||||||
@@ -396,6 +409,29 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
changeWhiteList(callback: update);
|
changeWhiteList(callback: update);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
SettingsTile.switchTile(
|
||||||
|
title: Row(children: [
|
||||||
|
Expanded(child: Text(translate('Use ID whitelisting'))),
|
||||||
|
Offstage(
|
||||||
|
offstage: !_onlyIdWhiteList,
|
||||||
|
child: const Icon(Icons.warning_amber_rounded,
|
||||||
|
color: Color.fromARGB(255, 255, 204, 0)))
|
||||||
|
.marginOnly(left: 5)
|
||||||
|
]),
|
||||||
|
initialValue: _onlyIdWhiteList,
|
||||||
|
onToggle: (_) async {
|
||||||
|
update() async {
|
||||||
|
final onlyIdWhiteList = idWhitelistNotEmpty();
|
||||||
|
if (onlyIdWhiteList != _onlyIdWhiteList) {
|
||||||
|
setState(() {
|
||||||
|
_onlyIdWhiteList = onlyIdWhiteList;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeIdWhiteList(callback: update);
|
||||||
|
},
|
||||||
|
),
|
||||||
SettingsTile.switchTile(
|
SettingsTile.switchTile(
|
||||||
title: Text(translate('Adaptive bitrate')),
|
title: Text(translate('Adaptive bitrate')),
|
||||||
initialValue: _enableAbr,
|
initialValue: _enableAbr,
|
||||||
@@ -614,7 +650,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
onToggle: (bool v) async {
|
onToggle: (bool v) async {
|
||||||
await mainSetLocalBoolOption(kOptionEnableShowTerminalExtraKeys, v);
|
await mainSetLocalBoolOption(kOptionEnableShowTerminalExtraKeys, v);
|
||||||
final newValue =
|
final newValue =
|
||||||
mainGetLocalBoolOptionSync(kOptionEnableShowTerminalExtraKeys);
|
mainGetLocalBoolOptionSync(kOptionEnableShowTerminalExtraKeys);
|
||||||
setState(() {
|
setState(() {
|
||||||
_showTerminalExtraKeys = newValue;
|
_showTerminalExtraKeys = newValue;
|
||||||
});
|
});
|
||||||
@@ -685,8 +721,18 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
SettingsTile(
|
SettingsTile(
|
||||||
title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty
|
title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty
|
||||||
? translate('Login')
|
? translate('Login')
|
||||||
: '${translate('Logout')} (${gFFI.userModel.userName.value})')),
|
: '${translate('Logout')} (${gFFI.userModel.accountLabelWithHandle})')),
|
||||||
leading: Icon(Icons.person),
|
leading: Obx(() {
|
||||||
|
final avatar = bind.mainResolveAvatarUrl(
|
||||||
|
avatar: gFFI.userModel.avatar.value);
|
||||||
|
return buildAvatarWidget(
|
||||||
|
avatar: avatar,
|
||||||
|
size: 28,
|
||||||
|
borderRadius: null,
|
||||||
|
fallback: Icon(Icons.person),
|
||||||
|
) ??
|
||||||
|
Icon(Icons.person);
|
||||||
|
}),
|
||||||
onPressed: (context) {
|
onPressed: (context) {
|
||||||
if (gFFI.userModel.userName.value.isEmpty) {
|
if (gFFI.userModel.userName.value.isEmpty) {
|
||||||
loginDialog();
|
loginDialog();
|
||||||
@@ -715,6 +761,13 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
onPressed: (context) {
|
onPressed: (context) {
|
||||||
changeSocks5Proxy();
|
changeSocks5Proxy();
|
||||||
}),
|
}),
|
||||||
|
if (isAndroid && !bind.isOutgoingOnly())
|
||||||
|
SettingsTile(
|
||||||
|
title: Text(translate('Deploy')),
|
||||||
|
leading: Icon(Icons.cloud_upload),
|
||||||
|
onPressed: (context) {
|
||||||
|
showDeployDialog();
|
||||||
|
}),
|
||||||
if (!disabledSettings && !_hideNetwork && !_hideWebSocket)
|
if (!disabledSettings && !_hideNetwork && !_hideWebSocket)
|
||||||
SettingsTile.switchTile(
|
SettingsTile.switchTile(
|
||||||
title: Text(translate('Use WebSocket')),
|
title: Text(translate('Use WebSocket')),
|
||||||
@@ -823,7 +876,20 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
_allowAskForNoteAtEndOfConnection = newValue;
|
_allowAskForNoteAtEndOfConnection = newValue;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
|
if (!incomingOnly)
|
||||||
|
SettingsTile.switchTile(
|
||||||
|
title:
|
||||||
|
Text(translate('keep-awake-during-outgoing-sessions-label')),
|
||||||
|
initialValue: _preventSleepWhileConnected,
|
||||||
|
onToggle: (v) async {
|
||||||
|
await mainSetLocalBoolOption(
|
||||||
|
kOptionKeepAwakeDuringOutgoingSessions, v);
|
||||||
|
setState(() {
|
||||||
|
_preventSleepWhileConnected = v;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
if (isAndroid)
|
if (isAndroid)
|
||||||
SettingsSection(title: Text(translate('Hardware Codec')), tiles: [
|
SettingsSection(title: Text(translate('Hardware Codec')), tiles: [
|
||||||
@@ -948,6 +1014,14 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
child: Text(_fingerprint),
|
child: Text(_fingerprint),
|
||||||
),
|
),
|
||||||
leading: Icon(Icons.fingerprint)),
|
leading: Icon(Icons.fingerprint)),
|
||||||
|
SettingsTile(
|
||||||
|
onPressed: (context) => onCopyId(_myId),
|
||||||
|
title: Text(translate("ID")),
|
||||||
|
value: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Text(_myId),
|
||||||
|
),
|
||||||
|
leading: Icon(Icons.perm_identity)),
|
||||||
SettingsTile(
|
SettingsTile(
|
||||||
title: Text(translate("Privacy Statement")),
|
title: Text(translate("Privacy Statement")),
|
||||||
onPressed: (context) =>
|
onPressed: (context) =>
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/common/widgets/dialog.dart';
|
import 'package:flutter_hbb/common/widgets/dialog.dart';
|
||||||
|
import 'package:flutter_hbb/models/input_modifier_utils.dart';
|
||||||
import 'package:flutter_hbb/models/model.dart';
|
import 'package:flutter_hbb/models/model.dart';
|
||||||
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:flutter_hbb/models/terminal_model.dart';
|
import 'package:flutter_hbb/models/terminal_model.dart';
|
||||||
|
import 'package:flutter_hbb/mobile/terminal_keyboard_utils.dart';
|
||||||
|
import 'package:flutter_hbb/web/dummy.dart'
|
||||||
|
if (dart.library.html) 'package:flutter_hbb/web/terminal_font.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:xterm/xterm.dart';
|
import 'package:xterm/xterm.dart';
|
||||||
import '../../desktop/pages/terminal_connection_manager.dart';
|
import '../../desktop/pages/terminal_connection_manager.dart';
|
||||||
@@ -41,6 +47,14 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
final GlobalKey _keyboardKey = GlobalKey();
|
final GlobalKey _keyboardKey = GlobalKey();
|
||||||
double _keyboardHeight = 0;
|
double _keyboardHeight = 0;
|
||||||
late bool _showTerminalExtraKeys;
|
late bool _showTerminalExtraKeys;
|
||||||
|
// Ctrl lock state for virtual keyboard: active key presses are mapped to control codes
|
||||||
|
bool _ctrlLocked = false;
|
||||||
|
bool _altLocked = false;
|
||||||
|
// Row3 expand/collapse state for compact keyboard layout
|
||||||
|
bool _row3Expanded = false;
|
||||||
|
// For iOS edge swipe gesture
|
||||||
|
double _swipeStartX = 0;
|
||||||
|
double _swipeCurrentX = 0;
|
||||||
|
|
||||||
// For web only.
|
// For web only.
|
||||||
// 'monospace' does not work on web, use Google Fonts, `??` is only for null safety.
|
// 'monospace' does not work on web, use Google Fonts, `??` is only for null safety.
|
||||||
@@ -55,6 +69,10 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
|
||||||
|
if (isWeb) {
|
||||||
|
loadLocalTerminalFontIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[TerminalPage] Initializing terminal ${widget.terminalId} for peer ${widget.id}');
|
'[TerminalPage] Initializing terminal ${widget.terminalId} for peer ${widget.id}');
|
||||||
|
|
||||||
@@ -79,7 +97,29 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
// Register this terminal model with FFI for event routing
|
// Register this terminal model with FFI for event routing
|
||||||
_ffi.registerTerminalModel(widget.terminalId, _terminalModel);
|
_ffi.registerTerminalModel(widget.terminalId, _terminalModel);
|
||||||
|
|
||||||
_showTerminalExtraKeys = mainGetLocalBoolOptionSync(kOptionEnableShowTerminalExtraKeys);
|
// Auto-close connection when shell exits
|
||||||
|
_terminalModel.onClosed = () {
|
||||||
|
if (mounted) {
|
||||||
|
closeConnection(id: widget.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Web desktop users have full hardware keyboard access, so the on-screen
|
||||||
|
// terminal extra keys bar is unnecessary and disabled.
|
||||||
|
_showTerminalExtraKeys = !isWebDesktop &&
|
||||||
|
mainGetLocalBoolOptionSync(kOptionEnableShowTerminalExtraKeys);
|
||||||
|
_terminalModel.isCtrlLocked = () => _ctrlLocked;
|
||||||
|
_terminalModel.clearCtrlLock = () {
|
||||||
|
if (_ctrlLocked) setState(() => _ctrlLocked = false);
|
||||||
|
};
|
||||||
|
_terminalModel.isAltLocked = () => _altLocked;
|
||||||
|
_terminalModel.clearAltLock = () {
|
||||||
|
if (_altLocked) setState(() => _altLocked = false);
|
||||||
|
};
|
||||||
|
// Load Row3 expand/collapse state from persistent storage. The raw option
|
||||||
|
// read keeps Row3 collapsed when no value has been saved yet.
|
||||||
|
_row3Expanded =
|
||||||
|
bind.mainGetLocalOption(key: kOptionShowTerminalCtrlKeys) == 'Y';
|
||||||
// Initialize terminal connection
|
// Initialize terminal connection
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_ffi.dialogManager
|
_ffi.dialogManager
|
||||||
@@ -134,6 +174,39 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
return EdgeInsets.only(left: 5.0, right: 5.0, top: topBottom, bottom: topBottom + _sysKeyboardHeight + _keyboardHeight);
|
return EdgeInsets.only(left: 5.0, right: 5.0, top: topBottom, bottom: topBottom + _sysKeyboardHeight + _keyboardHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pastes clipboard text through TerminalModel so keyboard-only modifiers and
|
||||||
|
/// mobile Enter normalization never alter clipboard data.
|
||||||
|
Future<void> _pasteClipboardText() async {
|
||||||
|
final data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
|
final text = data?.text;
|
||||||
|
if (text == null || !mounted) return;
|
||||||
|
|
||||||
|
await _terminalModel.pasteText(text);
|
||||||
|
if (mounted) {
|
||||||
|
_terminalModel.terminalController.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEventResult _handleTerminalKeyEvent(FocusNode _, KeyEvent event) {
|
||||||
|
final hardwareKeyboard = HardwareKeyboard.instance;
|
||||||
|
final shouldPaste = shouldHandleTerminalPasteShortcut(
|
||||||
|
logicalKey: event.logicalKey,
|
||||||
|
isKeyDown: event is KeyDownEvent,
|
||||||
|
isKeyRepeat: event is KeyRepeatEvent,
|
||||||
|
controlPressed: hardwareKeyboard.isControlPressed,
|
||||||
|
metaPressed: hardwareKeyboard.isMetaPressed,
|
||||||
|
altPressed: hardwareKeyboard.isAltPressed,
|
||||||
|
shiftPressed: hardwareKeyboard.isShiftPressed,
|
||||||
|
modifierLockActive: _ctrlLocked || _altLocked,
|
||||||
|
);
|
||||||
|
if (!shouldPaste) return KeyEventResult.ignored;
|
||||||
|
|
||||||
|
// Only locked virtual modifiers need interception. Without a lock, keep
|
||||||
|
// xterm's default hardware paste behavior, including bracketed paste mode.
|
||||||
|
unawaited(_pasteClipboardText());
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -147,7 +220,7 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildBody() {
|
Widget buildBody() {
|
||||||
return Scaffold(
|
final scaffold = Scaffold(
|
||||||
resizeToAvoidBottomInset: false, // Disable automatic layout adjustment; manually control UI updates to prevent flickering when the keyboard shows/hides
|
resizeToAvoidBottomInset: false, // Disable automatic layout adjustment; manually control UI updates to prevent flickering when the keyboard shows/hides
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
body: Stack(
|
body: Stack(
|
||||||
@@ -164,6 +237,14 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
textStyle: _getTerminalStyle(),
|
textStyle: _getTerminalStyle(),
|
||||||
backgroundOpacity: 0.7,
|
backgroundOpacity: 0.7,
|
||||||
|
// The following comment is from xterm.dart source code:
|
||||||
|
// Workaround to detect delete key for platforms and IMEs that do not
|
||||||
|
// emit a hardware delete event. Preferred on mobile platforms. [false] by
|
||||||
|
// default.
|
||||||
|
//
|
||||||
|
// Android works fine without this workaround.
|
||||||
|
deleteDetection: isIOS,
|
||||||
|
onKeyEvent: _handleTerminalKeyEvent,
|
||||||
padding: _calculatePadding(heightPx),
|
padding: _calculatePadding(heightPx),
|
||||||
onSecondaryTapDown: (details, offset) async {
|
onSecondaryTapDown: (details, offset) async {
|
||||||
final selection = _terminalModel.terminalController.selection;
|
final selection = _terminalModel.terminalController.selection;
|
||||||
@@ -172,11 +253,7 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
_terminalModel.terminalController.clearSelection();
|
_terminalModel.terminalController.clearSelection();
|
||||||
await Clipboard.setData(ClipboardData(text: text));
|
await Clipboard.setData(ClipboardData(text: text));
|
||||||
} else {
|
} else {
|
||||||
final data = await Clipboard.getData('text/plain');
|
await _pasteClipboardText();
|
||||||
final text = data?.text;
|
|
||||||
if (text != null) {
|
|
||||||
_terminalModel.terminal.paste(text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -185,9 +262,108 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_showTerminalExtraKeys) _buildFloatingKeyboard(),
|
if (_showTerminalExtraKeys) _buildFloatingKeyboard(),
|
||||||
|
// iOS-style circular close button in top-right corner
|
||||||
|
if (isIOS) _buildCloseButton(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add iOS edge swipe gesture to exit (similar to Android back button)
|
||||||
|
if (isIOS) {
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final screenWidth = constraints.maxWidth;
|
||||||
|
// Base thresholds on screen width but clamp to reasonable logical pixel ranges
|
||||||
|
// Edge detection region: ~10% of width, clamped between 20 and 80 logical pixels
|
||||||
|
final edgeThreshold = (screenWidth * 0.1).clamp(20.0, 80.0);
|
||||||
|
// Required horizontal movement: ~25% of width, clamped between 80 and 300 logical pixels
|
||||||
|
final swipeThreshold = (screenWidth * 0.25).clamp(80.0, 300.0);
|
||||||
|
|
||||||
|
return RawGestureDetector(
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
gestures: <Type, GestureRecognizerFactory>{
|
||||||
|
HorizontalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>(
|
||||||
|
() => HorizontalDragGestureRecognizer(
|
||||||
|
debugOwner: this,
|
||||||
|
// Only respond to touch input, exclude mouse/trackpad
|
||||||
|
supportedDevices: kTouchBasedDeviceKinds,
|
||||||
|
),
|
||||||
|
(HorizontalDragGestureRecognizer instance) {
|
||||||
|
instance
|
||||||
|
// Capture initial touch-down position (before touch slop)
|
||||||
|
..onDown = (details) {
|
||||||
|
_swipeStartX = details.localPosition.dx;
|
||||||
|
_swipeCurrentX = details.localPosition.dx;
|
||||||
|
}
|
||||||
|
..onUpdate = (details) {
|
||||||
|
_swipeCurrentX = details.localPosition.dx;
|
||||||
|
}
|
||||||
|
..onEnd = (details) {
|
||||||
|
// Check if swipe started from left edge and moved right
|
||||||
|
if (_swipeStartX < edgeThreshold && (_swipeCurrentX - _swipeStartX) > swipeThreshold) {
|
||||||
|
clientClose(sessionId, _ffi);
|
||||||
|
}
|
||||||
|
_swipeStartX = 0;
|
||||||
|
_swipeCurrentX = 0;
|
||||||
|
}
|
||||||
|
..onCancel = () {
|
||||||
|
_swipeStartX = 0;
|
||||||
|
_swipeCurrentX = 0;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
child: scaffold,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return scaffold;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCloseButton() {
|
||||||
|
return Positioned(
|
||||||
|
top: 0,
|
||||||
|
right: 0,
|
||||||
|
child: SafeArea(
|
||||||
|
minimum: const EdgeInsets.only(
|
||||||
|
top: 16, // iOS standard margin
|
||||||
|
right: 16, // iOS standard margin
|
||||||
|
),
|
||||||
|
child: Semantics(
|
||||||
|
button: true,
|
||||||
|
label: translate('Close'),
|
||||||
|
child: Container(
|
||||||
|
width: 44, // iOS standard tap target size
|
||||||
|
height: 44,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black.withOpacity(0.5), // Half transparency
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: InkWell(
|
||||||
|
customBorder: const CircleBorder(),
|
||||||
|
onTap: () {
|
||||||
|
clientClose(sessionId, _ffi);
|
||||||
|
},
|
||||||
|
child: Tooltip(
|
||||||
|
message: translate('Close'),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.chevron_left, // iOS-style back arrow
|
||||||
|
color: Colors.white,
|
||||||
|
size: 28,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildFloatingKeyboard() {
|
Widget _buildFloatingKeyboard() {
|
||||||
@@ -204,66 +380,171 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
// Row 1 follows the latest reviewed PR layout.
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: _buildKeyboardKeyButtons(terminalKeyboardRow1Keys),
|
||||||
|
),
|
||||||
|
// Row 2 ends with the full-width Row3 collapse/expand toggle.
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
_buildKeyButton('Esc'),
|
..._buildKeyboardKeyButtons(terminalKeyboardRow2Keys),
|
||||||
const SizedBox(width: 2),
|
const SizedBox(width: terminalKeyboardKeySpacing),
|
||||||
_buildKeyButton('/'),
|
_buildCollapseButton(),
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('|'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('Home'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('↑'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('End'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('PgUp'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
_buildKeyButton('Tab'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('Ctrl+C'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('~'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('←'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('↓'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('→'),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
_buildKeyButton('PgDn'),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// Row 3 restores paging keys and trailing alignment placeholders.
|
||||||
|
if (_row3Expanded)
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
..._buildKeyboardKeyButtons(terminalKeyboardRow3Keys),
|
||||||
|
for (var i = 0;
|
||||||
|
i < terminalKeyboardRow3TrailingPlaceholderCount;
|
||||||
|
i++) ...[
|
||||||
|
const SizedBox(width: terminalKeyboardKeySpacing),
|
||||||
|
const SizedBox(width: terminalKeyboardKeyWidth),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ctrl toggle button with highlighted locked state
|
||||||
|
Widget _buildCtrlKeyButton() {
|
||||||
|
return _buildModifierToggleButton(
|
||||||
|
text: 'Ctrl',
|
||||||
|
semanticsLabel: 'Ctrl',
|
||||||
|
isLocked: _ctrlLocked,
|
||||||
|
onPressed: () => setState(() => _ctrlLocked = !_ctrlLocked),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alt toggle button with highlighted locked state
|
||||||
|
Widget _buildAltKeyButton() {
|
||||||
|
return _buildModifierToggleButton(
|
||||||
|
text: 'Alt',
|
||||||
|
semanticsLabel: 'Alt',
|
||||||
|
isLocked: _altLocked,
|
||||||
|
onPressed: () => setState(() => _altLocked = !_altLocked),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collapse/expand toggle button for Row3
|
||||||
|
void _toggleRow3Expanded() {
|
||||||
|
final willExpand = !_row3Expanded;
|
||||||
|
final shouldClearModifiers = shouldClearTerminalModifiersWhenRow3Collapses(
|
||||||
|
wasExpanded: _row3Expanded,
|
||||||
|
willExpand: willExpand,
|
||||||
|
ctrlLocked: _ctrlLocked,
|
||||||
|
altLocked: _altLocked,
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
_row3Expanded = willExpand;
|
||||||
|
if (shouldClearModifiers) {
|
||||||
|
_ctrlLocked = false;
|
||||||
|
_altLocked = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainSetLocalBoolOption(kOptionShowTerminalCtrlKeys, willExpand);
|
||||||
|
|
||||||
|
// The floating keyboard height changes after Row3 is inserted/removed.
|
||||||
|
// Re-measure on the next frame so terminal padding uses the new height.
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (!mounted || !_showTerminalExtraKeys) return;
|
||||||
|
setState(() {
|
||||||
|
_updateKeyboardHeight();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCollapseButton() {
|
||||||
|
return Semantics(
|
||||||
|
label: translate('Show terminal extra keys'),
|
||||||
|
toggled: _row3Expanded,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: _toggleRow3Expanded,
|
||||||
|
child: Text(_row3Expanded ? '∧' : '∨'),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
minimumSize: const Size(terminalKeyboardKeyWidth, 32),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
textStyle: const TextStyle(fontSize: 12),
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds a fixed-width key sequence with the reviewed 2dp spacing.
|
||||||
|
List<Widget> _buildKeyboardKeyButtons(List<String> labels) {
|
||||||
|
return [
|
||||||
|
for (var i = 0; i < labels.length; i++) ...[
|
||||||
|
_buildKeyButton(labels[i]),
|
||||||
|
if (i < labels.length - 1)
|
||||||
|
const SizedBox(width: terminalKeyboardKeySpacing),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build a modifier toggle button (Ctrl/Alt) with one-shot behavior.
|
||||||
|
/// When [isLocked] is true, the button highlights in blue and the next
|
||||||
|
/// single-character input is mapped to its modified equivalent.
|
||||||
|
Widget _buildModifierToggleButton({
|
||||||
|
required String text,
|
||||||
|
required String semanticsLabel,
|
||||||
|
required bool isLocked,
|
||||||
|
required VoidCallback onPressed,
|
||||||
|
}) {
|
||||||
|
return Semantics(
|
||||||
|
// Ctrl and Alt are technical key names and intentionally stay unchanged.
|
||||||
|
label: semanticsLabel,
|
||||||
|
toggled: isLocked,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: Text(text),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
minimumSize: const Size(terminalKeyboardKeyWidth, 32),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
textStyle: const TextStyle(fontSize: 12),
|
||||||
|
backgroundColor: isLocked
|
||||||
|
? Colors.blue
|
||||||
|
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
|
foregroundColor: isLocked
|
||||||
|
? Colors.white
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildKeyButton(String label) {
|
Widget _buildKeyButton(String label) {
|
||||||
|
if (label == 'Ctrl') return _buildCtrlKeyButton();
|
||||||
|
if (label == 'Alt') return _buildAltKeyButton();
|
||||||
|
|
||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_sendKeyToTerminal(label);
|
_sendKeyToTerminal(label);
|
||||||
},
|
},
|
||||||
child: Text(label),
|
child: Text(label),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
minimumSize: const Size(48, 32),
|
minimumSize: const Size(terminalKeyboardKeyWidth, 32),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
textStyle: const TextStyle(fontSize: 12),
|
textStyle: const TextStyle(fontSize: 12),
|
||||||
backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sendKeyToTerminal(String key) {
|
void _sendKeyToTerminal(String key) {
|
||||||
String? send;
|
String send;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'Esc':
|
case 'Esc':
|
||||||
@@ -307,9 +588,7 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send != null) {
|
_terminalModel.sendVirtualKey(send);
|
||||||
_terminalModel.sendVirtualKey(send);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/TerminalStudio/xterm.dart/issues/42#issuecomment-877495472
|
// https://github.com/TerminalStudio/xterm.dart/issues/42#issuecomment-877495472
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../common/widgets/overlay.dart';
|
import '../../common/widgets/overlay.dart';
|
||||||
@@ -62,7 +61,7 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
|||||||
bool _showGestureHelp = false;
|
bool _showGestureHelp = false;
|
||||||
Orientation? _currentOrientation;
|
Orientation? _currentOrientation;
|
||||||
double _viewInsetsBottom = 0;
|
double _viewInsetsBottom = 0;
|
||||||
|
final _uniqueKey = UniqueKey();
|
||||||
Timer? _timerDidChangeMetrics;
|
Timer? _timerDidChangeMetrics;
|
||||||
|
|
||||||
final _blockableOverlayState = BlockableOverlayState();
|
final _blockableOverlayState = BlockableOverlayState();
|
||||||
@@ -100,9 +99,7 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
|||||||
gFFI.dialogManager
|
gFFI.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
});
|
});
|
||||||
if (!isWeb) {
|
WakelockManager.enable(_uniqueKey);
|
||||||
WakelockPlus.enable();
|
|
||||||
}
|
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
gFFI.inputModel.listenToMouse(true);
|
gFFI.inputModel.listenToMouse(true);
|
||||||
gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId);
|
gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId);
|
||||||
@@ -139,9 +136,7 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
|||||||
gFFI.dialogManager.dismissAll();
|
gFFI.dialogManager.dismissAll();
|
||||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||||
overlays: SystemUiOverlay.values);
|
overlays: SystemUiOverlay.values);
|
||||||
if (!isWeb) {
|
WakelockManager.disable(_uniqueKey);
|
||||||
await WakelockPlus.disable();
|
|
||||||
}
|
|
||||||
removeSharedStates(widget.id);
|
removeSharedStates(widget.id);
|
||||||
// `on_voice_call_closed` should be called when the connection is ended.
|
// `on_voice_call_closed` should be called when the connection is ended.
|
||||||
// The inner logic of `on_voice_call_closed` will check if the voice call is active.
|
// The inner logic of `on_voice_call_closed` will check if the voice call is active.
|
||||||
|
|||||||
20
flutter/lib/mobile/terminal_keyboard_utils.dart
Normal file
20
flutter/lib/mobile/terminal_keyboard_utils.dart
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/// Reviewed mobile terminal keyboard layout from PR #15532.
|
||||||
|
///
|
||||||
|
/// Keeping the key order outside the widget makes the intended layout explicit
|
||||||
|
/// and prevents behavior fixes from silently moving keys between rows.
|
||||||
|
const terminalKeyboardRow1Keys = ['Esc', '/', '|', 'Home', '↑', 'End', r'\'];
|
||||||
|
const terminalKeyboardRow2Keys = ['Tab', 'Ctrl+C', '~', '←', '↓', '→'];
|
||||||
|
const terminalKeyboardRow3Keys = ['Ctrl', 'Alt', '-', 'PgUp', 'PgDn'];
|
||||||
|
|
||||||
|
const terminalKeyboardKeyWidth = 48.0;
|
||||||
|
const terminalKeyboardKeySpacing = 2.0;
|
||||||
|
|
||||||
|
/// Empty 48dp slots keep expanded Row3 aligned with the two rows above it.
|
||||||
|
const terminalKeyboardRow3TrailingPlaceholderCount = 2;
|
||||||
|
|
||||||
|
/// Returns the fixed width occupied by a row of equally sized key slots.
|
||||||
|
double terminalKeyboardRowWidth(int slotCount) {
|
||||||
|
if (slotCount <= 0) return 0;
|
||||||
|
return slotCount * terminalKeyboardKeyWidth +
|
||||||
|
(slotCount - 1) * terminalKeyboardKeySpacing;
|
||||||
|
}
|
||||||
114
flutter/lib/mobile/widgets/deploy_dialog.dart
Normal file
114
flutter/lib/mobile/widgets/deploy_dialog.dart
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../common.dart';
|
||||||
|
import '../../models/platform_model.dart';
|
||||||
|
|
||||||
|
const _deployDialogTag = 'android-deploy-device';
|
||||||
|
|
||||||
|
void showDeployPromptDialog() {
|
||||||
|
gFFI.dialogManager.dismissByTag(_deployDialogTag);
|
||||||
|
gFFI.dialogManager.show<bool>((setState, close, context) {
|
||||||
|
submit() => close(true);
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: Text(translate("Deploy")),
|
||||||
|
content: Text(translate("server_requires_deployment_tip")),
|
||||||
|
actions: [
|
||||||
|
dialogButton("Cancel", onPressed: close, isOutline: true),
|
||||||
|
dialogButton("OK", onPressed: submit),
|
||||||
|
],
|
||||||
|
onSubmit: submit,
|
||||||
|
onCancel: close,
|
||||||
|
);
|
||||||
|
}, tag: _deployDialogTag).then((deploy) {
|
||||||
|
if (deploy == true) {
|
||||||
|
showDeployDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void showDeployDialog() {
|
||||||
|
gFFI.dialogManager.dismissByTag(_deployDialogTag);
|
||||||
|
final tokenController = TextEditingController();
|
||||||
|
final idController = TextEditingController();
|
||||||
|
var errorText = "";
|
||||||
|
var isInProgress = false;
|
||||||
|
gFFI.dialogManager.show((setState, close, context) {
|
||||||
|
submit() async {
|
||||||
|
if (isInProgress) return;
|
||||||
|
final token = tokenController.text.trim();
|
||||||
|
if (token.isEmpty) {
|
||||||
|
setState(() {
|
||||||
|
errorText = translate("token is required!");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
errorText = "";
|
||||||
|
isInProgress = true;
|
||||||
|
});
|
||||||
|
String res;
|
||||||
|
try {
|
||||||
|
res = await bind.mainDeployDevice(
|
||||||
|
token: token, id: idController.text.trim());
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
errorText = translate(e.toString());
|
||||||
|
isInProgress = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (res.isEmpty) {
|
||||||
|
close();
|
||||||
|
await gFFI.serverModel.fetchID();
|
||||||
|
showToast(translate("Successful"));
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
errorText = translate(res.toString());
|
||||||
|
isInProgress = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: Text(translate("Deploy")),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: tokenController,
|
||||||
|
decoration: InputDecoration(labelText: translate("API Token")),
|
||||||
|
obscureText: true,
|
||||||
|
enableSuggestions: false,
|
||||||
|
autocorrect: false,
|
||||||
|
autofocus: true,
|
||||||
|
).workaroundFreezeLinuxMint(),
|
||||||
|
TextField(
|
||||||
|
controller: idController,
|
||||||
|
decoration:
|
||||||
|
InputDecoration(labelText: translate("Custom ID (optional)")),
|
||||||
|
).workaroundFreezeLinuxMint(),
|
||||||
|
if (errorText.isNotEmpty)
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: SelectableText(
|
||||||
|
errorText,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
).paddingOnly(top: 8),
|
||||||
|
),
|
||||||
|
if (isInProgress) const LinearProgressIndicator().paddingOnly(top: 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
dialogButton("Cancel",
|
||||||
|
onPressed: isInProgress ? null : close, isOutline: true),
|
||||||
|
dialogButton("OK", onPressed: isInProgress ? null : submit),
|
||||||
|
],
|
||||||
|
onSubmit: submit,
|
||||||
|
onCancel: isInProgress ? null : close,
|
||||||
|
);
|
||||||
|
}, tag: _deployDialogTag);
|
||||||
|
}
|
||||||
@@ -12,100 +12,6 @@ void _showSuccess() {
|
|||||||
showToast(translate("Successful"));
|
showToast(translate("Successful"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showError() {
|
|
||||||
showToast(translate("Error"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
|
||||||
final pw = await bind.mainGetPermanentPassword();
|
|
||||||
final p0 = TextEditingController(text: pw);
|
|
||||||
final p1 = TextEditingController(text: pw);
|
|
||||||
var validateLength = false;
|
|
||||||
var validateSame = false;
|
|
||||||
dialogManager.show((setState, close, context) {
|
|
||||||
submit() async {
|
|
||||||
close();
|
|
||||||
dialogManager.showLoading(translate("Waiting"));
|
|
||||||
if (await gFFI.serverModel.setPermanentPassword(p0.text)) {
|
|
||||||
dialogManager.dismissAll();
|
|
||||||
_showSuccess();
|
|
||||||
} else {
|
|
||||||
dialogManager.dismissAll();
|
|
||||||
_showError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CustomAlertDialog(
|
|
||||||
title: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.password_rounded, color: MyTheme.accent),
|
|
||||||
Text(translate('Set your own password')).paddingOnly(left: 10),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
content: Form(
|
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
|
||||||
TextFormField(
|
|
||||||
autofocus: true,
|
|
||||||
obscureText: true,
|
|
||||||
keyboardType: TextInputType.visiblePassword,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: translate('Password'),
|
|
||||||
),
|
|
||||||
controller: p0,
|
|
||||||
validator: (v) {
|
|
||||||
if (v == null) return null;
|
|
||||||
final val = v.trim().length > 5;
|
|
||||||
if (validateLength != val) {
|
|
||||||
// use delay to make setState success
|
|
||||||
Future.delayed(Duration(microseconds: 1),
|
|
||||||
() => setState(() => validateLength = val));
|
|
||||||
}
|
|
||||||
return val
|
|
||||||
? null
|
|
||||||
: translate('Too short, at least 6 characters.');
|
|
||||||
},
|
|
||||||
).workaroundFreezeLinuxMint(),
|
|
||||||
TextFormField(
|
|
||||||
obscureText: true,
|
|
||||||
keyboardType: TextInputType.visiblePassword,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: translate('Confirmation'),
|
|
||||||
),
|
|
||||||
controller: p1,
|
|
||||||
validator: (v) {
|
|
||||||
if (v == null) return null;
|
|
||||||
final val = p0.text == v;
|
|
||||||
if (validateSame != val) {
|
|
||||||
Future.delayed(Duration(microseconds: 1),
|
|
||||||
() => setState(() => validateSame = val));
|
|
||||||
}
|
|
||||||
return val
|
|
||||||
? null
|
|
||||||
: translate('The confirmation is not identical.');
|
|
||||||
},
|
|
||||||
).workaroundFreezeLinuxMint(),
|
|
||||||
])),
|
|
||||||
onCancel: close,
|
|
||||||
onSubmit: (validateLength && validateSame) ? submit : null,
|
|
||||||
actions: [
|
|
||||||
dialogButton(
|
|
||||||
'Cancel',
|
|
||||||
icon: Icon(Icons.close_rounded),
|
|
||||||
onPressed: close,
|
|
||||||
isOutline: true,
|
|
||||||
),
|
|
||||||
dialogButton(
|
|
||||||
'OK',
|
|
||||||
icon: Icon(Icons.done_rounded),
|
|
||||||
onPressed: (validateLength && validateSame) ? submit : null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTemporaryPasswordLengthDialog(
|
void setTemporaryPasswordLengthDialog(
|
||||||
OverlayDialogManager dialogManager) async {
|
OverlayDialogManager dialogManager) async {
|
||||||
List<String> lengths = ['6', '8', '10'];
|
List<String> lengths = ['6', '8', '10'];
|
||||||
@@ -211,13 +117,13 @@ void showServerSettingsWithValue(
|
|||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextFormField(
|
child: serverSettingsTextFormField(
|
||||||
|
label: label,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
decoration: InputDecoration(
|
errorMsg: errorMsg,
|
||||||
errorText: errorMsg.isEmpty ? null : errorMsg,
|
contentPadding:
|
||||||
contentPadding:
|
EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
||||||
EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
showLabelText: false,
|
||||||
),
|
|
||||||
validator: validator,
|
validator: validator,
|
||||||
autofocus: autofocus,
|
autofocus: autofocus,
|
||||||
).workaroundFreezeLinuxMint(),
|
).workaroundFreezeLinuxMint(),
|
||||||
@@ -226,12 +132,10 @@ void showServerSettingsWithValue(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TextFormField(
|
return serverSettingsTextFormField(
|
||||||
|
label: label,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
decoration: InputDecoration(
|
errorMsg: errorMsg,
|
||||||
labelText: label,
|
|
||||||
errorText: errorMsg.isEmpty ? null : errorMsg,
|
|
||||||
),
|
|
||||||
validator: validator,
|
validator: validator,
|
||||||
).workaroundFreezeLinuxMint();
|
).workaroundFreezeLinuxMint();
|
||||||
}
|
}
|
||||||
@@ -303,6 +207,35 @@ void showServerSettingsWithValue(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextFormField serverSettingsTextFormField({
|
||||||
|
required String label,
|
||||||
|
required TextEditingController controller,
|
||||||
|
required String errorMsg,
|
||||||
|
String? Function(String?)? validator,
|
||||||
|
bool autofocus = false,
|
||||||
|
bool showLabelText = true,
|
||||||
|
EdgeInsetsGeometry? contentPadding,
|
||||||
|
}) {
|
||||||
|
return TextFormField(
|
||||||
|
controller: controller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: showLabelText ? label : null,
|
||||||
|
errorText: errorMsg.isEmpty ? null : errorMsg,
|
||||||
|
contentPadding: contentPadding,
|
||||||
|
),
|
||||||
|
validator: validator,
|
||||||
|
autofocus: autofocus,
|
||||||
|
keyboardType: TextInputType.visiblePassword,
|
||||||
|
textCapitalization: TextCapitalization.none,
|
||||||
|
autocorrect: false,
|
||||||
|
enableSuggestions: false,
|
||||||
|
smartDashesType: SmartDashesType.disabled,
|
||||||
|
smartQuotesType: SmartQuotesType.disabled,
|
||||||
|
enableIMEPersonalizedLearning: false,
|
||||||
|
spellCheckConfiguration: const SpellCheckConfiguration.disabled(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void setPrivacyModeDialog(
|
void setPrivacyModeDialog(
|
||||||
OverlayDialogManager dialogManager,
|
OverlayDialogManager dialogManager,
|
||||||
List<TToggleMenu> privacyModeList,
|
List<TToggleMenu> privacyModeList,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
|
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
|
||||||
@@ -53,7 +52,9 @@ class AbModel {
|
|||||||
|
|
||||||
RxBool get currentAbLoading => current.abLoading;
|
RxBool get currentAbLoading => current.abLoading;
|
||||||
bool get currentAbEmpty => current.peers.isEmpty && current.tags.isEmpty;
|
bool get currentAbEmpty => current.peers.isEmpty && current.tags.isEmpty;
|
||||||
RxString get currentAbPullError => current.pullError;
|
final _listPullError = ''.obs;
|
||||||
|
RxString get abPullError =>
|
||||||
|
_listPullError.value.isNotEmpty ? _listPullError : current.pullError;
|
||||||
RxString get currentAbPushError => current.pushError;
|
RxString get currentAbPushError => current.pushError;
|
||||||
String? _personalAbGuid;
|
String? _personalAbGuid;
|
||||||
RxBool legacyMode = false.obs;
|
RxBool legacyMode = false.obs;
|
||||||
@@ -68,6 +69,7 @@ class AbModel {
|
|||||||
var _syncFromRecentLock = false;
|
var _syncFromRecentLock = false;
|
||||||
var _timerCounter = 0;
|
var _timerCounter = 0;
|
||||||
var _cacheLoadOnceFlag = false;
|
var _cacheLoadOnceFlag = false;
|
||||||
|
var _pulledOnce = false;
|
||||||
var listInitialized = false;
|
var listInitialized = false;
|
||||||
var _maxPeerOneAb = 0;
|
var _maxPeerOneAb = 0;
|
||||||
|
|
||||||
@@ -97,10 +99,17 @@ class AbModel {
|
|||||||
print("reset ab model");
|
print("reset ab model");
|
||||||
addressbooks.clear();
|
addressbooks.clear();
|
||||||
_currentName.value = '';
|
_currentName.value = '';
|
||||||
|
_listPullError.value = '';
|
||||||
|
_pulledOnce = false;
|
||||||
await bind.mainClearAb();
|
await bind.mainClearAb();
|
||||||
listInitialized = false;
|
listInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearPullErrors() {
|
||||||
|
_listPullError.value = '';
|
||||||
|
current.pullError.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
// #region ab
|
// #region ab
|
||||||
/// Pulls the address book data from the server.
|
/// Pulls the address book data from the server.
|
||||||
///
|
///
|
||||||
@@ -110,31 +119,41 @@ class AbModel {
|
|||||||
var _pulling = false;
|
var _pulling = false;
|
||||||
Future<void> pullAb(
|
Future<void> pullAb(
|
||||||
{required ForcePullAb? force, required bool quiet}) async {
|
{required ForcePullAb? force, required bool quiet}) async {
|
||||||
|
if (bind.isDisableAb()) return;
|
||||||
|
if (!gFFI.userModel.isLogin) return;
|
||||||
|
if (gFFI.userModel.networkError.isNotEmpty) return;
|
||||||
if (_pulling) return;
|
if (_pulling) return;
|
||||||
|
if (force == null && _pulledOnce) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_pulling = true;
|
_pulling = true;
|
||||||
|
if (!quiet) {
|
||||||
|
_listPullError.value = '';
|
||||||
|
current.pullError.value = '';
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await _pullAb(force: force, quiet: quiet);
|
await _pullAb(force: force, quiet: quiet);
|
||||||
_refreshTab();
|
_refreshTab();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
_pulling = false;
|
_pulling = false;
|
||||||
|
_pulledOnce = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _pullAb(
|
Future<void> _pullAb(
|
||||||
{required ForcePullAb? force, required bool quiet}) async {
|
{required ForcePullAb? force, required bool quiet}) async {
|
||||||
if (bind.isDisableAb()) return;
|
|
||||||
if (!gFFI.userModel.isLogin) return;
|
|
||||||
if (gFFI.userModel.networkError.isNotEmpty) return;
|
|
||||||
if (force == null && listInitialized && current.initialized) return;
|
if (force == null && listInitialized && current.initialized) return;
|
||||||
debugPrint("pullAb, force: $force, quiet: $quiet");
|
debugPrint("pullAb, force: $force, quiet: $quiet");
|
||||||
if (!listInitialized || force == ForcePullAb.listAndCurrent) {
|
if (!listInitialized || force == ForcePullAb.listAndCurrent) {
|
||||||
try {
|
try {
|
||||||
// Read personal guid every time to avoid upgrading the server without closing the main window
|
// Read personal guid every time to avoid upgrading the server without closing the main window
|
||||||
_personalAbGuid = null;
|
_personalAbGuid = null;
|
||||||
await _getPersonalAbGuid();
|
// `true`: continue init. `false`: stop, error already recorded.
|
||||||
// Determine legacy mode based on whether _personalAbGuid is null
|
if (!await _getPersonalAbGuid(quiet: quiet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
legacyMode.value = _personalAbGuid == null;
|
legacyMode.value = _personalAbGuid == null;
|
||||||
if (!legacyMode.value && _maxPeerOneAb == 0) {
|
if (!legacyMode.value && _maxPeerOneAb == 0) {
|
||||||
await _getAbSettings();
|
await _getAbSettings(quiet: quiet);
|
||||||
}
|
}
|
||||||
if (_personalAbGuid != null) {
|
if (_personalAbGuid != null) {
|
||||||
debugPrint("pull ab list");
|
debugPrint("pull ab list");
|
||||||
@@ -142,7 +161,7 @@ class AbModel {
|
|||||||
abProfiles.add(AbProfile(_personalAbGuid!, _personalAddressBookName,
|
abProfiles.add(AbProfile(_personalAbGuid!, _personalAddressBookName,
|
||||||
gFFI.userModel.userName.value, null, ShareRule.read.value, null));
|
gFFI.userModel.userName.value, null, ShareRule.read.value, null));
|
||||||
// get all address book name
|
// get all address book name
|
||||||
await _getSharedAbProfiles(abProfiles);
|
await _getSharedAbProfiles(abProfiles, quiet: quiet);
|
||||||
addressbooks.removeWhere((key, value) =>
|
addressbooks.removeWhere((key, value) =>
|
||||||
abProfiles.firstWhereOrNull((e) => e.name == key) == null);
|
abProfiles.firstWhereOrNull((e) => e.name == key) == null);
|
||||||
for (int i = 0; i < abProfiles.length; i++) {
|
for (int i = 0; i < abProfiles.length; i++) {
|
||||||
@@ -182,6 +201,7 @@ class AbModel {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("pull ab list error: $e");
|
debugPrint("pull ab list error: $e");
|
||||||
|
_setListPullError(e, quiet: quiet);
|
||||||
}
|
}
|
||||||
} else if (listInitialized &&
|
} else if (listInitialized &&
|
||||||
(!current.initialized || force == ForcePullAb.current)) {
|
(!current.initialized || force == ForcePullAb.current)) {
|
||||||
@@ -197,14 +217,26 @@ class AbModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _getAbSettings() async {
|
void _setListPullError(Object err, {required bool quiet, int? statusCode}) {
|
||||||
|
if (!quiet) {
|
||||||
|
_listPullError.value =
|
||||||
|
'${translate('pull_ab_failed_tip')}: ${translate(err.toString())}';
|
||||||
|
}
|
||||||
|
if (statusCode == 401) {
|
||||||
|
gFFI.userModel.reset(resetOther: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _getAbSettings({required bool quiet}) async {
|
||||||
|
int? statusCode;
|
||||||
try {
|
try {
|
||||||
final api = "${await bind.mainGetApiServer()}/api/ab/settings";
|
final api = "${await bind.mainGetApiServer()}/api/ab/settings";
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
_setEmptyBody(headers);
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(Uri.parse(api), headers: headers);
|
final resp = await http.post(Uri.parse(api), headers: headers);
|
||||||
if (resp.statusCode == 404) {
|
statusCode = resp.statusCode;
|
||||||
|
if (statusCode == 404) {
|
||||||
debugPrint("HTTP 404, api server doesn't support shared address book");
|
debugPrint("HTTP 404, api server doesn't support shared address book");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -213,46 +245,57 @@ class AbModel {
|
|||||||
if (json.containsKey('error')) {
|
if (json.containsKey('error')) {
|
||||||
throw json['error'];
|
throw json['error'];
|
||||||
}
|
}
|
||||||
if (resp.statusCode != 200) {
|
if (statusCode != 200) {
|
||||||
throw 'HTTP ${resp.statusCode}';
|
throw 'HTTP $statusCode';
|
||||||
}
|
}
|
||||||
_maxPeerOneAb = json['max_peer_one_ab'] ?? 0;
|
_maxPeerOneAb = json['max_peer_one_ab'] ?? 0;
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugPrint('get ab settings err: ${err.toString()}');
|
debugPrint('get ab settings err: ${err.toString()}');
|
||||||
|
_setListPullError(err, quiet: quiet, statusCode: statusCode);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _getPersonalAbGuid() async {
|
/// Loads `/api/ab/personal`.
|
||||||
|
/// Returns `true` to continue init, `false` to stop after a real error.
|
||||||
|
Future<bool> _getPersonalAbGuid({required bool quiet}) async {
|
||||||
|
int? statusCode;
|
||||||
try {
|
try {
|
||||||
final api = "${await bind.mainGetApiServer()}/api/ab/personal";
|
final api = "${await bind.mainGetApiServer()}/api/ab/personal";
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
_setEmptyBody(headers);
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(Uri.parse(api), headers: headers);
|
final resp = await http.post(Uri.parse(api), headers: headers);
|
||||||
if (resp.statusCode == 404) {
|
statusCode = resp.statusCode;
|
||||||
|
if (statusCode == 404) {
|
||||||
debugPrint("HTTP 404, current api server is legacy mode");
|
debugPrint("HTTP 404, current api server is legacy mode");
|
||||||
return false;
|
// Old server: keep `_personalAbGuid` null and continue in legacy mode.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Map<String, dynamic> json =
|
Map<String, dynamic> json =
|
||||||
_jsonDecodeRespMap(decode_http_response(resp), resp.statusCode);
|
_jsonDecodeRespMap(decode_http_response(resp), resp.statusCode);
|
||||||
if (json.containsKey('error')) {
|
if (json.containsKey('error')) {
|
||||||
throw json['error'];
|
throw json['error'];
|
||||||
}
|
}
|
||||||
if (resp.statusCode != 200) {
|
if (statusCode != 200) {
|
||||||
throw 'HTTP ${resp.statusCode}';
|
throw 'HTTP $statusCode';
|
||||||
}
|
}
|
||||||
_personalAbGuid = json['guid'];
|
_personalAbGuid = json['guid'];
|
||||||
|
// New server: guid is available, continue in non-legacy mode.
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugPrint('get personal ab err: ${err.toString()}');
|
debugPrint('get personal ab err: ${err.toString()}');
|
||||||
|
_setListPullError(err, quiet: quiet, statusCode: statusCode);
|
||||||
}
|
}
|
||||||
|
// Real error: stop the current pull.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _getSharedAbProfiles(List<AbProfile> profiles) async {
|
Future<bool> _getSharedAbProfiles(List<AbProfile> profiles,
|
||||||
|
{required bool quiet}) async {
|
||||||
final api = "${await bind.mainGetApiServer()}/api/ab/shared/profiles";
|
final api = "${await bind.mainGetApiServer()}/api/ab/shared/profiles";
|
||||||
|
int? statusCode;
|
||||||
try {
|
try {
|
||||||
var uri0 = Uri.parse(api);
|
var uri0 = Uri.parse(api);
|
||||||
final pageSize = 100;
|
final pageSize = 100;
|
||||||
@@ -273,13 +316,19 @@ class AbModel {
|
|||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
_setEmptyBody(headers);
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(uri, headers: headers);
|
final resp = await http.post(uri, headers: headers);
|
||||||
|
statusCode = resp.statusCode;
|
||||||
|
if (statusCode == 404) {
|
||||||
|
debugPrint(
|
||||||
|
"HTTP 404, api server doesn't support shared address book");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Map<String, dynamic> json =
|
Map<String, dynamic> json =
|
||||||
_jsonDecodeRespMap(decode_http_response(resp), resp.statusCode);
|
_jsonDecodeRespMap(decode_http_response(resp), resp.statusCode);
|
||||||
if (json.containsKey('error')) {
|
if (json.containsKey('error')) {
|
||||||
throw json['error'];
|
throw json['error'];
|
||||||
}
|
}
|
||||||
if (resp.statusCode != 200) {
|
if (statusCode != 200) {
|
||||||
throw 'HTTP ${resp.statusCode}';
|
throw 'HTTP $statusCode';
|
||||||
}
|
}
|
||||||
if (json.containsKey('total')) {
|
if (json.containsKey('total')) {
|
||||||
if (total == 0) total = json['total'];
|
if (total == 0) total = json['total'];
|
||||||
@@ -302,6 +351,7 @@ class AbModel {
|
|||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugPrint('_getSharedAbProfiles err: ${err.toString()}');
|
debugPrint('_getSharedAbProfiles err: ${err.toString()}');
|
||||||
|
_setListPullError(err, quiet: quiet, statusCode: statusCode);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class _PixelbufferTexture {
|
|||||||
int _display = 0;
|
int _display = 0;
|
||||||
SessionID? _sessionId;
|
SessionID? _sessionId;
|
||||||
bool _destroying = false;
|
bool _destroying = false;
|
||||||
|
bool _closed = false;
|
||||||
|
int _ptr = 0;
|
||||||
int? _id;
|
int? _id;
|
||||||
|
|
||||||
final textureRenderer = TextureRgbaRenderer();
|
final textureRenderer = TextureRgbaRenderer();
|
||||||
@@ -27,11 +29,22 @@ class _PixelbufferTexture {
|
|||||||
_textureKey = bind.getNextTextureKey();
|
_textureKey = bind.getNextTextureKey();
|
||||||
_sessionId = sessionId;
|
_sessionId = sessionId;
|
||||||
|
|
||||||
textureRenderer.createTexture(_textureKey).then((id) async {
|
final textureKey = _textureKey;
|
||||||
|
textureRenderer.createTexture(textureKey).then((id) async {
|
||||||
_id = id;
|
_id = id;
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
|
if (_closed) {
|
||||||
|
// Destroyed while creation was still in flight (rapid
|
||||||
|
// connect/disconnect); nobody else will close this texture.
|
||||||
|
await textureRenderer.closeTexture(textureKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ffi.textureModel.setRgbaTextureId(display: d, id: id);
|
ffi.textureModel.setRgbaTextureId(display: d, id: id);
|
||||||
final ptr = await textureRenderer.getTexturePtr(_textureKey);
|
final ptr = await textureRenderer.getTexturePtr(textureKey);
|
||||||
|
if (_closed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ptr = ptr;
|
||||||
platformFFI.registerPixelbufferTexture(sessionId, display, ptr);
|
platformFFI.registerPixelbufferTexture(sessionId, display, ptr);
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"create pixelbuffer texture: peerId: ${ffi.id} display:$_display, textureId:$id, texturePtr:$ptr");
|
"create pixelbuffer texture: peerId: ${ffi.id} display:$_display, textureId:$id, texturePtr:$ptr");
|
||||||
@@ -39,13 +52,16 @@ class _PixelbufferTexture {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy(bool unregisterTexture, FFI ffi) async {
|
destroy(FFI ffi) async {
|
||||||
|
_closed = true;
|
||||||
if (!_destroying && _textureKey != -1 && _sessionId != null) {
|
if (!_destroying && _textureKey != -1 && _sessionId != null) {
|
||||||
_destroying = true;
|
_destroying = true;
|
||||||
if (unregisterTexture) {
|
if (_ptr != 0) {
|
||||||
platformFFI.registerPixelbufferTexture(_sessionId!, display, 0);
|
// Compare-and-clear: only clears if Rust still holds this pointer
|
||||||
// sleep for a while to avoid the texture is used after it's unregistered.
|
// (#8016-safe); returning from this synchronous call also means no
|
||||||
await Future.delayed(Duration(milliseconds: 100));
|
// push through the old pointer is still in flight.
|
||||||
|
platformFFI.unregisterPixelbufferTexture(_sessionId!, display, _ptr);
|
||||||
|
_ptr = 0;
|
||||||
}
|
}
|
||||||
await textureRenderer.closeTexture(_textureKey);
|
await textureRenderer.closeTexture(_textureKey);
|
||||||
_textureKey = -1;
|
_textureKey = -1;
|
||||||
@@ -61,6 +77,7 @@ class _GpuTexture {
|
|||||||
SessionID? _sessionId;
|
SessionID? _sessionId;
|
||||||
final support = bind.mainHasGpuTextureRender();
|
final support = bind.mainHasGpuTextureRender();
|
||||||
bool _destroying = false;
|
bool _destroying = false;
|
||||||
|
bool _closed = false;
|
||||||
int _display = 0;
|
int _display = 0;
|
||||||
int? _id;
|
int? _id;
|
||||||
int? _output;
|
int? _output;
|
||||||
@@ -79,9 +96,18 @@ class _GpuTexture {
|
|||||||
gpuTextureRenderer.registerTexture().then((id) async {
|
gpuTextureRenderer.registerTexture().then((id) async {
|
||||||
_id = id;
|
_id = id;
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
if (_closed) {
|
||||||
|
// Destroyed while creation was still in flight (rapid
|
||||||
|
// connect/disconnect); nobody else will unregister this texture.
|
||||||
|
await gpuTextureRenderer.unregisterTexture(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
_textureId = id;
|
_textureId = id;
|
||||||
ffi.textureModel.setGpuTextureId(display: d, id: id);
|
ffi.textureModel.setGpuTextureId(display: d, id: id);
|
||||||
final output = await gpuTextureRenderer.output(id);
|
final output = await gpuTextureRenderer.output(id);
|
||||||
|
if (_closed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_output = output;
|
_output = output;
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
platformFFI.registerGpuTexture(sessionId, d, output);
|
platformFFI.registerGpuTexture(sessionId, d, output);
|
||||||
@@ -95,20 +121,22 @@ class _GpuTexture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy(bool unregisterTexture, FFI ffi) async {
|
destroy(FFI ffi) async {
|
||||||
// must stop texture render, render unregistered texture cause crash
|
// must stop texture render, render unregistered texture cause crash
|
||||||
|
_closed = true;
|
||||||
if (!_destroying && support && _sessionId != null && _textureId != -1) {
|
if (!_destroying && support && _sessionId != null && _textureId != -1) {
|
||||||
_destroying = true;
|
_destroying = true;
|
||||||
if (unregisterTexture) {
|
final output = _output;
|
||||||
platformFFI.registerGpuTexture(_sessionId!, _display, 0);
|
if (output != null) {
|
||||||
// sleep for a while to avoid the texture is used after it's unregistered.
|
// Compare-and-clear, see _PixelbufferTexture.destroy.
|
||||||
await Future.delayed(Duration(milliseconds: 100));
|
platformFFI.unregisterGpuTexture(_sessionId!, _display, output);
|
||||||
|
_output = null;
|
||||||
}
|
}
|
||||||
await gpuTextureRenderer.unregisterTexture(_textureId);
|
await gpuTextureRenderer.unregisterTexture(_textureId);
|
||||||
_textureId = -1;
|
_textureId = -1;
|
||||||
_destroying = false;
|
_destroying = false;
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"destroy gpu texture: peerId: ${ffi.id} display:$_display, textureId:$_id, output:$_output");
|
"destroy gpu texture: peerId: ${ffi.id} display:$_display, textureId:$_id, output:$output");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,11 +228,11 @@ class TextureModel {
|
|||||||
tryRemoveTexture(int idx) {
|
tryRemoveTexture(int idx) {
|
||||||
_control.remove(idx);
|
_control.remove(idx);
|
||||||
if (_pixelbufferRenderTextures.containsKey(idx)) {
|
if (_pixelbufferRenderTextures.containsKey(idx)) {
|
||||||
_pixelbufferRenderTextures[idx]!.destroy(true, ffi);
|
_pixelbufferRenderTextures[idx]!.destroy(ffi);
|
||||||
_pixelbufferRenderTextures.remove(idx);
|
_pixelbufferRenderTextures.remove(idx);
|
||||||
}
|
}
|
||||||
if (_gpuRenderTextures.containsKey(idx)) {
|
if (_gpuRenderTextures.containsKey(idx)) {
|
||||||
_gpuRenderTextures[idx]!.destroy(true, ffi);
|
_gpuRenderTextures[idx]!.destroy(ffi);
|
||||||
_gpuRenderTextures.remove(idx);
|
_gpuRenderTextures.remove(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,25 +252,25 @@ class TextureModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemotePageDispose(bool closeSession) async {
|
onRemotePageDispose() async {
|
||||||
final ffi = parent.target;
|
final ffi = parent.target;
|
||||||
if (ffi == null) return;
|
if (ffi == null) return;
|
||||||
for (final texture in _pixelbufferRenderTextures.values) {
|
for (final texture in _pixelbufferRenderTextures.values) {
|
||||||
await texture.destroy(closeSession, ffi);
|
await texture.destroy(ffi);
|
||||||
}
|
}
|
||||||
for (final texture in _gpuRenderTextures.values) {
|
for (final texture in _gpuRenderTextures.values) {
|
||||||
await texture.destroy(closeSession, ffi);
|
await texture.destroy(ffi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onViewCameraPageDispose(bool closeSession) async {
|
onViewCameraPageDispose() async {
|
||||||
final ffi = parent.target;
|
final ffi = parent.target;
|
||||||
if (ffi == null) return;
|
if (ffi == null) return;
|
||||||
for (final texture in _pixelbufferRenderTextures.values) {
|
for (final texture in _pixelbufferRenderTextures.values) {
|
||||||
await texture.destroy(closeSession, ffi);
|
await texture.destroy(ffi);
|
||||||
}
|
}
|
||||||
for (final texture in _gpuRenderTextures.values) {
|
for (final texture in _gpuRenderTextures.values) {
|
||||||
await texture.destroy(closeSession, ffi);
|
await texture.destroy(ffi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,12 +142,22 @@ class FileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> postOverrideFileConfirm(Map<String, dynamic> evt) async {
|
Future<void> postOverrideFileConfirm(Map<String, dynamic> evt) async {
|
||||||
|
final id = int.tryParse(evt['id']?.toString() ?? '');
|
||||||
|
if (id == null || !jobController.hasTransferConflictJob(id)) {
|
||||||
|
debugPrint("Ignore stale override confirm event: $evt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
evtLoop.pushEvent(
|
evtLoop.pushEvent(
|
||||||
_FileDialogEvent(WeakReference(this), FileDialogType.overwrite, evt));
|
_FileDialogEvent(WeakReference(this), FileDialogType.overwrite, evt));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> overrideFileConfirm(Map<String, dynamic> evt,
|
Future<void> overrideFileConfirm(Map<String, dynamic> evt,
|
||||||
{bool? overrideConfirm, bool skip = false}) async {
|
{bool? overrideConfirm, bool skip = false}) async {
|
||||||
|
final id = int.tryParse(evt['id']?.toString() ?? '') ?? 0;
|
||||||
|
if (id == 0 || !jobController.hasTransferConflictJob(id)) {
|
||||||
|
debugPrint("Ignore override confirm for inactive job: $evt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// If `skip == true`, it means to skip this file without showing dialog.
|
// If `skip == true`, it means to skip this file without showing dialog.
|
||||||
// Because `resp` may be null after the user operation or the last remembered operation,
|
// Because `resp` may be null after the user operation or the last remembered operation,
|
||||||
// and we should distinguish them.
|
// and we should distinguish them.
|
||||||
@@ -156,15 +166,12 @@ class FileModel {
|
|||||||
? await showFileConfirmDialog(translate("Overwrite"),
|
? await showFileConfirmDialog(translate("Overwrite"),
|
||||||
"${evt['read_path']}", true, evt['is_identical'] == "true")
|
"${evt['read_path']}", true, evt['is_identical'] == "true")
|
||||||
: null);
|
: null);
|
||||||
final id = int.tryParse(evt['id']) ?? 0;
|
if (!jobController.hasTransferConflictJob(id)) {
|
||||||
|
debugPrint("Ignore override confirm result for inactive job: $evt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (false == resp) {
|
if (false == resp) {
|
||||||
final jobIndex = jobController.getJob(id);
|
await jobController.cancelTransferConflictBatch(id);
|
||||||
if (jobIndex != -1) {
|
|
||||||
await jobController.cancelJob(id);
|
|
||||||
final job = jobController.jobTable[jobIndex];
|
|
||||||
job.state = JobState.done;
|
|
||||||
jobController.jobTable.refresh();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
var need_override = false;
|
var need_override = false;
|
||||||
if (resp == null) {
|
if (resp == null) {
|
||||||
@@ -176,6 +183,7 @@ class FileModel {
|
|||||||
}
|
}
|
||||||
// Update the loop config.
|
// Update the loop config.
|
||||||
if (fileConfirmCheckboxRemember) {
|
if (fileConfirmCheckboxRemember) {
|
||||||
|
jobController.rememberTransferConflictBatch(id, resp);
|
||||||
evtLoop.setSkip(!need_override);
|
evtLoop.setSkip(!need_override);
|
||||||
}
|
}
|
||||||
await bind.sessionSetConfirmOverrideFile(
|
await bind.sessionSetConfirmOverrideFile(
|
||||||
@@ -285,6 +293,8 @@ class FileModel {
|
|||||||
final isWindows = otherSideData.options.isWindows;
|
final isWindows = otherSideData.options.isWindows;
|
||||||
final showHidden = otherSideData.options.showHidden;
|
final showHidden = otherSideData.options.showHidden;
|
||||||
final jobID = jobController.addTransferJob(entry, false);
|
final jobID = jobController.addTransferJob(entry, false);
|
||||||
|
jobController.registerTransferConflictBatch([jobID],
|
||||||
|
batchId: int.tryParse(obj['batchId']?.toString() ?? ''));
|
||||||
webSendLocalFiles(
|
webSendLocalFiles(
|
||||||
handleIndex: handleIndex,
|
handleIndex: handleIndex,
|
||||||
actId: jobID,
|
actId: jobID,
|
||||||
@@ -391,14 +401,30 @@ class FileController {
|
|||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 100));
|
await Future.delayed(Duration(milliseconds: 100));
|
||||||
|
|
||||||
final dir = (await bind.sessionGetPeerOption(
|
final savedDir = (await bind.sessionGetPeerOption(
|
||||||
sessionId: sessionId, name: isLocal ? "local_dir" : "remote_dir"));
|
sessionId: sessionId, name: isLocal ? "local_dir" : "remote_dir"));
|
||||||
openDirectory(dir.isEmpty ? options.value.home : dir);
|
Future<bool> tryOpenReadyDirs() async {
|
||||||
|
final dirs = <String>{
|
||||||
|
if (directory.value.path.isNotEmpty) directory.value.path,
|
||||||
|
if (savedDir.isNotEmpty) savedDir,
|
||||||
|
options.value.home,
|
||||||
|
};
|
||||||
|
for (final dir in dirs) {
|
||||||
|
if (await _openDirectoryPath(dir, isBack: true)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var opened = await tryOpenReadyDirs();
|
||||||
|
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
|
||||||
if (directory.value.path.isEmpty) {
|
if (!opened) {
|
||||||
openDirectory(options.value.home);
|
// The peer may become ready during the reconnect delay, so retry the
|
||||||
|
// same candidates instead of only retrying the default home directory.
|
||||||
|
await tryOpenReadyDirs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,19 +455,23 @@ class FileController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh() async {
|
Future<bool> refresh() async {
|
||||||
await openDirectory(directory.value.path);
|
// "." can be both a refresh command and a real remote directory path.
|
||||||
|
// Refresh must bypass openDirectory's command dispatch to avoid recursion.
|
||||||
|
return await _openDirectoryPath(directory.value.path, isBack: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> openDirectory(String path, {bool isBack = false}) async {
|
Future<bool> openDirectory(String path, {bool isBack = false}) async {
|
||||||
if (path == ".") {
|
if (!isBack && path == ".") {
|
||||||
refresh();
|
return await refresh();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (path == "..") {
|
if (!isBack && path == "..") {
|
||||||
goToParentDirectory();
|
return await _goToParentDirectory(isBack: isBack);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return await _openDirectoryPath(path, isBack: isBack);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _openDirectoryPath(String path, {bool isBack = false}) async {
|
||||||
if (!isBack) {
|
if (!isBack) {
|
||||||
pushHistory();
|
pushHistory();
|
||||||
}
|
}
|
||||||
@@ -458,8 +488,10 @@ class FileController {
|
|||||||
final fd = await fileFetcher.fetchDirectory(path, isLocal, showHidden);
|
final fd = await fileFetcher.fetchDirectory(path, isLocal, showHidden);
|
||||||
fd.format(isWindows, sort: sortBy.value);
|
fd.format(isWindows, sort: sortBy.value);
|
||||||
directory.value = fd;
|
directory.value = fd;
|
||||||
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("Failed to openDirectory $path: $e");
|
debugPrint("Failed to openDirectory $path: $e");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,19 +519,22 @@ class FileController {
|
|||||||
goBack();
|
goBack();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openDirectory(path, isBack: true);
|
unawaited(_openDirectoryPath(path, isBack: true).then<void>((_) {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void goToParentDirectory() {
|
void goToParentDirectory() {
|
||||||
|
unawaited(_goToParentDirectory().then<void>((_) {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _goToParentDirectory({bool isBack = false}) async {
|
||||||
final isWindows = options.value.isWindows;
|
final isWindows = options.value.isWindows;
|
||||||
final dirPath = directory.value.path;
|
final dirPath = directory.value.path;
|
||||||
var parent = PathUtil.dirname(dirPath, isWindows);
|
var parent = PathUtil.dirname(dirPath, isWindows);
|
||||||
// specially for C:\, D:\, goto '/'
|
// specially for C:\, D:\, goto '/'
|
||||||
if (parent == dirPath && isWindows) {
|
if (parent == dirPath && isWindows) {
|
||||||
openDirectory('/');
|
return await _openDirectoryPath('/', isBack: isBack);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
openDirectory(parent);
|
return await _openDirectoryPath(parent, isBack: isBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO deprecated this
|
// TODO deprecated this
|
||||||
@@ -545,8 +580,15 @@ class FileController {
|
|||||||
final toPath = otherSideData.directory.path;
|
final toPath = otherSideData.directory.path;
|
||||||
final isWindows = otherSideData.options.isWindows;
|
final isWindows = otherSideData.options.isWindows;
|
||||||
final showHidden = otherSideData.options.showHidden;
|
final showHidden = otherSideData.options.showHidden;
|
||||||
|
final transferJobs = <(Entry, int)>[];
|
||||||
|
final transferJobIds = <int>[];
|
||||||
for (var from in items.items) {
|
for (var from in items.items) {
|
||||||
final jobID = jobController.addTransferJob(from, isRemoteToLocal);
|
final jobID = jobController.addTransferJob(from, isRemoteToLocal);
|
||||||
|
transferJobs.add((from, jobID));
|
||||||
|
transferJobIds.add(jobID);
|
||||||
|
}
|
||||||
|
jobController.registerTransferConflictBatch(transferJobIds);
|
||||||
|
for (final (from, jobID) in transferJobs) {
|
||||||
bind.sessionSendFiles(
|
bind.sessionSendFiles(
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
actId: jobID,
|
actId: jobID,
|
||||||
@@ -892,6 +934,10 @@ class JobController {
|
|||||||
static final JobID jobID = JobID();
|
static final JobID jobID = JobID();
|
||||||
final jobTable = List<JobProgress>.empty(growable: true).obs;
|
final jobTable = List<JobProgress>.empty(growable: true).obs;
|
||||||
final jobResultListener = JobResultListener<Map<String, dynamic>>();
|
final jobResultListener = JobResultListener<Map<String, dynamic>>();
|
||||||
|
int _nextTransferConflictBatchId = 1;
|
||||||
|
final Map<int, int> _transferConflictJobToBatch = {};
|
||||||
|
int? _transferConflictRememberBatchId;
|
||||||
|
bool? _transferConflictRememberOverrideConfirm;
|
||||||
final GetSessionID getSessionID;
|
final GetSessionID getSessionID;
|
||||||
final GetDialogManager getDialogManager;
|
final GetDialogManager getDialogManager;
|
||||||
SessionID get sessionId => getSessionID();
|
SessionID get sessionId => getSessionID();
|
||||||
@@ -904,6 +950,57 @@ class JobController {
|
|||||||
return jobTable.indexWhere((element) => element.id == id);
|
return jobTable.indexWhere((element) => element.id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void registerTransferConflictBatch(Iterable<int> jobIds, {int? batchId}) {
|
||||||
|
final ids = jobIds.toList(growable: false);
|
||||||
|
if (ids.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
batchId ??= _nextTransferConflictBatchId++;
|
||||||
|
if (batchId >= _nextTransferConflictBatchId) {
|
||||||
|
_nextTransferConflictBatchId = batchId + 1;
|
||||||
|
}
|
||||||
|
for (final jobId in ids) {
|
||||||
|
_transferConflictJobToBatch[jobId] = batchId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int? transferConflictBatchId(int jobId) {
|
||||||
|
return _transferConflictJobToBatch[jobId];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasTransferConflictJob(int jobId) {
|
||||||
|
return transferConflictBatchId(jobId) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isTransferConflictRememberBatch(int? batchId) {
|
||||||
|
return batchId != null && batchId == _transferConflictRememberBatchId;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool? transferConflictRememberOverrideConfirm(int? batchId) {
|
||||||
|
if (!isTransferConflictRememberBatch(batchId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _transferConflictRememberOverrideConfirm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rememberTransferConflictBatch(int jobId, bool? overrideConfirm) {
|
||||||
|
_transferConflictRememberBatchId = _transferConflictJobToBatch[jobId];
|
||||||
|
_transferConflictRememberOverrideConfirm = overrideConfirm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unregisterTransferConflictJob(int jobId) {
|
||||||
|
final batchId = _transferConflictJobToBatch.remove(jobId);
|
||||||
|
if (batchId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_transferConflictJobToBatch.containsValue(batchId)) {
|
||||||
|
if (_transferConflictRememberBatchId == batchId) {
|
||||||
|
_transferConflictRememberBatchId = null;
|
||||||
|
_transferConflictRememberOverrideConfirm = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// return jobID
|
// return jobID
|
||||||
int addTransferJob(Entry from, bool isRemoteToLocal) {
|
int addTransferJob(Entry from, bool isRemoteToLocal) {
|
||||||
final jobID = JobController.jobID.next();
|
final jobID = JobController.jobID.next();
|
||||||
@@ -975,7 +1072,10 @@ class JobController {
|
|||||||
id = int.parse(evt['id']);
|
id = int.parse(evt['id']);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
final jobIndex = getJob(id);
|
final jobIndex = getJob(id);
|
||||||
if (jobIndex == -1) return true;
|
if (jobIndex == -1) {
|
||||||
|
unregisterTransferConflictJob(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
final job = jobTable[jobIndex];
|
final job = jobTable[jobIndex];
|
||||||
job.recvJobRes = true;
|
job.recvJobRes = true;
|
||||||
if (job.type == JobType.deleteFile) {
|
if (job.type == JobType.deleteFile) {
|
||||||
@@ -1001,6 +1101,9 @@ class JobController {
|
|||||||
job.state = JobState.done;
|
job.state = JobState.done;
|
||||||
}
|
}
|
||||||
jobTable.refresh();
|
jobTable.refresh();
|
||||||
|
if (job.state == JobState.done || job.state == JobState.error) {
|
||||||
|
unregisterTransferConflictJob(id);
|
||||||
|
}
|
||||||
if (job.type == JobType.deleteDir) {
|
if (job.type == JobType.deleteDir) {
|
||||||
return job.state == JobState.done;
|
return job.state == JobState.done;
|
||||||
} else {
|
} else {
|
||||||
@@ -1010,9 +1113,15 @@ class JobController {
|
|||||||
|
|
||||||
void jobError(Map<String, dynamic> evt) {
|
void jobError(Map<String, dynamic> evt) {
|
||||||
final err = evt['err'].toString();
|
final err = evt['err'].toString();
|
||||||
int jobIndex = getJob(int.parse(evt['id']));
|
final id = int.tryParse(evt['id']?.toString() ?? '');
|
||||||
|
if (id == null) {
|
||||||
|
debugPrint("Ignore job error with invalid id: $evt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int jobIndex = getJob(id);
|
||||||
if (jobIndex != -1) {
|
if (jobIndex != -1) {
|
||||||
final job = jobTable[jobIndex];
|
final job = jobTable[jobIndex];
|
||||||
|
if (job.state == JobState.done && job.err == "cancel") return;
|
||||||
job.state = JobState.error;
|
job.state = JobState.error;
|
||||||
job.err = err;
|
job.err = err;
|
||||||
job.recvJobRes = true;
|
job.recvJobRes = true;
|
||||||
@@ -1035,6 +1144,11 @@ class JobController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobTable.refresh();
|
jobTable.refresh();
|
||||||
|
if (job.state == JobState.done || job.state == JobState.error) {
|
||||||
|
unregisterTransferConflictJob(job.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unregisterTransferConflictJob(id);
|
||||||
}
|
}
|
||||||
if (err == _kOneWayFileTransferError) {
|
if (err == _kOneWayFileTransferError) {
|
||||||
if (DateTime.now().millisecondsSinceEpoch - _lastTimeShowMsgbox > 3000) {
|
if (DateTime.now().millisecondsSinceEpoch - _lastTimeShowMsgbox > 3000) {
|
||||||
@@ -1071,9 +1185,42 @@ class JobController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cancelJob(int id) async {
|
Future<void> cancelJob(int id) async {
|
||||||
|
unregisterTransferConflictJob(id);
|
||||||
await bind.sessionCancelJob(sessionId: sessionId, actId: id);
|
await bind.sessionCancelJob(sessionId: sessionId, actId: id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> cancelTransferConflictBatch(int jobId) async {
|
||||||
|
final batchId = _transferConflictJobToBatch[jobId];
|
||||||
|
final batchJobIds = batchId == null ? [jobId] : <int>[];
|
||||||
|
if (batchId != null) {
|
||||||
|
for (final entry in _transferConflictJobToBatch.entries) {
|
||||||
|
if (entry.value == batchId) {
|
||||||
|
batchJobIds.add(entry.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (final id in batchJobIds) {
|
||||||
|
unregisterTransferConflictJob(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final jobIdsToCancel = batchJobIds.toSet();
|
||||||
|
for (final job in jobTable) {
|
||||||
|
if (!jobIdsToCancel.contains(job.id) || job.state == JobState.done) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
job.state = JobState.done;
|
||||||
|
job.err = "cancel";
|
||||||
|
job.recvJobRes = true;
|
||||||
|
}
|
||||||
|
jobTable.refresh();
|
||||||
|
for (final id in batchJobIds) {
|
||||||
|
try {
|
||||||
|
await bind.sessionCancelJob(sessionId: sessionId, actId: id);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint("Failed to cancel transfer job $id in conflict batch: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> loadLastJob(Map<String, dynamic> evt) async {
|
Future<void> loadLastJob(Map<String, dynamic> evt) async {
|
||||||
debugPrint("load last job: $evt");
|
debugPrint("load last job: $evt");
|
||||||
Map<String, dynamic> jobDetail = json.decode(evt['value']);
|
Map<String, dynamic> jobDetail = json.decode(evt['value']);
|
||||||
@@ -1120,7 +1267,7 @@ class JobController {
|
|||||||
..state = JobState.paused;
|
..state = JobState.paused;
|
||||||
jobTable.add(jobProgress);
|
jobTable.add(jobProgress);
|
||||||
}
|
}
|
||||||
|
registerTransferConflictBatch([currJobId]);
|
||||||
await bind.sessionAddJob(
|
await bind.sessionAddJob(
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
isRemote: isRemote,
|
isRemote: isRemote,
|
||||||
@@ -1168,6 +1315,9 @@ class JobController {
|
|||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
jobTable.clear();
|
jobTable.clear();
|
||||||
|
_transferConflictJobToBatch.clear();
|
||||||
|
_transferConflictRememberBatchId = null;
|
||||||
|
_transferConflictRememberOverrideConfirm = null;
|
||||||
jobResultListener.clear();
|
jobResultListener.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1510,6 +1660,9 @@ class JobProgress {
|
|||||||
|
|
||||||
String display() {
|
String display() {
|
||||||
if (type == JobType.transfer) {
|
if (type == JobType.transfer) {
|
||||||
|
if (state == JobState.done && err == "cancel") {
|
||||||
|
return translate("Cancel");
|
||||||
|
}
|
||||||
if (state == JobState.done && err == "skipped") {
|
if (state == JobState.done && err == "skipped") {
|
||||||
return translate("Skipped");
|
return translate("Skipped");
|
||||||
}
|
}
|
||||||
@@ -1819,21 +1972,44 @@ class _FileDialogEvent extends BaseEvent<FileDialogType, Map<String, dynamic>> {
|
|||||||
|
|
||||||
class FileDialogEventLoop
|
class FileDialogEventLoop
|
||||||
extends BaseEventLoop<FileDialogType, Map<String, dynamic>> {
|
extends BaseEventLoop<FileDialogType, Map<String, dynamic>> {
|
||||||
|
int? _batchId;
|
||||||
bool? _overrideConfirm;
|
bool? _overrideConfirm;
|
||||||
bool _skip = false;
|
bool _skip = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onPreConsume(
|
Future<void> onPreConsume(
|
||||||
BaseEvent<FileDialogType, Map<String, dynamic>> evt) async {
|
BaseEvent<FileDialogType, Map<String, dynamic>> evt) async {
|
||||||
var event = evt as _FileDialogEvent;
|
final event = evt as _FileDialogEvent;
|
||||||
|
final model = event.fileModel.target;
|
||||||
|
final jobId = int.tryParse(evt.data['id']?.toString() ?? '');
|
||||||
|
final batchId = model == null || jobId == null
|
||||||
|
? null
|
||||||
|
: model.jobController.transferConflictBatchId(jobId);
|
||||||
|
final keepRemembered = model != null &&
|
||||||
|
model.jobController.isTransferConflictRememberBatch(batchId);
|
||||||
|
// The loop only preloads the remembered batch choice. The model updates it
|
||||||
|
// after the user answers the current overwrite dialog.
|
||||||
|
if (_batchId != batchId && !keepRemembered) {
|
||||||
|
_batchId = batchId;
|
||||||
|
_overrideConfirm = null;
|
||||||
|
_skip = false;
|
||||||
|
} else {
|
||||||
|
_batchId = batchId;
|
||||||
|
}
|
||||||
|
if (keepRemembered) {
|
||||||
|
_overrideConfirm =
|
||||||
|
model.jobController.transferConflictRememberOverrideConfirm(batchId);
|
||||||
|
_skip = _overrideConfirm == null;
|
||||||
|
}
|
||||||
event.setOverrideConfirm(_overrideConfirm);
|
event.setOverrideConfirm(_overrideConfirm);
|
||||||
event.setSkip(_skip);
|
event.setSkip(_skip);
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"FileDialogEventLoop: consuming<jobId: ${evt.data['id']} overrideConfirm: $_overrideConfirm, skip: $_skip>");
|
"FileDialogEventLoop: consuming<jobId: ${evt.data['id']} batchId: $_batchId overrideConfirm: $_overrideConfirm, skip: $_skip>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onEventsClear() {
|
Future<void> onEventsClear() {
|
||||||
|
_batchId = null;
|
||||||
_overrideConfirm = null;
|
_overrideConfirm = null;
|
||||||
_skip = false;
|
_skip = false;
|
||||||
return super.onEventsClear();
|
return super.onEventsClear();
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ class GroupModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset() async {
|
reset() async {
|
||||||
|
initialized = false;
|
||||||
groupLoadError.value = '';
|
groupLoadError.value = '';
|
||||||
deviceGroups.clear();
|
deviceGroups.clear();
|
||||||
users.clear();
|
users.clear();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||||
@@ -15,12 +16,13 @@ import 'package:get/get.dart';
|
|||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import '../../models/platform_model.dart';
|
import '../../models/platform_model.dart';
|
||||||
import '../../models/state_model.dart';
|
import '../../models/state_model.dart';
|
||||||
|
import 'input_modifier_utils.dart';
|
||||||
import 'relative_mouse_model.dart';
|
import 'relative_mouse_model.dart';
|
||||||
import '../common.dart';
|
import '../common.dart';
|
||||||
import '../consts.dart';
|
import '../consts.dart';
|
||||||
|
|
||||||
/// Mouse button enum.
|
/// Mouse button enum.
|
||||||
enum MouseButtons { left, right, wheel, back }
|
enum MouseButtons { left, right, wheel, back, forward }
|
||||||
|
|
||||||
const _kMouseEventDown = 'mousedown';
|
const _kMouseEventDown = 'mousedown';
|
||||||
const _kMouseEventUp = 'mouseup';
|
const _kMouseEventUp = 'mouseup';
|
||||||
@@ -59,7 +61,8 @@ class CanvasCoords {
|
|||||||
model.scale = json['scale'];
|
model.scale = json['scale'];
|
||||||
model.scrollX = json['scrollX'];
|
model.scrollX = json['scrollX'];
|
||||||
model.scrollY = json['scrollY'];
|
model.scrollY = json['scrollY'];
|
||||||
model.scrollStyle = ScrollStyle.fromJson(json['scrollStyle'], ScrollStyle.scrollauto);
|
model.scrollStyle =
|
||||||
|
ScrollStyle.fromJson(json['scrollStyle'], ScrollStyle.scrollauto);
|
||||||
model.size = Size(json['size']['w'], json['size']['h']);
|
model.size = Size(json['size']['w'], json['size']['h']);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
@@ -156,6 +159,8 @@ extension ToString on MouseButtons {
|
|||||||
return 'wheel';
|
return 'wheel';
|
||||||
case MouseButtons.back:
|
case MouseButtons.back:
|
||||||
return 'back';
|
return 'back';
|
||||||
|
case MouseButtons.forward:
|
||||||
|
return 'forward';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,6 +331,80 @@ class ToReleaseKeys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class InputModel {
|
class InputModel {
|
||||||
|
// Side mouse button support for Linux.
|
||||||
|
// Flutter's Linux embedder drops X11 button 8/9 events, so we capture them
|
||||||
|
// natively via GDK and forward through the platform channel.
|
||||||
|
static InputModel? _activeSideButtonModel;
|
||||||
|
// Tracks per-button which model received a side button down event, so the
|
||||||
|
// matching up event is routed there even if the pointer has left the view
|
||||||
|
// or a different button was pressed in between.
|
||||||
|
static final Map<MouseButtons, InputModel> _sideButtonDownModels = {};
|
||||||
|
static bool _sideButtonChannelInitialized = false;
|
||||||
|
|
||||||
|
/// Each Flutter engine (main window + sub-windows from desktop_multi_window)
|
||||||
|
/// runs its own Dart isolate with its own statics. Called from initEnv()
|
||||||
|
/// which runs per-engine, so each isolate registers its own handler tied
|
||||||
|
/// to its own set of InputModels.
|
||||||
|
static void initSideButtonChannel() {
|
||||||
|
if (!isLinux) return;
|
||||||
|
if (_sideButtonChannelInitialized) return;
|
||||||
|
_sideButtonChannelInitialized = true;
|
||||||
|
|
||||||
|
const channel = MethodChannel('org.rustdesk.rustdesk/side_buttons');
|
||||||
|
channel.setMethodCallHandler((call) async {
|
||||||
|
if (call.method == 'onSideMouseButton') {
|
||||||
|
final args = call.arguments as Map<dynamic, dynamic>;
|
||||||
|
final button = args['button'] as String;
|
||||||
|
final type = args['type'] as String;
|
||||||
|
final mb = button == 'back' ? MouseButtons.back : MouseButtons.forward;
|
||||||
|
|
||||||
|
if (type == 'down') {
|
||||||
|
final model = _activeSideButtonModel;
|
||||||
|
if (model != null &&
|
||||||
|
!(model.isViewOnly && !model.showMyCursor) &&
|
||||||
|
model.keyboardPerm &&
|
||||||
|
!model.isViewCamera) {
|
||||||
|
_sideButtonDownModels[mb] = model;
|
||||||
|
// Fire-and-forget to avoid blocking the platform channel handler.
|
||||||
|
unawaited(model._sendMouseUnchecked(type, mb).catchError((Object e) {
|
||||||
|
debugPrint('[InputModel] failed to send side button $type for $mb: $e');
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Only route 'up' when we recorded the matching 'down';
|
||||||
|
// dropping avoids sending unpaired 'up' to an unrelated session.
|
||||||
|
// Use _sendMouseUnchecked to bypass permission checks so the
|
||||||
|
// release always goes through even if permissions changed.
|
||||||
|
final model = _sideButtonDownModels.remove(mb);
|
||||||
|
if (model != null) {
|
||||||
|
unawaited(model._sendMouseUnchecked(type, mb).catchError((Object e) {
|
||||||
|
debugPrint('[InputModel] failed to send side button $type for $mb: $e');
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clear any static references to this model (prevents stale routing).
|
||||||
|
/// Releases any held side buttons on the peer so closing a session
|
||||||
|
/// mid-press does not leave a stuck button.
|
||||||
|
void disposeSideButtonTracking() {
|
||||||
|
if (_activeSideButtonModel == this) _activeSideButtonModel = null;
|
||||||
|
final held = _sideButtonDownModels.entries
|
||||||
|
.where((e) => e.value == this)
|
||||||
|
.map((e) => e.key)
|
||||||
|
.toList();
|
||||||
|
for (final mb in held) {
|
||||||
|
_sideButtonDownModels.remove(mb);
|
||||||
|
// Best-effort release; session may already be tearing down.
|
||||||
|
unawaited(_sendMouseUnchecked('up', mb).catchError((Object e) {
|
||||||
|
debugPrint('[InputModel] failed to release side button $mb: $e');
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final WeakReference<FFI> parent;
|
final WeakReference<FFI> parent;
|
||||||
String keyboardMode = '';
|
String keyboardMode = '';
|
||||||
|
|
||||||
@@ -347,6 +426,12 @@ class InputModel {
|
|||||||
final _trackpadAdjustPeerLinux = 0.06;
|
final _trackpadAdjustPeerLinux = 0.06;
|
||||||
// This is an experience value.
|
// This is an experience value.
|
||||||
final _trackpadAdjustMacToWin = 2.50;
|
final _trackpadAdjustMacToWin = 2.50;
|
||||||
|
// Ignore directional locking for very small deltas on both axes (including
|
||||||
|
// tiny single-axis movement) to avoid over-filtering near zero.
|
||||||
|
static const double _trackpadAxisNoiseThreshold = 0.2;
|
||||||
|
// Lock to dominant axis only when one axis is clearly stronger.
|
||||||
|
// 1.6 means the dominant axis must be >= 60% larger than the other.
|
||||||
|
static const double _trackpadAxisLockRatio = 1.6;
|
||||||
int _trackpadSpeed = kDefaultTrackpadSpeed;
|
int _trackpadSpeed = kDefaultTrackpadSpeed;
|
||||||
double _trackpadSpeedInner = kDefaultTrackpadSpeed / 100.0;
|
double _trackpadSpeedInner = kDefaultTrackpadSpeed / 100.0;
|
||||||
var _trackpadScrollUnsent = Offset.zero;
|
var _trackpadScrollUnsent = Offset.zero;
|
||||||
@@ -364,6 +449,16 @@ class InputModel {
|
|||||||
final isPhysicalMouse = false.obs;
|
final isPhysicalMouse = false.obs;
|
||||||
int _lastButtons = 0;
|
int _lastButtons = 0;
|
||||||
Offset lastMousePos = Offset.zero;
|
Offset lastMousePos = Offset.zero;
|
||||||
|
int _lastWheelTsUs = 0;
|
||||||
|
|
||||||
|
// Wheel acceleration thresholds.
|
||||||
|
static const int _wheelAccelFastThresholdUs = 40000; // 40ms
|
||||||
|
static const int _wheelAccelMediumThresholdUs = 80000; // 80ms
|
||||||
|
static const double _wheelBurstVelocityThreshold =
|
||||||
|
0.002; // delta units per microsecond
|
||||||
|
// Wheel burst acceleration (empirical tuning).
|
||||||
|
// Applies only to fast, non-smooth bursts to preserve single-step scrolling.
|
||||||
|
// Flutter uses microseconds for dt, so velocity is in delta/us.
|
||||||
|
|
||||||
// Relative mouse mode (for games/3D apps).
|
// Relative mouse mode (for games/3D apps).
|
||||||
final relativeMouseMode = false.obs;
|
final relativeMouseMode = false.obs;
|
||||||
@@ -379,6 +474,10 @@ class InputModel {
|
|||||||
|
|
||||||
late final SessionID sessionId;
|
late final SessionID sessionId;
|
||||||
|
|
||||||
|
// Local gate for clipboard-assisted input flows on mobile Wayland dialogs.
|
||||||
|
// It should not block physical keyboard events.
|
||||||
|
bool keyboardInputAllowed = true;
|
||||||
|
|
||||||
bool get keyboardPerm => parent.target!.ffiModel.keyboard;
|
bool get keyboardPerm => parent.target!.ffiModel.keyboard;
|
||||||
String get id => parent.target?.id ?? '';
|
String get id => parent.target?.id ?? '';
|
||||||
String? get peerPlatform => parent.target?.ffiModel.pi.platform;
|
String? get peerPlatform => parent.target?.ffiModel.pi.platform;
|
||||||
@@ -395,6 +494,7 @@ class InputModel {
|
|||||||
bool get isRelativeMouseModeSupported => _relativeMouse.isSupported;
|
bool get isRelativeMouseModeSupported => _relativeMouse.isSupported;
|
||||||
|
|
||||||
InputModel(this.parent) {
|
InputModel(this.parent) {
|
||||||
|
initSideButtonChannel();
|
||||||
sessionId = parent.target!.sessionId;
|
sessionId = parent.target!.sessionId;
|
||||||
_relativeMouse = RelativeMouseModel(
|
_relativeMouse = RelativeMouseModel(
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
@@ -418,6 +518,74 @@ class InputModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/flutter/flutter/issues/157241
|
||||||
|
// Infer CapsLock state from the character output.
|
||||||
|
// This is needed because Flutter's HardwareKeyboard.lockModesEnabled may report
|
||||||
|
// incorrect CapsLock state on iOS.
|
||||||
|
bool _getIosCapsFromCharacter(KeyEvent e) {
|
||||||
|
if (!isIOS) return false;
|
||||||
|
final ch = e.character;
|
||||||
|
return _getIosCapsFromCharacterImpl(
|
||||||
|
ch, HardwareKeyboard.instance.isShiftPressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RawKeyEvent version of _getIosCapsFromCharacter.
|
||||||
|
bool _getIosCapsFromRawCharacter(RawKeyEvent e) {
|
||||||
|
if (!isIOS) return false;
|
||||||
|
final ch = e.character;
|
||||||
|
return _getIosCapsFromCharacterImpl(ch, e.isShiftPressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shared implementation for inferring CapsLock state from character.
|
||||||
|
// Uses Unicode-aware case detection to support non-ASCII letters (e.g., ü/Ü, é/É).
|
||||||
|
//
|
||||||
|
// Limitations:
|
||||||
|
// 1. This inference assumes the client and server use the same keyboard layout.
|
||||||
|
// If layouts differ (e.g., client uses EN, server uses DE), the character output
|
||||||
|
// may not match expectations. For example, ';' on EN layout maps to 'ö' on DE
|
||||||
|
// layout, making it impossible to correctly infer CapsLock state from the
|
||||||
|
// character alone.
|
||||||
|
// 2. On iOS, CapsLock+Shift produces uppercase letters (unlike desktop where it
|
||||||
|
// produces lowercase). This method cannot handle that case correctly.
|
||||||
|
bool _getIosCapsFromCharacterImpl(String? ch, bool shiftPressed) {
|
||||||
|
if (ch == null || ch.length != 1) return false;
|
||||||
|
// Use Dart's built-in Unicode-aware case detection
|
||||||
|
final upper = ch.toUpperCase();
|
||||||
|
final lower = ch.toLowerCase();
|
||||||
|
final isUpper = upper == ch && lower != ch;
|
||||||
|
final isLower = lower == ch && upper != ch;
|
||||||
|
// Skip non-letter characters (e.g., numbers, symbols, CJK characters without case)
|
||||||
|
if (!isUpper && !isLower) return false;
|
||||||
|
return isUpper != shiftPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _buildLockModes(bool iosCapsLock) {
|
||||||
|
const capslock = 1;
|
||||||
|
const numlock = 2;
|
||||||
|
const scrolllock = 3;
|
||||||
|
int lockModes = 0;
|
||||||
|
if (isIOS) {
|
||||||
|
if (iosCapsLock) {
|
||||||
|
lockModes |= (1 << capslock);
|
||||||
|
}
|
||||||
|
// Ignore "NumLock/ScrollLock" on iOS for now.
|
||||||
|
} else {
|
||||||
|
if (HardwareKeyboard.instance.lockModesEnabled
|
||||||
|
.contains(KeyboardLockMode.capsLock)) {
|
||||||
|
lockModes |= (1 << capslock);
|
||||||
|
}
|
||||||
|
if (HardwareKeyboard.instance.lockModesEnabled
|
||||||
|
.contains(KeyboardLockMode.numLock)) {
|
||||||
|
lockModes |= (1 << numlock);
|
||||||
|
}
|
||||||
|
if (HardwareKeyboard.instance.lockModesEnabled
|
||||||
|
.contains(KeyboardLockMode.scrollLock)) {
|
||||||
|
lockModes |= (1 << scrolllock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lockModes;
|
||||||
|
}
|
||||||
|
|
||||||
// This function must be called after the peer info is received.
|
// This function must be called after the peer info is received.
|
||||||
// Because `sessionGetKeyboardMode` relies on the peer version.
|
// Because `sessionGetKeyboardMode` relies on the peer version.
|
||||||
updateKeyboardMode() async {
|
updateKeyboardMode() async {
|
||||||
@@ -535,6 +703,38 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safe: this only re-dispatches synthesized Shift key-up events.
|
||||||
|
// The key-up path clears the tracked Shift state so this does not loop.
|
||||||
|
void _releaseTrackedShiftKeyEventIfNeeded() {
|
||||||
|
final leftShift = toReleaseKeys.lastLShiftKeyEvent;
|
||||||
|
final rightShift = toReleaseKeys.lastRShiftKeyEvent;
|
||||||
|
if (leftShift != null) {
|
||||||
|
handleKeyEvent(leftShift);
|
||||||
|
}
|
||||||
|
if (rightShift != null) {
|
||||||
|
handleKeyEvent(rightShift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safe: this only re-dispatches synthesized Shift key-up events.
|
||||||
|
// The raw key-up path clears the tracked Shift state so this does not loop.
|
||||||
|
void _releaseTrackedRawShiftKeyEventIfNeeded() {
|
||||||
|
final leftShift = toReleaseRawKeys.lastLShiftKeyEvent;
|
||||||
|
final rightShift = toReleaseRawKeys.lastRShiftKeyEvent;
|
||||||
|
if (leftShift != null) {
|
||||||
|
handleRawKeyEvent(RawKeyUpEvent(
|
||||||
|
data: leftShift.data,
|
||||||
|
character: leftShift.character,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (rightShift != null) {
|
||||||
|
handleRawKeyEvent(RawKeyUpEvent(
|
||||||
|
data: rightShift.data,
|
||||||
|
character: rightShift.character,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KeyEventResult handleRawKeyEvent(RawKeyEvent e) {
|
KeyEventResult handleRawKeyEvent(RawKeyEvent e) {
|
||||||
if (isViewOnly) return KeyEventResult.handled;
|
if (isViewOnly) return KeyEventResult.handled;
|
||||||
if (isViewCamera) return KeyEventResult.handled;
|
if (isViewCamera) return KeyEventResult.handled;
|
||||||
@@ -550,6 +750,11 @@ class InputModel {
|
|||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool iosCapsLock = false;
|
||||||
|
if (isIOS && e is RawKeyDownEvent) {
|
||||||
|
iosCapsLock = _getIosCapsFromRawCharacter(e);
|
||||||
|
}
|
||||||
|
|
||||||
final key = e.logicalKey;
|
final key = e.logicalKey;
|
||||||
if (e is RawKeyDownEvent) {
|
if (e is RawKeyDownEvent) {
|
||||||
if (!e.repeat) {
|
if (!e.repeat) {
|
||||||
@@ -584,9 +789,30 @@ class InputModel {
|
|||||||
toReleaseRawKeys.updateKeyUp(key, e);
|
toReleaseRawKeys.updateKeyUp(key, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On some mobile soft-keyboard paths, Flutter may leave cached Shift state
|
||||||
|
// set even though the current raw key event is not shifted anymore.
|
||||||
|
if (e is RawKeyDownEvent &&
|
||||||
|
shouldReleaseStaleMobileShift(
|
||||||
|
isMobile: isMobile,
|
||||||
|
cachedShiftPressed: shift,
|
||||||
|
actualShiftPressed: e.isShiftPressed,
|
||||||
|
logicalKey: e.logicalKey,
|
||||||
|
hasTrackedShiftKeyDown: toReleaseRawKeys.lastLShiftKeyEvent != null ||
|
||||||
|
toReleaseRawKeys.lastRShiftKeyEvent != null,
|
||||||
|
)) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'input: releasing stale mobile Shift before replaying tracked raw '
|
||||||
|
'key-up (logicalKey=${e.logicalKey.keyLabel}, '
|
||||||
|
'actualShiftPressed=${e.isShiftPressed}, cachedShiftPressed=$shift)',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_releaseTrackedRawShiftKeyEventIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
// * Currently mobile does not enable map mode
|
// * Currently mobile does not enable map mode
|
||||||
if ((isDesktop || isWebDesktop) && keyboardMode == kKeyMapMode) {
|
if ((isDesktop || isWebDesktop) && keyboardMode == kKeyMapMode) {
|
||||||
mapKeyboardModeRaw(e);
|
mapKeyboardModeRaw(e, iosCapsLock);
|
||||||
} else {
|
} else {
|
||||||
legacyKeyboardModeRaw(e);
|
legacyKeyboardModeRaw(e);
|
||||||
}
|
}
|
||||||
@@ -622,6 +848,13 @@ class InputModel {
|
|||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool iosCapsLock = false;
|
||||||
|
if (isIOS && (e is KeyDownEvent || e is KeyRepeatEvent)) {
|
||||||
|
iosCapsLock = _getIosCapsFromCharacter(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update cached modifier state before sending the event. The stale mobile
|
||||||
|
// Shift release check below relies on this cached state.
|
||||||
if (e is KeyUpEvent) {
|
if (e is KeyUpEvent) {
|
||||||
handleKeyUpEventModifiers(e);
|
handleKeyUpEventModifiers(e);
|
||||||
} else if (e is KeyDownEvent) {
|
} else if (e is KeyDownEvent) {
|
||||||
@@ -659,6 +892,21 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On some mobile soft-keyboard paths, Flutter may leave cached Shift state
|
||||||
|
// set even though the current key event is not shifted anymore.
|
||||||
|
if (e is KeyDownEvent &&
|
||||||
|
shouldReleaseStaleMobileShift(
|
||||||
|
isMobile: isMobile,
|
||||||
|
cachedShiftPressed: shift,
|
||||||
|
actualShiftPressed: HardwareKeyboard.instance.isShiftPressed,
|
||||||
|
logicalKey: e.logicalKey,
|
||||||
|
hasTrackedShiftKeyDown: toReleaseKeys.lastLShiftKeyEvent != null ||
|
||||||
|
toReleaseKeys.lastRShiftKeyEvent != null,
|
||||||
|
)) {
|
||||||
|
_releaseTrackedShiftKeyEventIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
final isDesktopAndMapMode =
|
final isDesktopAndMapMode =
|
||||||
isDesktop || (isWebDesktop && keyboardMode == kKeyMapMode);
|
isDesktop || (isWebDesktop && keyboardMode == kKeyMapMode);
|
||||||
if (isMobileAndMapMode || isDesktopAndMapMode) {
|
if (isMobileAndMapMode || isDesktopAndMapMode) {
|
||||||
@@ -667,7 +915,8 @@ class InputModel {
|
|||||||
e.character ?? '',
|
e.character ?? '',
|
||||||
e.physicalKey.usbHidUsage & 0xFFFF,
|
e.physicalKey.usbHidUsage & 0xFFFF,
|
||||||
// Show repeat event be converted to "release+press" events?
|
// Show repeat event be converted to "release+press" events?
|
||||||
e is KeyDownEvent || e is KeyRepeatEvent);
|
e is KeyDownEvent || e is KeyRepeatEvent,
|
||||||
|
iosCapsLock);
|
||||||
} else {
|
} else {
|
||||||
legacyKeyboardMode(e);
|
legacyKeyboardMode(e);
|
||||||
}
|
}
|
||||||
@@ -676,23 +925,9 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send Key Event
|
/// Send Key Event
|
||||||
void newKeyboardMode(String character, int usbHid, bool down) {
|
void newKeyboardMode(
|
||||||
const capslock = 1;
|
String character, int usbHid, bool down, bool iosCapsLock) {
|
||||||
const numlock = 2;
|
final lockModes = _buildLockModes(iosCapsLock);
|
||||||
const scrolllock = 3;
|
|
||||||
int lockModes = 0;
|
|
||||||
if (HardwareKeyboard.instance.lockModesEnabled
|
|
||||||
.contains(KeyboardLockMode.capsLock)) {
|
|
||||||
lockModes |= (1 << capslock);
|
|
||||||
}
|
|
||||||
if (HardwareKeyboard.instance.lockModesEnabled
|
|
||||||
.contains(KeyboardLockMode.numLock)) {
|
|
||||||
lockModes |= (1 << numlock);
|
|
||||||
}
|
|
||||||
if (HardwareKeyboard.instance.lockModesEnabled
|
|
||||||
.contains(KeyboardLockMode.scrollLock)) {
|
|
||||||
lockModes |= (1 << scrolllock);
|
|
||||||
}
|
|
||||||
bind.sessionHandleFlutterKeyEvent(
|
bind.sessionHandleFlutterKeyEvent(
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
character: character,
|
character: character,
|
||||||
@@ -701,7 +936,7 @@ class InputModel {
|
|||||||
downOrUp: down);
|
downOrUp: down);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapKeyboardModeRaw(RawKeyEvent e) {
|
void mapKeyboardModeRaw(RawKeyEvent e, bool iosCapsLock) {
|
||||||
int positionCode = -1;
|
int positionCode = -1;
|
||||||
int platformCode = -1;
|
int platformCode = -1;
|
||||||
bool down;
|
bool down;
|
||||||
@@ -732,27 +967,14 @@ class InputModel {
|
|||||||
} else {
|
} else {
|
||||||
down = false;
|
down = false;
|
||||||
}
|
}
|
||||||
inputRawKey(e.character ?? '', platformCode, positionCode, down);
|
inputRawKey(
|
||||||
|
e.character ?? '', platformCode, positionCode, down, iosCapsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send raw Key Event
|
/// Send raw Key Event
|
||||||
void inputRawKey(String name, int platformCode, int positionCode, bool down) {
|
void inputRawKey(String name, int platformCode, int positionCode, bool down,
|
||||||
const capslock = 1;
|
bool iosCapsLock) {
|
||||||
const numlock = 2;
|
final lockModes = _buildLockModes(iosCapsLock);
|
||||||
const scrolllock = 3;
|
|
||||||
int lockModes = 0;
|
|
||||||
if (HardwareKeyboard.instance.lockModesEnabled
|
|
||||||
.contains(KeyboardLockMode.capsLock)) {
|
|
||||||
lockModes |= (1 << capslock);
|
|
||||||
}
|
|
||||||
if (HardwareKeyboard.instance.lockModesEnabled
|
|
||||||
.contains(KeyboardLockMode.numLock)) {
|
|
||||||
lockModes |= (1 << numlock);
|
|
||||||
}
|
|
||||||
if (HardwareKeyboard.instance.lockModesEnabled
|
|
||||||
.contains(KeyboardLockMode.scrollLock)) {
|
|
||||||
lockModes |= (1 << scrolllock);
|
|
||||||
}
|
|
||||||
bind.sessionHandleFlutterRawKeyEvent(
|
bind.sessionHandleFlutterRawKeyEvent(
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
name: name,
|
name: name,
|
||||||
@@ -826,6 +1048,9 @@ class InputModel {
|
|||||||
Map<String, dynamic> _getMouseEvent(PointerEvent evt, String type) {
|
Map<String, dynamic> _getMouseEvent(PointerEvent evt, String type) {
|
||||||
final Map<String, dynamic> out = {};
|
final Map<String, dynamic> out = {};
|
||||||
|
|
||||||
|
bool hasStaleButtonsOnMouseUp =
|
||||||
|
type == _kMouseEventUp && evt.buttons == _lastButtons;
|
||||||
|
|
||||||
// Check update event type and set buttons to be sent.
|
// Check update event type and set buttons to be sent.
|
||||||
int buttons = _lastButtons;
|
int buttons = _lastButtons;
|
||||||
if (type == _kMouseEventMove) {
|
if (type == _kMouseEventMove) {
|
||||||
@@ -850,7 +1075,7 @@ class InputModel {
|
|||||||
buttons = evt.buttons;
|
buttons = evt.buttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lastButtons = evt.buttons;
|
_lastButtons = hasStaleButtonsOnMouseUp ? 0 : evt.buttons;
|
||||||
|
|
||||||
out['buttons'] = buttons;
|
out['buttons'] = buttons;
|
||||||
out['type'] = type;
|
out['type'] = type;
|
||||||
@@ -894,13 +1119,20 @@ class InputModel {
|
|||||||
return evt;
|
return evt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send mouse event unconditionally (no permission checks).
|
||||||
|
/// Used for side button releases that must go through even if permissions
|
||||||
|
/// changed after the matching down was sent.
|
||||||
|
Future<void> _sendMouseUnchecked(String type, MouseButtons button) async {
|
||||||
|
await bind.sessionSendMouse(
|
||||||
|
sessionId: sessionId,
|
||||||
|
msg: json.encode(modify({'type': type, 'buttons': button.value})));
|
||||||
|
}
|
||||||
|
|
||||||
/// Send mouse press event.
|
/// Send mouse press event.
|
||||||
Future<void> sendMouse(String type, MouseButtons button) async {
|
Future<void> sendMouse(String type, MouseButtons button) async {
|
||||||
if (!keyboardPerm) return;
|
if (!keyboardPerm) return;
|
||||||
if (isViewCamera) return;
|
if (isViewCamera) return;
|
||||||
await bind.sessionSendMouse(
|
await _sendMouseUnchecked(type, button);
|
||||||
sessionId: sessionId,
|
|
||||||
msg: json.encode(modify({'type': type, 'buttons': button.value})));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterOrLeave(bool enter) {
|
void enterOrLeave(bool enter) {
|
||||||
@@ -908,6 +1140,14 @@ class InputModel {
|
|||||||
toReleaseRawKeys.release(handleRawKeyEvent);
|
toReleaseRawKeys.release(handleRawKeyEvent);
|
||||||
_pointerMovedAfterEnter = false;
|
_pointerMovedAfterEnter = false;
|
||||||
_pointerInsideImage = enter;
|
_pointerInsideImage = enter;
|
||||||
|
_lastWheelTsUs = 0;
|
||||||
|
|
||||||
|
// Track active model for side button events (Linux).
|
||||||
|
if (enter) {
|
||||||
|
_activeSideButtonModel = this;
|
||||||
|
} else if (_activeSideButtonModel == this) {
|
||||||
|
_activeSideButtonModel = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Fix status
|
// Fix status
|
||||||
if (!enter) {
|
if (!enter) {
|
||||||
@@ -1048,6 +1288,14 @@ class InputModel {
|
|||||||
if (isViewOnly && !showMyCursor) return;
|
if (isViewOnly && !showMyCursor) return;
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||||
|
|
||||||
|
// May fix https://github.com/rustdesk/rustdesk/issues/13009
|
||||||
|
if (isIOS && e.synthesized && e.position == Offset.zero && e.buttons == 0) {
|
||||||
|
// iOS may emit a synthesized hover event at (0,0) when the mouse is disconnected.
|
||||||
|
// Ignore this event to prevent cursor jumping.
|
||||||
|
debugPrint('Ignored synthesized hover at (0,0) on iOS');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only update pointer region when relative mouse mode is enabled.
|
// Only update pointer region when relative mouse mode is enabled.
|
||||||
// This avoids unnecessary tracking when not in relative mode.
|
// This avoids unnecessary tracking when not in relative mode.
|
||||||
if (_relativeMouse.enabled.value) {
|
if (_relativeMouse.enabled.value) {
|
||||||
@@ -1059,7 +1307,8 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
if (isPhysicalMouse.value) {
|
if (isPhysicalMouse.value) {
|
||||||
if (!_relativeMouse.handleRelativeMouseMove(e.localPosition)) {
|
if (!_relativeMouse.handleRelativeMouseMove(e.localPosition)) {
|
||||||
handleMouse(_getMouseEvent(e, _kMouseEventMove), e.position,
|
final canvasPosition = _pointerPositionForRemoteCanvas(e);
|
||||||
|
handleMouse(_getMouseEvent(e, _kMouseEventMove), canvasPosition,
|
||||||
edgeScroll: useEdgeScroll);
|
edgeScroll: useEdgeScroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1097,6 +1346,7 @@ class InputModel {
|
|||||||
if (isMacOS && peerPlatform == kPeerPlatformWindows) {
|
if (isMacOS && peerPlatform == kPeerPlatformWindows) {
|
||||||
delta *= _trackpadAdjustMacToWin;
|
delta *= _trackpadAdjustMacToWin;
|
||||||
}
|
}
|
||||||
|
delta = _filterTrackpadDeltaAxis(delta);
|
||||||
_trackpadLastDelta = delta;
|
_trackpadLastDelta = delta;
|
||||||
|
|
||||||
var x = delta.dx.toInt();
|
var x = delta.dx.toInt();
|
||||||
@@ -1129,6 +1379,24 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Offset _filterTrackpadDeltaAxis(Offset delta) {
|
||||||
|
final absDx = delta.dx.abs();
|
||||||
|
final absDy = delta.dy.abs();
|
||||||
|
// Keep diagonal intent when movement is tiny on both axes.
|
||||||
|
if (absDx < _trackpadAxisNoiseThreshold &&
|
||||||
|
absDy < _trackpadAxisNoiseThreshold) {
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
// Dominant-axis lock to reduce accidental cross-axis scrolling noise.
|
||||||
|
if (absDy >= absDx * _trackpadAxisLockRatio) {
|
||||||
|
return Offset(0, delta.dy);
|
||||||
|
}
|
||||||
|
if (absDx >= absDy * _trackpadAxisLockRatio) {
|
||||||
|
return Offset(delta.dx, 0);
|
||||||
|
}
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
void _scheduleFling(double x, double y, int delay) {
|
void _scheduleFling(double x, double y, int delay) {
|
||||||
if (isViewCamera) return;
|
if (isViewCamera) return;
|
||||||
if ((x == 0 && y == 0) || _stopFling) {
|
if ((x == 0 && y == 0) || _stopFling) {
|
||||||
@@ -1210,6 +1478,38 @@ class InputModel {
|
|||||||
_trackpadLastDelta = Offset.zero;
|
_trackpadLastDelta = Offset.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// iOS Magic Mouse duplicate event detection.
|
||||||
|
// When using Magic Mouse on iPad, iOS may emit both mouse and touch events
|
||||||
|
// for the same click in certain areas (like top-left corner).
|
||||||
|
int _lastMouseDownTimeMs = 0;
|
||||||
|
ui.Offset _lastMouseDownPos = ui.Offset.zero;
|
||||||
|
|
||||||
|
/// Check if a touch tap event should be ignored because it's a duplicate
|
||||||
|
/// of a recent mouse event (iOS Magic Mouse issue).
|
||||||
|
bool shouldIgnoreTouchTap(ui.Offset pos) {
|
||||||
|
if (!isIOS) return false;
|
||||||
|
final nowMs = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
final dt = nowMs - _lastMouseDownTimeMs;
|
||||||
|
final distance = (_lastMouseDownPos - pos).distance;
|
||||||
|
// If touch tap is within 2000ms and 80px of the last mouse down,
|
||||||
|
// it's likely a duplicate event from the same Magic Mouse click.
|
||||||
|
if (dt >= 0 && dt < 2000 && distance < 80.0) {
|
||||||
|
debugPrint("shouldIgnoreTouchTap: IGNORED (dt=$dt, dist=$distance)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// iOS may emit a synthesized touch event after a real mouse click.
|
||||||
|
/// This helper ignores touch-down events that arrive shortly after a mouse down,
|
||||||
|
/// even when the position is far (e.g., near the top edge).
|
||||||
|
bool _shouldIgnoreTouchAfterMouse(int nowMs) {
|
||||||
|
if (!isIOS) return false;
|
||||||
|
const int kTouchAfterMouseWindowMs = 700;
|
||||||
|
final dt = nowMs - _lastMouseDownTimeMs;
|
||||||
|
return dt >= 0 && dt < kTouchAfterMouseWindowMs;
|
||||||
|
}
|
||||||
|
|
||||||
void onPointDownImage(PointerDownEvent e) {
|
void onPointDownImage(PointerDownEvent e) {
|
||||||
debugPrint("onPointDownImage ${e.kind}");
|
debugPrint("onPointDownImage ${e.kind}");
|
||||||
_stopFling = true;
|
_stopFling = true;
|
||||||
@@ -1219,11 +1519,25 @@ class InputModel {
|
|||||||
if (isViewOnly && !showMyCursor) return;
|
if (isViewOnly && !showMyCursor) return;
|
||||||
if (isViewCamera) return;
|
if (isViewCamera) return;
|
||||||
|
|
||||||
|
// Track mouse down events for duplicate detection on iOS.
|
||||||
|
final nowMs = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
if (e.kind == ui.PointerDeviceKind.mouse) {
|
||||||
|
if (!isPhysicalMouse.value) {
|
||||||
|
isPhysicalMouse.value = true;
|
||||||
|
}
|
||||||
|
_lastMouseDownTimeMs = nowMs;
|
||||||
|
_lastMouseDownPos = e.position;
|
||||||
|
}
|
||||||
|
|
||||||
if (_relativeMouse.enabled.value) {
|
if (_relativeMouse.enabled.value) {
|
||||||
_relativeMouse.updatePointerRegionTopLeftGlobal(e);
|
_relativeMouse.updatePointerRegionTopLeftGlobal(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) {
|
if (e.kind != ui.PointerDeviceKind.mouse) {
|
||||||
|
// Ignore duplicate touch events that follow a recent mouse click (iOS Magic Mouse issue).
|
||||||
|
if (isPhysicalMouse.value && _shouldIgnoreTouchAfterMouse(nowMs)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isPhysicalMouse.value) {
|
if (isPhysicalMouse.value) {
|
||||||
isPhysicalMouse.value = false;
|
isPhysicalMouse.value = false;
|
||||||
}
|
}
|
||||||
@@ -1235,7 +1549,8 @@ class InputModel {
|
|||||||
_relativeMouse
|
_relativeMouse
|
||||||
.sendRelativeMouseButton(_getMouseEvent(e, _kMouseEventDown));
|
.sendRelativeMouseButton(_getMouseEvent(e, _kMouseEventDown));
|
||||||
} else {
|
} else {
|
||||||
handleMouse(_getMouseEvent(e, _kMouseEventDown), e.position);
|
final canvasPosition = _pointerPositionForRemoteCanvas(e);
|
||||||
|
handleMouse(_getMouseEvent(e, _kMouseEventDown), canvasPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1257,7 +1572,8 @@ class InputModel {
|
|||||||
_relativeMouse
|
_relativeMouse
|
||||||
.sendRelativeMouseButton(_getMouseEvent(e, _kMouseEventUp));
|
.sendRelativeMouseButton(_getMouseEvent(e, _kMouseEventUp));
|
||||||
} else {
|
} else {
|
||||||
handleMouse(_getMouseEvent(e, _kMouseEventUp), e.position);
|
final canvasPosition = _pointerPositionForRemoteCanvas(e);
|
||||||
|
handleMouse(_getMouseEvent(e, _kMouseEventUp), canvasPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1279,12 +1595,40 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
if (isPhysicalMouse.value) {
|
if (isPhysicalMouse.value) {
|
||||||
if (!_relativeMouse.handleRelativeMouseMove(e.localPosition)) {
|
if (!_relativeMouse.handleRelativeMouseMove(e.localPosition)) {
|
||||||
handleMouse(_getMouseEvent(e, _kMouseEventMove), e.position,
|
final canvasPosition = _pointerPositionForRemoteCanvas(e);
|
||||||
|
handleMouse(_getMouseEvent(e, _kMouseEventMove), canvasPosition,
|
||||||
edgeScroll: useEdgeScroll);
|
edgeScroll: useEdgeScroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert pointer coordinates into the visible remote canvas space.
|
||||||
|
///
|
||||||
|
/// On mobile, the remote page body is wrapped in `SafeArea`, but the pointer
|
||||||
|
/// listener that feeds these events sits outside that subtree. As a result,
|
||||||
|
/// `event.localPosition` still includes the top/left safe-area inset.
|
||||||
|
///
|
||||||
|
/// When the keyboard-visible path shows `KeyHelpTools`, the remote canvas is
|
||||||
|
/// also shifted downward by `CanvasModel.getAdjustY()`. The downstream mouse
|
||||||
|
/// mapping logic expects coordinates relative to the visible canvas area, so
|
||||||
|
/// we subtract both the mobile safe-area padding and the current canvas
|
||||||
|
/// adjustment before passing the position into mouse mapping.
|
||||||
|
///
|
||||||
|
/// Desktop and web desktop continue to use the global position directly
|
||||||
|
/// because their pointer mapping is window-based.
|
||||||
|
Offset _pointerPositionForRemoteCanvas(PointerEvent event) {
|
||||||
|
if (isDesktop || isWebDesktop) {
|
||||||
|
return event.position;
|
||||||
|
}
|
||||||
|
final mediaData = MediaQueryData.fromView(
|
||||||
|
WidgetsBinding.instance.platformDispatcher.views.first);
|
||||||
|
final adjustY = parent.target?.canvasModel.getAdjustY() ?? 0.0;
|
||||||
|
return Offset(
|
||||||
|
event.localPosition.dx - mediaData.padding.left,
|
||||||
|
event.localPosition.dy - mediaData.padding.top - adjustY,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static Future<Rect?> fillRemoteCoordsAndGetCurFrame(
|
static Future<Rect?> fillRemoteCoordsAndGetCurFrame(
|
||||||
List<RemoteWindowCoords> remoteWindowCoords) async {
|
List<RemoteWindowCoords> remoteWindowCoords) async {
|
||||||
final coords =
|
final coords =
|
||||||
@@ -1314,17 +1658,44 @@ class InputModel {
|
|||||||
if (isViewOnly) return;
|
if (isViewOnly) return;
|
||||||
if (isViewCamera) return;
|
if (isViewCamera) return;
|
||||||
if (e is PointerScrollEvent) {
|
if (e is PointerScrollEvent) {
|
||||||
var dx = e.scrollDelta.dx.toInt();
|
final rawDx = e.scrollDelta.dx;
|
||||||
var dy = e.scrollDelta.dy.toInt();
|
final rawDy = e.scrollDelta.dy;
|
||||||
|
final dominantDelta = rawDx.abs() > rawDy.abs() ? rawDx.abs() : rawDy.abs();
|
||||||
|
final isSmooth = dominantDelta < 1;
|
||||||
|
final nowUs = DateTime.now().microsecondsSinceEpoch;
|
||||||
|
final dtUs = _lastWheelTsUs == 0 ? 0 : nowUs - _lastWheelTsUs;
|
||||||
|
_lastWheelTsUs = nowUs;
|
||||||
|
int accel = 1;
|
||||||
|
if (!isSmooth &&
|
||||||
|
dtUs > 0 &&
|
||||||
|
dtUs <= _wheelAccelMediumThresholdUs &&
|
||||||
|
(isWindows || isLinux) &&
|
||||||
|
peerPlatform == kPeerPlatformMacOS) {
|
||||||
|
final velocity = dominantDelta / dtUs;
|
||||||
|
if (velocity >= _wheelBurstVelocityThreshold) {
|
||||||
|
if (dtUs < _wheelAccelFastThresholdUs) {
|
||||||
|
accel = 3;
|
||||||
|
} else {
|
||||||
|
accel = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var dx = rawDx.toInt();
|
||||||
|
var dy = rawDy.toInt();
|
||||||
|
if (rawDx.abs() > rawDy.abs()) {
|
||||||
|
dy = 0;
|
||||||
|
} else {
|
||||||
|
dx = 0;
|
||||||
|
}
|
||||||
if (dx > 0) {
|
if (dx > 0) {
|
||||||
dx = -1;
|
dx = -accel;
|
||||||
} else if (dx < 0) {
|
} else if (dx < 0) {
|
||||||
dx = 1;
|
dx = accel;
|
||||||
}
|
}
|
||||||
if (dy > 0) {
|
if (dy > 0) {
|
||||||
dy = -1;
|
dy = -accel;
|
||||||
} else if (dy < 0) {
|
} else if (dy < 0) {
|
||||||
dy = 1;
|
dy = accel;
|
||||||
}
|
}
|
||||||
bind.sessionSendMouse(
|
bind.sessionSendMouse(
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
@@ -1760,9 +2131,9 @@ class InputModel {
|
|||||||
// Simulate a key press event.
|
// Simulate a key press event.
|
||||||
// `usbHidUsage` is the USB HID usage code of the key.
|
// `usbHidUsage` is the USB HID usage code of the key.
|
||||||
Future<void> tapHidKey(int usbHidUsage) async {
|
Future<void> tapHidKey(int usbHidUsage) async {
|
||||||
newKeyboardMode(kKeyFlutterKey, usbHidUsage, true);
|
newKeyboardMode(kKeyFlutterKey, usbHidUsage, true, false);
|
||||||
await Future.delayed(Duration(milliseconds: 100));
|
await Future.delayed(Duration(milliseconds: 100));
|
||||||
newKeyboardMode(kKeyFlutterKey, usbHidUsage, false);
|
newKeyboardMode(kKeyFlutterKey, usbHidUsage, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onMobileVolumeUp() async =>
|
Future<void> onMobileVolumeUp() async =>
|
||||||
|
|||||||
190
flutter/lib/models/input_modifier_utils.dart
Normal file
190
flutter/lib/models/input_modifier_utils.dart
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// Identifies where terminal input originated so paste data can bypass all
|
||||||
|
/// keyboard-only transformations.
|
||||||
|
enum TerminalInputSource {
|
||||||
|
keyboard,
|
||||||
|
paste,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true when a stale mobile one-shot Shift state should be released
|
||||||
|
/// by replaying a tracked Shift key-down as a synthesized key-up.
|
||||||
|
///
|
||||||
|
/// This is only valid on mobile when Flutter's cached Shift state is still on
|
||||||
|
/// (`cachedShiftPressed == true`) but the current hardware/raw event reports
|
||||||
|
/// Shift as off (`actualShiftPressed == false`).
|
||||||
|
///
|
||||||
|
/// A tracked Shift key-down is required so the caller can safely synthesize the
|
||||||
|
/// matching key-up. Both `shiftLeft` and `shiftRight` are excluded because the
|
||||||
|
/// Shift key event itself must be processed first; otherwise we could release
|
||||||
|
/// the tracked key while still handling the original Shift press/release.
|
||||||
|
/// Callers should evaluate this only after their cached modifier state has been
|
||||||
|
/// updated for the current event.
|
||||||
|
///
|
||||||
|
/// When this returns true, the caller logs a line like:
|
||||||
|
/// `input: releasing stale mobile Shift before replaying tracked raw key-up`
|
||||||
|
/// immediately before calling `_releaseTrackedRawShiftKeyEventIfNeeded()`.
|
||||||
|
bool shouldReleaseStaleMobileShift({
|
||||||
|
required bool isMobile,
|
||||||
|
required bool cachedShiftPressed,
|
||||||
|
required bool actualShiftPressed,
|
||||||
|
required LogicalKeyboardKey logicalKey,
|
||||||
|
required bool hasTrackedShiftKeyDown,
|
||||||
|
}) {
|
||||||
|
if (!isMobile || !cachedShiftPressed || actualShiftPressed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!hasTrackedShiftKeyDown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (logicalKey == LogicalKeyboardKey.shiftLeft ||
|
||||||
|
logicalKey == LogicalKeyboardKey.shiftRight) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Applies the terminal Ctrl/Alt one-shot modifiers to a single input payload.
|
||||||
|
///
|
||||||
|
String applyTerminalInputModifiers(
|
||||||
|
String data, {
|
||||||
|
required bool ctrlLocked,
|
||||||
|
required bool altLocked,
|
||||||
|
}) {
|
||||||
|
var result = data;
|
||||||
|
if (ctrlLocked) {
|
||||||
|
result = _applyTerminalCtrlModifier(result);
|
||||||
|
}
|
||||||
|
if (altLocked) {
|
||||||
|
result = '\x1B$result';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds the exact payload xterm sends for paste, without applying modifiers.
|
||||||
|
String terminalPastePayload(String text, {required bool bracketedPasteMode}) {
|
||||||
|
if (!bracketedPasteMode) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
return '\x1B[200~$text\x1B[201~';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether one-shot Ctrl/Alt may transform and consume this input.
|
||||||
|
///
|
||||||
|
/// xterm emits terminal control keys as either one control byte or a longer
|
||||||
|
/// escape sequence. Neither form is ordinary text input, so a pending modifier
|
||||||
|
/// must survive until the user enters a printable character.
|
||||||
|
bool shouldApplyTerminalInputModifiers(String data) {
|
||||||
|
if (data.characters.length != 1) return false;
|
||||||
|
final codeUnit = data.codeUnitAt(0);
|
||||||
|
return codeUnit >= 0x20 && codeUnit != 0x7F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds the payload sent to the remote terminal for keyboard and paste input.
|
||||||
|
///
|
||||||
|
/// Keyboard input keeps the mobile Enter workaround and one-shot Ctrl/Alt
|
||||||
|
/// mapping. Paste input deliberately bypasses both transformations so even a
|
||||||
|
/// one-character clipboard payload is preserved exactly.
|
||||||
|
String prepareTerminalInputPayload(
|
||||||
|
String data, {
|
||||||
|
required TerminalInputSource source,
|
||||||
|
required bool isMobileOrWebMobile,
|
||||||
|
required bool bracketedPasteMode,
|
||||||
|
required bool ctrlLocked,
|
||||||
|
required bool altLocked,
|
||||||
|
}) {
|
||||||
|
if (source == TerminalInputSource.paste) {
|
||||||
|
return terminalPastePayload(
|
||||||
|
data,
|
||||||
|
bracketedPasteMode: bracketedPasteMode,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = data;
|
||||||
|
if (isMobileOrWebMobile && result == '\n') {
|
||||||
|
result = '\r';
|
||||||
|
}
|
||||||
|
if ((ctrlLocked || altLocked) && shouldApplyTerminalInputModifiers(result)) {
|
||||||
|
result = applyTerminalInputModifiers(
|
||||||
|
result,
|
||||||
|
ctrlLocked: ctrlLocked,
|
||||||
|
altLocked: altLocked,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true when a hardware paste shortcut must bypass keyboard modifiers.
|
||||||
|
///
|
||||||
|
/// xterm already handles hardware Ctrl/Cmd+V correctly in the common case. Only
|
||||||
|
/// intercept while a virtual Ctrl/Alt lock is active, because xterm can emit a
|
||||||
|
/// one-character paste as normal text when bracketed paste mode is disabled.
|
||||||
|
bool shouldHandleTerminalPasteShortcut({
|
||||||
|
required LogicalKeyboardKey logicalKey,
|
||||||
|
required bool isKeyDown,
|
||||||
|
required bool isKeyRepeat,
|
||||||
|
required bool controlPressed,
|
||||||
|
required bool metaPressed,
|
||||||
|
required bool altPressed,
|
||||||
|
required bool shiftPressed,
|
||||||
|
required bool modifierLockActive,
|
||||||
|
}) {
|
||||||
|
if (!modifierLockActive) return false;
|
||||||
|
if (!isKeyDown && !isKeyRepeat) return false;
|
||||||
|
if (logicalKey != LogicalKeyboardKey.keyV) return false;
|
||||||
|
if (altPressed || shiftPressed) return false;
|
||||||
|
return controlPressed != metaPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true when collapsing Row3 should also clear hidden modifier state.
|
||||||
|
bool shouldClearTerminalModifiersWhenRow3Collapses({
|
||||||
|
required bool wasExpanded,
|
||||||
|
required bool willExpand,
|
||||||
|
required bool ctrlLocked,
|
||||||
|
required bool altLocked,
|
||||||
|
}) {
|
||||||
|
return wasExpanded && !willExpand && (ctrlLocked || altLocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _applyTerminalCtrlModifier(String data) {
|
||||||
|
// Ctrl mappings are defined only for ASCII scalars. A visible character can
|
||||||
|
// be multiple scalars (for example, a decomposed accent), so leave those
|
||||||
|
// graphemes untouched instead of rewriting only their ASCII base letter.
|
||||||
|
final graphemes = data.characters.toList(growable: false);
|
||||||
|
if (graphemes.length != 1) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
final runes = graphemes.single.runes.toList(growable: false);
|
||||||
|
if (runes.length != 1) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
final code = runes.single;
|
||||||
|
if (code >= 0x61 && code <= 0x7A) {
|
||||||
|
return String.fromCharCode(code - 0x60);
|
||||||
|
}
|
||||||
|
if (code >= 0x41 && code <= 0x5A) {
|
||||||
|
return String.fromCharCode(code - 0x40);
|
||||||
|
}
|
||||||
|
if (code == 0x20) {
|
||||||
|
return String.fromCharCode(0);
|
||||||
|
}
|
||||||
|
if (code == 0x5B) {
|
||||||
|
return String.fromCharCode(27);
|
||||||
|
}
|
||||||
|
if (code == 0x5C) {
|
||||||
|
return String.fromCharCode(28);
|
||||||
|
}
|
||||||
|
if (code == 0x5D) {
|
||||||
|
return String.fromCharCode(29);
|
||||||
|
}
|
||||||
|
if (code == 0x5E) {
|
||||||
|
return String.fromCharCode(30);
|
||||||
|
}
|
||||||
|
if (code == 0x5F || code == 0x2F) {
|
||||||
|
return String.fromCharCode(31);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@@ -55,6 +55,8 @@ import 'package:flutter_hbb/native/custom_cursor.dart'
|
|||||||
typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id);
|
typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id);
|
||||||
typedef ReconnectHandle = Function(OverlayDialogManager, SessionID, bool);
|
typedef ReconnectHandle = Function(OverlayDialogManager, SessionID, bool);
|
||||||
final _constSessionId = Uuid().v4obj();
|
final _constSessionId = Uuid().v4obj();
|
||||||
|
// Empirical restart reconnect cadence: keep the last frame briefly and retry quickly.
|
||||||
|
const _restartReconnectSilentDelaySecs = 5;
|
||||||
|
|
||||||
class CachedPeerData {
|
class CachedPeerData {
|
||||||
Map<String, dynamic> updatePrivacyMode = {};
|
Map<String, dynamic> updatePrivacyMode = {};
|
||||||
@@ -110,6 +112,9 @@ class CachedPeerData {
|
|||||||
class FfiModel with ChangeNotifier {
|
class FfiModel with ChangeNotifier {
|
||||||
CachedPeerData cachedPeerData = CachedPeerData();
|
CachedPeerData cachedPeerData = CachedPeerData();
|
||||||
PeerInfo _pi = PeerInfo();
|
PeerInfo _pi = PeerInfo();
|
||||||
|
int? lastUserDisplay;
|
||||||
|
int? pendingMonitorRestore;
|
||||||
|
Timer? _pendingRestoreTimer;
|
||||||
Rect? _rect;
|
Rect? _rect;
|
||||||
|
|
||||||
var _inputBlocked = false;
|
var _inputBlocked = false;
|
||||||
@@ -119,7 +124,9 @@ class FfiModel with ChangeNotifier {
|
|||||||
bool _touchMode = false;
|
bool _touchMode = false;
|
||||||
late VirtualMouseMode virtualMouseMode;
|
late VirtualMouseMode virtualMouseMode;
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
|
Timer? _restartReconnectDelayTimer;
|
||||||
var _reconnects = 1;
|
var _reconnects = 1;
|
||||||
|
DateTime? _offlineReconnectStartTime;
|
||||||
bool _viewOnly = false;
|
bool _viewOnly = false;
|
||||||
bool _showMyCursor = false;
|
bool _showMyCursor = false;
|
||||||
WeakReference<FFI> parent;
|
WeakReference<FFI> parent;
|
||||||
@@ -244,11 +251,14 @@ class FfiModel with ChangeNotifier {
|
|||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
_pi = PeerInfo();
|
_pi = PeerInfo();
|
||||||
|
lastUserDisplay = null;
|
||||||
|
_cancelPendingMonitorRestore();
|
||||||
_secure = null;
|
_secure = null;
|
||||||
_direct = null;
|
_direct = null;
|
||||||
_inputBlocked = false;
|
_inputBlocked = false;
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = null;
|
_timer = null;
|
||||||
|
resetRestartReconnectState();
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
waitForImageTimer?.cancel();
|
waitForImageTimer?.cancel();
|
||||||
timerScreenshot?.cancel();
|
timerScreenshot?.cancel();
|
||||||
@@ -340,6 +350,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == 'connection_ready') {
|
} else if (name == 'connection_ready') {
|
||||||
setConnectionType(peerId, evt['secure'] == 'true',
|
setConnectionType(peerId, evt['secure'] == 'true',
|
||||||
evt['direct'] == 'true', evt['stream_type'] ?? '');
|
evt['direct'] == 'true', evt['stream_type'] ?? '');
|
||||||
|
resetRestartReconnectState();
|
||||||
} else if (name == 'switch_display') {
|
} else if (name == 'switch_display') {
|
||||||
// switch display is kept for backward compatibility
|
// switch display is kept for backward compatibility
|
||||||
handleSwitchDisplay(evt, sessionId, peerId);
|
handleSwitchDisplay(evt, sessionId, peerId);
|
||||||
@@ -724,6 +735,11 @@ class FfiModel with ChangeNotifier {
|
|||||||
_handleUseTextureRender(
|
_handleUseTextureRender(
|
||||||
Map<String, dynamic> evt, SessionID sessionId, String peerId) {
|
Map<String, dynamic> evt, SessionID sessionId, String peerId) {
|
||||||
parent.target?.imageModel.setUseTextureRender(evt['v'] == 'Y');
|
parent.target?.imageModel.setUseTextureRender(evt['v'] == 'Y');
|
||||||
|
if (evt['reason'] == 'fallback') {
|
||||||
|
// The Rust watchdog detected that pushed frames were never rendered
|
||||||
|
// and switched this session to software rendering.
|
||||||
|
showToast(translate('texture-render-fallback-tip'));
|
||||||
|
}
|
||||||
waitForFirstImage.value = true;
|
waitForFirstImage.value = true;
|
||||||
isRefreshing = true;
|
isRefreshing = true;
|
||||||
showConnectedWaitingForImage(parent.target!.dialogManager, sessionId,
|
showConnectedWaitingForImage(parent.target!.dialogManager, sessionId,
|
||||||
@@ -783,7 +799,8 @@ class FfiModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateCurDisplay(SessionID sessionId, {updateCursorPos = false}) async {
|
Future<void> updateCurDisplay(SessionID sessionId,
|
||||||
|
{updateCursorPos = false}) async {
|
||||||
final newRect = displaysRect();
|
final newRect = displaysRect();
|
||||||
if (newRect == null) {
|
if (newRect == null) {
|
||||||
return;
|
return;
|
||||||
@@ -920,8 +937,29 @@ class FfiModel with ChangeNotifier {
|
|||||||
enterUserLoginAndPasswordDialog(
|
enterUserLoginAndPasswordDialog(
|
||||||
sessionId, dialogManager, 'terminal-admin-login-tip', false);
|
sessionId, dialogManager, 'terminal-admin-login-tip', false);
|
||||||
} else if (type == 'restarting') {
|
} else if (type == 'restarting') {
|
||||||
showMsgBox(sessionId, type, title, text, link, false, dialogManager,
|
// Treat restart messages as reconnect control events. Rust still sends
|
||||||
hasCancel: false);
|
// title/text for legacy UI and translation reuse; Flutter keeps the last
|
||||||
|
// frame briefly, then shows the Connecting overlay.
|
||||||
|
if (_restartReconnectDelayTimer == null) {
|
||||||
|
parent.target?.inputModel.setRelativeMouseMode(false);
|
||||||
|
_cancelPendingMonitorRestore();
|
||||||
|
bind.sessionReconnect(sessionId: sessionId, forceRelay: false);
|
||||||
|
clearPermissions();
|
||||||
|
// Retry once more after the silent window so restart reconnect attempts
|
||||||
|
// are spaced by the empirical short cadence instead of only updating UI.
|
||||||
|
_restartReconnectDelayTimer =
|
||||||
|
Timer(Duration(seconds: _restartReconnectSilentDelaySecs), () {
|
||||||
|
_restartReconnectDelayTimer = null;
|
||||||
|
if (parent.target?.closed == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reconnect(dialogManager, sessionId, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (type == 'restarting-show') {
|
||||||
|
_restartReconnectDelayTimer?.cancel();
|
||||||
|
_restartReconnectDelayTimer = null;
|
||||||
|
reconnect(dialogManager, sessionId, false);
|
||||||
} else if (type == 'wait-remote-accept-nook') {
|
} else if (type == 'wait-remote-accept-nook') {
|
||||||
showWaitAcceptDialog(sessionId, type, title, text, dialogManager);
|
showWaitAcceptDialog(sessionId, type, title, text, dialogManager);
|
||||||
} else if (type == 'on-uac' || type == 'on-foreground-elevated') {
|
} else if (type == 'on-uac' || type == 'on-foreground-elevated') {
|
||||||
@@ -939,11 +977,51 @@ class FfiModel with ChangeNotifier {
|
|||||||
showPrivacyFailedDialog(
|
showPrivacyFailedDialog(
|
||||||
sessionId, type, title, text, link, hasRetry, dialogManager);
|
sessionId, type, title, text, link, hasRetry, dialogManager);
|
||||||
} else {
|
} else {
|
||||||
final hasRetry = evt['hasRetry'] == 'true';
|
var hasRetry = evt['hasRetry'] == 'true';
|
||||||
|
if (!hasRetry) {
|
||||||
|
hasRetry = shouldAutoRetryOnOffline(type, title, text);
|
||||||
|
}
|
||||||
showMsgBox(sessionId, type, title, text, link, hasRetry, dialogManager);
|
showMsgBox(sessionId, type, title, text, link, hasRetry, dialogManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resetRestartReconnectState() {
|
||||||
|
_restartReconnectDelayTimer?.cancel();
|
||||||
|
_restartReconnectDelayTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Auto-retry check for "Remote desktop is offline" error.
|
||||||
|
/// returns true to auto-retry, false otherwise.
|
||||||
|
bool shouldAutoRetryOnOffline(
|
||||||
|
String type,
|
||||||
|
String title,
|
||||||
|
String text,
|
||||||
|
) {
|
||||||
|
if (type == 'error' &&
|
||||||
|
title == 'Connection Error' &&
|
||||||
|
text == 'Remote desktop is offline' &&
|
||||||
|
_pi.isSet.isTrue) {
|
||||||
|
// Auto retry for ~30s (server's peer offline threshold) when controlled peer's account changes
|
||||||
|
// (e.g., signout, switch user, login into OS) causes temporary offline via websocket/tcp connection.
|
||||||
|
// The actual wait may exceed 30s (e.g., 20s elapsed + 16s next retry = 36s), which is acceptable
|
||||||
|
// since the controlled side reconnects quickly after account changes.
|
||||||
|
// Uses time-based check instead of _reconnects count because user can manually retry.
|
||||||
|
// https://github.com/rustdesk/rustdesk/discussions/14048
|
||||||
|
if (_offlineReconnectStartTime == null) {
|
||||||
|
// First offline, record time and start retry
|
||||||
|
_offlineReconnectStartTime = DateTime.now();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
final elapsed =
|
||||||
|
DateTime.now().difference(_offlineReconnectStartTime!).inSeconds;
|
||||||
|
if (elapsed < 30) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
handleToast(Map<String, dynamic> evt, SessionID sessionId, String peerId) {
|
handleToast(Map<String, dynamic> evt, SessionID sessionId, String peerId) {
|
||||||
final type = evt['type'] ?? 'info';
|
final type = evt['type'] ?? 'info';
|
||||||
final text = evt['text'] ?? '';
|
final text = evt['text'] ?? '';
|
||||||
@@ -979,19 +1057,31 @@ class FfiModel with ChangeNotifier {
|
|||||||
showMsgBox(SessionID sessionId, String type, String title, String text,
|
showMsgBox(SessionID sessionId, String type, String title, String text,
|
||||||
String link, bool hasRetry, OverlayDialogManager dialogManager,
|
String link, bool hasRetry, OverlayDialogManager dialogManager,
|
||||||
{bool? hasCancel}) async {
|
{bool? hasCancel}) async {
|
||||||
final showNoteEdit = parent.target != null &&
|
final noteAllowed = parent.target != null &&
|
||||||
allowAskForNoteAtEndOfConnection(parent.target, false) &&
|
allowAskForNoteAtEndOfConnection(parent.target, false) &&
|
||||||
(title == "Connection Error" || type == "restarting") &&
|
(title == "Connection Error" || type == "restarting");
|
||||||
!hasRetry;
|
final showNoteEdit = noteAllowed && !hasRetry;
|
||||||
if (showNoteEdit) {
|
if (showNoteEdit) {
|
||||||
await showConnEndAuditDialogCloseCanceled(
|
await showConnEndAuditDialogCloseCanceled(
|
||||||
ffi: parent.target!, type: type, title: title, text: text);
|
ffi: parent.target!, type: type, title: title, text: text);
|
||||||
closeConnection();
|
closeConnection();
|
||||||
} else {
|
} else {
|
||||||
|
VoidCallback? onSubmit;
|
||||||
|
if (noteAllowed && hasRetry) {
|
||||||
|
final ffi = parent.target!;
|
||||||
|
onSubmit = () async {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = null;
|
||||||
|
await showConnEndAuditDialogCloseCanceled(
|
||||||
|
ffi: ffi, type: type, title: title, text: text);
|
||||||
|
closeConnection();
|
||||||
|
};
|
||||||
|
}
|
||||||
msgBox(sessionId, type, title, text, link, dialogManager,
|
msgBox(sessionId, type, title, text, link, dialogManager,
|
||||||
hasCancel: hasCancel,
|
hasCancel: hasCancel,
|
||||||
reconnect: hasRetry ? reconnect : null,
|
reconnect: hasRetry ? reconnect : null,
|
||||||
reconnectTimeout: hasRetry ? _reconnects : null);
|
reconnectTimeout: hasRetry ? _reconnects : null,
|
||||||
|
onSubmit: onSubmit);
|
||||||
}
|
}
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
if (hasRetry) {
|
if (hasRetry) {
|
||||||
@@ -1001,13 +1091,26 @@ class FfiModel with ChangeNotifier {
|
|||||||
_reconnects *= 2;
|
_reconnects *= 2;
|
||||||
} else {
|
} else {
|
||||||
_reconnects = 1;
|
_reconnects = 1;
|
||||||
|
_offlineReconnectStartTime = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _cancelPendingMonitorRestore() {
|
||||||
|
_pendingRestoreTimer?.cancel();
|
||||||
|
_pendingRestoreTimer = null;
|
||||||
|
pendingMonitorRestore = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancelPendingRestoreTimer() {
|
||||||
|
_pendingRestoreTimer?.cancel();
|
||||||
|
_pendingRestoreTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
void reconnect(OverlayDialogManager dialogManager, SessionID sessionId,
|
void reconnect(OverlayDialogManager dialogManager, SessionID sessionId,
|
||||||
bool forceRelay) {
|
bool forceRelay) {
|
||||||
// Disable relative mouse mode before reconnecting to ensure cursor is released.
|
// Disable relative mouse mode before reconnecting to ensure cursor is released.
|
||||||
parent.target?.inputModel.setRelativeMouseMode(false);
|
parent.target?.inputModel.setRelativeMouseMode(false);
|
||||||
|
_cancelPendingMonitorRestore();
|
||||||
bind.sessionReconnect(sessionId: sessionId, forceRelay: forceRelay);
|
bind.sessionReconnect(sessionId: sessionId, forceRelay: forceRelay);
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
@@ -1321,8 +1424,29 @@ class FfiModel with ChangeNotifier {
|
|||||||
// now replaced to _updateCurDisplay
|
// now replaced to _updateCurDisplay
|
||||||
updateCurDisplay(sessionId);
|
updateCurDisplay(sessionId);
|
||||||
}
|
}
|
||||||
|
// After reconnecting, restore the last selected monitor once the canvas is ready.
|
||||||
|
// Switching earlier can offset the view if the monitor sizes differ.
|
||||||
|
final last = lastUserDisplay;
|
||||||
|
pendingMonitorRestore = (!isCache &&
|
||||||
|
last != null &&
|
||||||
|
last != currentDisplay &&
|
||||||
|
bind.sessionGetUseAllMyDisplaysForTheRemoteSession(
|
||||||
|
sessionId: sessionId) !=
|
||||||
|
'Y' &&
|
||||||
|
((last == kAllDisplayValue && _pi.displays.isNotEmpty) ||
|
||||||
|
(last >= 0 && last < _pi.displays.length)))
|
||||||
|
? last
|
||||||
|
: null;
|
||||||
|
// Fallback if the first image event never reaches this tab (multi-UI).
|
||||||
|
_pendingRestoreTimer?.cancel();
|
||||||
|
if (pendingMonitorRestore != null) {
|
||||||
|
_pendingRestoreTimer = Timer(const Duration(milliseconds: 1500),
|
||||||
|
() => parent.target?._applyPendingMonitorRestore());
|
||||||
|
}
|
||||||
if (displays.isNotEmpty) {
|
if (displays.isNotEmpty) {
|
||||||
_reconnects = 1;
|
_reconnects = 1;
|
||||||
|
_offlineReconnectStartTime = null;
|
||||||
|
resetRestartReconnectState();
|
||||||
waitForFirstImage.value = true;
|
waitForFirstImage.value = true;
|
||||||
isRefreshing = false;
|
isRefreshing = false;
|
||||||
}
|
}
|
||||||
@@ -1833,6 +1957,12 @@ class ImageModel with ChangeNotifier {
|
|||||||
platformFFI.nextRgba(sessionId, display);
|
platformFFI.nextRgba(sessionId, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// web only: image already created from a decoded WebCodecs frame
|
||||||
|
Future<void> onImage(
|
||||||
|
int display, ui.Image image, bool Function() isCurrentSession) async {
|
||||||
|
await update(image, isCurrentSession: isCurrentSession);
|
||||||
|
}
|
||||||
|
|
||||||
decodeAndUpdate(int display, Uint8List rgba) async {
|
decodeAndUpdate(int display, Uint8List rgba) async {
|
||||||
final pid = parent.target?.id;
|
final pid = parent.target?.id;
|
||||||
final rect = parent.target?.ffiModel.pi.getDisplayRect(display);
|
final rect = parent.target?.ffiModel.pi.getDisplayRect(display);
|
||||||
@@ -1844,11 +1974,16 @@ class ImageModel with ChangeNotifier {
|
|||||||
? ui.PixelFormat.rgba8888
|
? ui.PixelFormat.rgba8888
|
||||||
: ui.PixelFormat.bgra8888,
|
: ui.PixelFormat.bgra8888,
|
||||||
);
|
);
|
||||||
if (parent.target?.id != pid) return;
|
if (parent.target?.id != pid) {
|
||||||
|
image?.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
await update(image);
|
await update(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(ui.Image? image) async {
|
Future<void> update(ui.Image? image,
|
||||||
|
{bool Function()? isCurrentSession}) async {
|
||||||
|
if (_disposeIfStale(image, isCurrentSession)) return;
|
||||||
if (_image == null && image != null) {
|
if (_image == null && image != null) {
|
||||||
if (isDesktop || isWebDesktop) {
|
if (isDesktop || isWebDesktop) {
|
||||||
await parent.target?.canvasModel.updateViewStyle();
|
await parent.target?.canvasModel.updateViewStyle();
|
||||||
@@ -1859,11 +1994,19 @@ class ImageModel with ChangeNotifier {
|
|||||||
await initializeCursorAndCanvas(parent.target!);
|
await initializeCursorAndCanvas(parent.target!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_disposeIfStale(image, isCurrentSession)) return;
|
||||||
_image?.dispose();
|
_image?.dispose();
|
||||||
_image = image;
|
_image = image;
|
||||||
if (image != null) notifyListeners();
|
if (image != null) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _disposeIfStale(ui.Image? image, bool Function()? isCurrentSession) {
|
||||||
|
if (image == null || isCurrentSession == null) return false;
|
||||||
|
if (isCurrentSession()) return false;
|
||||||
|
image.dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// mobile only
|
// mobile only
|
||||||
double get maxScale {
|
double get maxScale {
|
||||||
if (_image == null) return 1.5;
|
if (_image == null) return 1.5;
|
||||||
@@ -2113,6 +2256,9 @@ class CanvasModel with ChangeNotifier {
|
|||||||
ViewStyle _lastViewStyle = ViewStyle.defaultViewStyle();
|
ViewStyle _lastViewStyle = ViewStyle.defaultViewStyle();
|
||||||
|
|
||||||
Timer? _timerMobileFocusCanvasCursor;
|
Timer? _timerMobileFocusCanvasCursor;
|
||||||
|
Timer? _timerMobileRestoreCanvasOffset;
|
||||||
|
Offset? _offsetBeforeMobileSoftKeyboard;
|
||||||
|
double? _scaleBeforeMobileSoftKeyboard;
|
||||||
|
|
||||||
// `isMobileCanvasChanged` is used to avoid canvas reset when changing the input method
|
// `isMobileCanvasChanged` is used to avoid canvas reset when changing the input method
|
||||||
// after showing the soft keyboard.
|
// after showing the soft keyboard.
|
||||||
@@ -2176,10 +2322,32 @@ class CanvasModel with ChangeNotifier {
|
|||||||
double w = size.width - leftToEdge - rightToEdge;
|
double w = size.width - leftToEdge - rightToEdge;
|
||||||
double h = size.height - topToEdge - bottomToEdge;
|
double h = size.height - topToEdge - bottomToEdge;
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
|
// Account for horizontal safe area insets on both orientations.
|
||||||
|
w = w - mediaData.padding.left - mediaData.padding.right;
|
||||||
|
// Vertically, subtract the bottom keyboard inset (viewInsets.bottom) and any
|
||||||
|
// bottom overlay (e.g. key-help tools) so the canvas is not covered.
|
||||||
h = h -
|
h = h -
|
||||||
mediaData.viewInsets.bottom -
|
mediaData.viewInsets.bottom -
|
||||||
(parent.target?.cursorModel.keyHelpToolsRectToAdjustCanvas?.bottom ??
|
(parent.target?.cursorModel.keyHelpToolsRectToAdjustCanvas?.bottom ??
|
||||||
0);
|
0);
|
||||||
|
// Orientation-specific handling:
|
||||||
|
// - Portrait: additionally subtract top padding (e.g. status bar / notch)
|
||||||
|
// - Landscape: does not subtract mediaData.padding.top/bottom (home indicator auto-hides)
|
||||||
|
final isPortrait = size.height > size.width;
|
||||||
|
if (isPortrait) {
|
||||||
|
// In portrait mode, subtract the top safe-area padding (e.g. status bar / notch)
|
||||||
|
// so the remote image is not truncated, while keeping the bottom inset to avoid
|
||||||
|
// introducing unnecessary blank space around the canvas.
|
||||||
|
//
|
||||||
|
// iOS -> Android, portrait, adjust mode:
|
||||||
|
// h = h (no padding subtracted): top and bottom are truncated
|
||||||
|
// https://github.com/user-attachments/assets/30ed4559-c27e-432b-847f-8fec23c9f998
|
||||||
|
// h = h - top - bottom: extra blank spaces appear
|
||||||
|
// https://github.com/user-attachments/assets/12a98817-3b4e-43aa-be0f-4b03cf364b7e
|
||||||
|
// h = h - top (current): works fine
|
||||||
|
// https://github.com/user-attachments/assets/95f047f2-7f47-4a36-8113-5023989a0c81
|
||||||
|
h = h - mediaData.padding.top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Size(w < 0 ? 0 : w, h < 0 ? 0 : h);
|
return Size(w < 0 ? 0 : w, h < 0 ? 0 : h);
|
||||||
}
|
}
|
||||||
@@ -2578,6 +2746,9 @@ class CanvasModel with ChangeNotifier {
|
|||||||
_scale = 1.0;
|
_scale = 1.0;
|
||||||
_lastViewStyle = ViewStyle.defaultViewStyle();
|
_lastViewStyle = ViewStyle.defaultViewStyle();
|
||||||
_timerMobileFocusCanvasCursor?.cancel();
|
_timerMobileFocusCanvasCursor?.cancel();
|
||||||
|
_timerMobileRestoreCanvasOffset?.cancel();
|
||||||
|
_offsetBeforeMobileSoftKeyboard = null;
|
||||||
|
_scaleBeforeMobileSoftKeyboard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScrollPercent() {
|
updateScrollPercent() {
|
||||||
@@ -2606,6 +2777,31 @@ class CanvasModel with ChangeNotifier {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveMobileOffsetBeforeSoftKeyboard() {
|
||||||
|
_timerMobileRestoreCanvasOffset?.cancel();
|
||||||
|
_offsetBeforeMobileSoftKeyboard = Offset(_x, _y);
|
||||||
|
_scaleBeforeMobileSoftKeyboard = _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void restoreMobileOffsetAfterSoftKeyboard() {
|
||||||
|
_timerMobileRestoreCanvasOffset?.cancel();
|
||||||
|
_timerMobileFocusCanvasCursor?.cancel();
|
||||||
|
final targetOffset = _offsetBeforeMobileSoftKeyboard;
|
||||||
|
final targetScale = _scaleBeforeMobileSoftKeyboard;
|
||||||
|
if (targetOffset == null || targetScale == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_timerMobileRestoreCanvasOffset = Timer(Duration(milliseconds: 100), () {
|
||||||
|
updateSize();
|
||||||
|
_x = targetOffset.dx;
|
||||||
|
_y = targetOffset.dy;
|
||||||
|
_scale = targetScale;
|
||||||
|
_offsetBeforeMobileSoftKeyboard = null;
|
||||||
|
_scaleBeforeMobileSoftKeyboard = null;
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// mobile only
|
// mobile only
|
||||||
// Move the canvas to make the cursor visible(center) on the screen.
|
// Move the canvas to make the cursor visible(center) on the screen.
|
||||||
void _moveToCenterCursor() {
|
void _moveToCenterCursor() {
|
||||||
@@ -2858,8 +3054,13 @@ class CursorModel with ChangeNotifier {
|
|||||||
_lastIsBlocked = true;
|
_lastIsBlocked = true;
|
||||||
}
|
}
|
||||||
if (isMobile && _lastKeyboardIsVisible != keyboardIsVisible) {
|
if (isMobile && _lastKeyboardIsVisible != keyboardIsVisible) {
|
||||||
parent.target?.canvasModel.mobileFocusCanvasCursor();
|
if (keyboardIsVisible) {
|
||||||
parent.target?.canvasModel.isMobileCanvasChanged = false;
|
parent.target?.canvasModel.saveMobileOffsetBeforeSoftKeyboard();
|
||||||
|
parent.target?.canvasModel.mobileFocusCanvasCursor();
|
||||||
|
parent.target?.canvasModel.isMobileCanvasChanged = false;
|
||||||
|
} else {
|
||||||
|
parent.target?.canvasModel.restoreMobileOffsetAfterSoftKeyboard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_lastKeyboardIsVisible = keyboardIsVisible;
|
_lastKeyboardIsVisible = keyboardIsVisible;
|
||||||
}
|
}
|
||||||
@@ -3557,6 +3758,7 @@ class FFI {
|
|||||||
|
|
||||||
/// Mobile reuse FFI
|
/// Mobile reuse FFI
|
||||||
void mobileReset() {
|
void mobileReset() {
|
||||||
|
ffiModel.resetRestartReconnectState();
|
||||||
ffiModel.waitForFirstImage.value = true;
|
ffiModel.waitForFirstImage.value = true;
|
||||||
ffiModel.isRefreshing = false;
|
ffiModel.isRefreshing = false;
|
||||||
ffiModel.waitForImageDialogShow.value = true;
|
ffiModel.waitForImageDialogShow.value = true;
|
||||||
@@ -3675,6 +3877,15 @@ class FFI {
|
|||||||
onEvent2UIRgba();
|
onEvent2UIRgba();
|
||||||
imageModel.onRgba(display, data);
|
imageModel.onRgba(display, data);
|
||||||
});
|
});
|
||||||
|
platformFFI.setVideoFrameCallback((int display, ui.Image image,
|
||||||
|
bool Function() isCurrentSession) async {
|
||||||
|
if (!isCurrentSession()) {
|
||||||
|
image.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await onEvent2UIRgba();
|
||||||
|
await imageModel.onImage(display, image, isCurrentSession);
|
||||||
|
});
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3762,7 +3973,7 @@ class FFI {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onEvent2UIRgba() async {
|
Future<void> onEvent2UIRgba() async {
|
||||||
if (ffiModel.waitForImageDialogShow.isTrue) {
|
if (ffiModel.waitForImageDialogShow.isTrue) {
|
||||||
ffiModel.waitForImageDialogShow.value = false;
|
ffiModel.waitForImageDialogShow.value = false;
|
||||||
ffiModel.waitForImageTimer?.cancel();
|
ffiModel.waitForImageTimer?.cancel();
|
||||||
@@ -3770,16 +3981,35 @@ class FFI {
|
|||||||
}
|
}
|
||||||
if (ffiModel.waitForFirstImage.value == true) {
|
if (ffiModel.waitForFirstImage.value == true) {
|
||||||
ffiModel.waitForFirstImage.value = false;
|
ffiModel.waitForFirstImage.value = false;
|
||||||
|
ffiModel.cancelPendingRestoreTimer();
|
||||||
|
ffiModel.resetRestartReconnectState();
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
await canvasModel.updateViewStyle();
|
try {
|
||||||
await canvasModel.updateScrollStyle();
|
await canvasModel.updateViewStyle();
|
||||||
await canvasModel.initializeEdgeScrollEdgeThickness();
|
await canvasModel.updateScrollStyle();
|
||||||
for (final cb in imageModel.callbacksOnFirstImage) {
|
await canvasModel.initializeEdgeScrollEdgeThickness();
|
||||||
cb(id);
|
for (final cb in imageModel.callbacksOnFirstImage) {
|
||||||
|
cb(id);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
_applyPendingMonitorRestore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _applyPendingMonitorRestore() {
|
||||||
|
final restore = ffiModel.pendingMonitorRestore;
|
||||||
|
ffiModel._cancelPendingMonitorRestore();
|
||||||
|
if (restore == null || closed) return;
|
||||||
|
// The display list may have changed since the restore was queued.
|
||||||
|
final displays = ffiModel.pi.displays;
|
||||||
|
if ((restore == kAllDisplayValue && displays.isNotEmpty) ||
|
||||||
|
(restore >= 0 && restore < displays.length)) {
|
||||||
|
openMonitorInTheSameTab(restore, this, ffiModel.pi,
|
||||||
|
recordSelection: false, updateCursorPos: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Login with [password], choose if the client should [remember] it.
|
/// Login with [password], choose if the client should [remember] it.
|
||||||
void login(String osUsername, String osPassword, SessionID sessionId,
|
void login(String osUsername, String osPassword, SessionID sessionId,
|
||||||
String password, bool remember) {
|
String password, bool remember) {
|
||||||
@@ -3799,6 +4029,9 @@ class FFI {
|
|||||||
/// Close the remote session.
|
/// Close the remote session.
|
||||||
Future<void> close({bool closeSession = true}) async {
|
Future<void> close({bool closeSession = true}) async {
|
||||||
closed = true;
|
closed = true;
|
||||||
|
if (isWeb) {
|
||||||
|
platformFFI.clearVideoFrameCallback();
|
||||||
|
}
|
||||||
chatModel.close();
|
chatModel.close();
|
||||||
// Close all terminal models
|
// Close all terminal models
|
||||||
for (final model in _terminalModels.values) {
|
for (final model in _terminalModels.values) {
|
||||||
@@ -3823,6 +4056,7 @@ class FFI {
|
|||||||
inputModel.resetModifiers();
|
inputModel.resetModifiers();
|
||||||
// Dispose relative mouse mode resources to ensure cursor is restored
|
// Dispose relative mouse mode resources to ensure cursor is restored
|
||||||
inputModel.disposeRelativeMouseMode();
|
inputModel.disposeRelativeMouseMode();
|
||||||
|
inputModel.disposeSideButtonTracking();
|
||||||
if (closeSession) {
|
if (closeSession) {
|
||||||
await bind.sessionClose(sessionId: sessionId);
|
await bind.sessionClose(sessionId: sessionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:external_path/external_path.dart';
|
import 'package:external_path/external_path.dart';
|
||||||
@@ -25,6 +26,23 @@ typedef F3 = Pointer<Uint8> Function(Pointer<Utf8>, int);
|
|||||||
typedef F3Dart = Pointer<Uint8> Function(Pointer<Utf8>, Int32);
|
typedef F3Dart = Pointer<Uint8> Function(Pointer<Utf8>, Int32);
|
||||||
typedef HandleEvent = Future<void> Function(Map<String, dynamic> evt);
|
typedef HandleEvent = Future<void> Function(Map<String, dynamic> evt);
|
||||||
|
|
||||||
|
/// The Linux bundle keeps the core library at lib/librustdesk.so next to the
|
||||||
|
/// executable. Prefer that copy, mirroring flutter/linux/main.cc: the plain
|
||||||
|
/// name relies on the loader search path, which repackaged installs may not
|
||||||
|
/// cover. https://github.com/rustdesk/rustdesk/discussions/14407
|
||||||
|
DynamicLibrary _openLinuxCoreLib() {
|
||||||
|
final bundled =
|
||||||
|
'${File(Platform.resolvedExecutable).parent.path}/lib/librustdesk.so';
|
||||||
|
try {
|
||||||
|
if (File(bundled).existsSync()) {
|
||||||
|
return DynamicLibrary.open(bundled);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint("Failed to load '$bundled': $e");
|
||||||
|
}
|
||||||
|
return DynamicLibrary.open('librustdesk.so');
|
||||||
|
}
|
||||||
|
|
||||||
/// FFI wrapper around the native Rust core.
|
/// FFI wrapper around the native Rust core.
|
||||||
/// Hides the platform differences.
|
/// Hides the platform differences.
|
||||||
class PlatformFFI {
|
class PlatformFFI {
|
||||||
@@ -113,6 +131,12 @@ class PlatformFFI {
|
|||||||
void registerGpuTexture(SessionID sessionId, int display, int ptr) =>
|
void registerGpuTexture(SessionID sessionId, int display, int ptr) =>
|
||||||
_ffiBind.sessionRegisterGpuTexture(
|
_ffiBind.sessionRegisterGpuTexture(
|
||||||
sessionId: sessionId, display: display, ptr: ptr);
|
sessionId: sessionId, display: display, ptr: ptr);
|
||||||
|
void unregisterPixelbufferTexture(SessionID sessionId, int display, int ptr) =>
|
||||||
|
_ffiBind.sessionUnregisterPixelbufferTexture(
|
||||||
|
sessionId: sessionId, display: display, ptr: ptr);
|
||||||
|
void unregisterGpuTexture(SessionID sessionId, int display, int ptr) =>
|
||||||
|
_ffiBind.sessionUnregisterGpuTexture(
|
||||||
|
sessionId: sessionId, display: display, ptr: ptr);
|
||||||
|
|
||||||
/// Init the FFI class, loads the native Rust core library.
|
/// Init the FFI class, loads the native Rust core library.
|
||||||
Future<void> init(String appType) async {
|
Future<void> init(String appType) async {
|
||||||
@@ -120,7 +144,7 @@ class PlatformFFI {
|
|||||||
final dylib = isAndroid
|
final dylib = isAndroid
|
||||||
? DynamicLibrary.open('librustdesk.so')
|
? DynamicLibrary.open('librustdesk.so')
|
||||||
: isLinux
|
: isLinux
|
||||||
? DynamicLibrary.open('librustdesk.so')
|
? _openLinuxCoreLib()
|
||||||
: isWindows
|
: isWindows
|
||||||
? DynamicLibrary.open('librustdesk.dll')
|
? DynamicLibrary.open('librustdesk.dll')
|
||||||
:
|
:
|
||||||
@@ -266,6 +290,12 @@ class PlatformFFI {
|
|||||||
|
|
||||||
void setRgbaCallback(void Function(int, Uint8List) fun) async {}
|
void setRgbaCallback(void Function(int, Uint8List) fun) async {}
|
||||||
|
|
||||||
|
// web only, decoded WebCodecs frames arriving as ready-made images
|
||||||
|
void setVideoFrameCallback(
|
||||||
|
Future<void> Function(int, ui.Image, bool Function()) fun) {}
|
||||||
|
|
||||||
|
void clearVideoFrameCallback() {}
|
||||||
|
|
||||||
void startDesktopWebListener() {}
|
void startDesktopWebListener() {}
|
||||||
|
|
||||||
void stopDesktopWebListener() {}
|
void stopDesktopWebListener() {}
|
||||||
|
|||||||
@@ -145,23 +145,26 @@ class Peer {
|
|||||||
note == other.note;
|
note == other.note;
|
||||||
}
|
}
|
||||||
|
|
||||||
Peer.copy(Peer other)
|
factory Peer.copy(Peer other) {
|
||||||
: this(
|
final peer = Peer(
|
||||||
id: other.id,
|
id: other.id,
|
||||||
hash: other.hash,
|
hash: other.hash,
|
||||||
password: other.password,
|
password: other.password,
|
||||||
username: other.username,
|
username: other.username,
|
||||||
hostname: other.hostname,
|
hostname: other.hostname,
|
||||||
platform: other.platform,
|
platform: other.platform,
|
||||||
alias: other.alias,
|
alias: other.alias,
|
||||||
tags: other.tags.toList(),
|
tags: other.tags.toList(),
|
||||||
forceAlwaysRelay: other.forceAlwaysRelay,
|
forceAlwaysRelay: other.forceAlwaysRelay,
|
||||||
rdpPort: other.rdpPort,
|
rdpPort: other.rdpPort,
|
||||||
rdpUsername: other.rdpUsername,
|
rdpUsername: other.rdpUsername,
|
||||||
loginName: other.loginName,
|
loginName: other.loginName,
|
||||||
device_group_name: other.device_group_name,
|
device_group_name: other.device_group_name,
|
||||||
note: other.note,
|
note: other.note,
|
||||||
sameServer: other.sameServer);
|
sameServer: other.sameServer);
|
||||||
|
peer.online = other.online;
|
||||||
|
return peer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UpdateEvent { online, load }
|
enum UpdateEvent { online, load }
|
||||||
|
|||||||
14
flutter/lib/models/rustdesk_terminal.dart
Normal file
14
flutter/lib/models/rustdesk_terminal.dart
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import 'package:xterm/xterm.dart';
|
||||||
|
|
||||||
|
class RustDeskTerminal extends Terminal {
|
||||||
|
RustDeskTerminal({super.maxLines});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void eraseScrollbackOnly() {
|
||||||
|
final scrollBack = buffer.scrollBack;
|
||||||
|
if (scrollBack == 0) return;
|
||||||
|
|
||||||
|
// Selection anchors require retained buffer lines to be reindexed.
|
||||||
|
buffer.lines.remove(0, scrollBack);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user