Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rustdesk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李朝发
rustdesk
Commits
9b694cba
Commit
9b694cba
authored
Sep 07, 2022
by
fufesou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flutter_desktop: cursor cache - linux
Signed-off-by:
fufesou
<
shuanglongchen@yeah.net
>
parent
93236bb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
21 deletions
+80
-21
remote_page.dart
flutter/lib/desktop/pages/remote_page.dart
+9
-6
model.dart
flutter/lib/models/model.dart
+70
-14
pubspec.yaml
flutter/pubspec.yaml
+1
-1
No files found.
flutter/lib/desktop/pages/remote_page.dart
View file @
9b694cba
...
...
@@ -568,13 +568,16 @@ class ImagePaint extends StatelessWidget {
cursor:
(
cursorOverImage
.
isTrue
&&
keyboardEnabled
.
isTrue
)
?
(
remoteCursorMoved
.
isTrue
?
SystemMouseCursors
.
none
:
(
cursor
.
pngData
!=
null
:
(
cursor
.
cacheLinux
!=
null
?
FlutterCustomMemoryImageCursor
(
pixbuf:
cursor
.
pngData
!,
hotx:
cursor
.
hotx
,
hoty:
cursor
.
hoty
,
imageWidth:
(
cursor
.
image
!.
width
*
s
).
toInt
(),
imageHeight:
(
cursor
.
image
!.
height
*
s
).
toInt
(),
pixbuf:
cursor
.
cacheLinux
!.
data
,
key:
cursor
.
cacheLinux
!.
key
,
hotx:
cursor
.
cacheLinux
!.
hotx
,
hoty:
cursor
.
cacheLinux
!.
hoty
,
imageWidth:
(
cursor
.
cacheLinux
!.
width
*
s
).
toInt
(),
imageHeight:
(
cursor
.
cacheLinux
!.
height
*
s
).
toInt
(),
)
:
MouseCursor
.
defer
))
:
MouseCursor
.
defer
,
...
...
flutter/lib/models/model.dart
View file @
9b694cba
...
...
@@ -17,6 +17,7 @@ import 'package:flutter_hbb/models/server_model.dart';
import
'package:flutter_hbb/models/user_model.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:tuple/tuple.dart'
;
import
'package:flutter_custom_cursor/flutter_custom_cursor.dart'
;
import
'../common.dart'
;
import
'../common/shared_state.dart'
;
...
...
@@ -351,7 +352,7 @@ class ImageModel with ChangeNotifier {
// my throw exception, because the listener maybe already dispose
update
(
image
,
tabBarHeight
);
}
catch
(
e
)
{
p
rint
(
'update image:
$e
'
);
debugP
rint
(
'update image:
$e
'
);
}
});
}
...
...
@@ -594,11 +595,36 @@ class CanvasModel with ChangeNotifier {
}
}
// data for cursor
class
CursorData
{
final
String
peerId
;
final
int
id
;
final
Uint8List
?
data
;
final
double
hotx
;
final
double
hoty
;
final
int
width
;
final
int
height
;
late
String
key
;
CursorData
({
required
this
.
peerId
,
required
this
.
id
,
required
this
.
data
,
required
this
.
hotx
,
required
this
.
hoty
,
required
this
.
width
,
required
this
.
height
,
})
{
key
=
'
${peerId}
_
${id}
_
${(hotx * 10e6).round().toInt()}
_
${(hoty * 10e6).round().toInt()}
_
${width}
_
$height
'
;
}
}
class
CursorModel
with
ChangeNotifier
{
ui
.
Image
?
_image
;
final
_images
=
<
int
,
Tuple3
<
ui
.
Image
,
double
,
double
>>{};
Uint8List
?
_pngData
;
final
_
pngs
=
<
int
,
Uint8List
?
>{};
CursorData
?
_cacheLinux
;
final
_
cacheMapLinux
=
<
int
,
CursorData
>{};
double
_x
=
-
10000
;
double
_y
=
-
10000
;
double
_hotx
=
0
;
...
...
@@ -609,7 +635,7 @@ class CursorModel with ChangeNotifier {
WeakReference
<
FFI
>
parent
;
ui
.
Image
?
get
image
=>
_image
;
Uint8List
?
get
pngData
=>
_pngData
;
CursorData
?
get
cacheLinux
=>
_cacheLinux
;
double
get
x
=>
_x
-
_displayOriginX
;
...
...
@@ -623,6 +649,9 @@ class CursorModel with ChangeNotifier {
CursorModel
(
this
.
parent
);
List
<
String
>
get
cachedKeysLinux
=>
_cacheMapLinux
.
values
.
map
((
v
)
=>
v
.
key
).
toList
();
// remote physical display coordinate
Rect
getVisibleRect
()
{
final
size
=
MediaQueryData
.
fromWindow
(
ui
.
window
).
size
;
...
...
@@ -763,13 +792,7 @@ class CursorModel with ChangeNotifier {
if
(
parent
.
target
?.
id
!=
pid
)
return
;
_image
=
image
;
_images
[
id
]
=
Tuple3
(
image
,
_hotx
,
_hoty
);
final
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
png
);
if
(
data
!=
null
)
{
_pngData
=
data
.
buffer
.
asUint8List
();
}
else
{
_pngData
=
null
;
}
_pngs
[
id
]
=
_pngData
;
_updateCacheLinux
(
image
,
id
,
width
,
height
);
try
{
// my throw exception, because the listener maybe already dispose
notifyListeners
();
...
...
@@ -780,8 +803,28 @@ class CursorModel with ChangeNotifier {
});
}
void
_updateCacheLinux
(
ui
.
Image
image
,
int
id
,
int
w
,
int
h
)
async
{
final
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
png
);
late
Uint8List
?
dataLinux
;
if
(
data
!=
null
)
{
dataLinux
=
data
.
buffer
.
asUint8List
();
}
else
{
dataLinux
=
null
;
}
_cacheLinux
=
CursorData
(
peerId:
this
.
id
,
data:
dataLinux
,
id:
id
,
hotx:
_hotx
,
hoty:
_hoty
,
width:
w
,
height:
h
,
);
_cacheMapLinux
[
id
]
=
_cacheLinux
!;
}
void
updateCursorId
(
Map
<
String
,
dynamic
>
evt
)
{
_
pngData
=
_pngs
[
int
.
parse
(
evt
[
'id'
])];
_
cacheLinux
=
_cacheMapLinux
[
int
.
parse
(
evt
[
'id'
])];
final
tmp
=
_images
[
int
.
parse
(
evt
[
'id'
])];
if
(
tmp
!=
null
)
{
_image
=
tmp
.
item1
;
...
...
@@ -828,6 +871,17 @@ class CursorModel with ChangeNotifier {
_x
=
-
10000
;
_image
=
null
;
_images
.
clear
();
_clearCacheLinux
();
_cacheLinux
=
null
;
_cacheMapLinux
.
clear
();
}
void
_clearCacheLinux
()
{
final
cachedKeys
=
[...
cachedKeysLinux
];
for
(
var
key
in
cachedKeys
)
{
customCursorController
.
freeCache
(
key
);
}
}
}
...
...
@@ -871,7 +925,9 @@ class QualityMonitorModel with ChangeNotifier {
_data
.
codecFormat
=
evt
[
'codec_format'
];
}
notifyListeners
();
}
catch
(
e
)
{}
}
catch
(
e
)
{
//
}
}
}
...
...
@@ -1230,7 +1286,7 @@ class FFI {
Future
<
Map
<
String
,
String
>>
getHttpHeaders
()
async
{
return
{
'Authorization'
:
'Bearer
'
+
await
bind
.
mainGetLocalOption
(
key:
'access_token'
)
'Bearer
${await bind.mainGetLocalOption(key: 'access_token')}
'
};
}
}
...
...
flutter/pubspec.yaml
View file @
9b694cba
...
...
@@ -71,7 +71,7 @@ dependencies:
flutter_custom_cursor
:
git
:
url
:
https://github.com/Kingtous/rustdesk_flutter_custom_cursor
ref
:
7fe78c139c711bafbae52d924e9caf18bd193e28
ref
:
9021e21de36c84edf01d5034f38eda580463163b
get
:
^4.6.5
visibility_detector
:
^0.3.3
contextmenu
:
^3.0.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment