desktop get mouse control by big distance
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
03e041001c
commit
8984d16c75
@ -42,6 +42,7 @@ class InputModel {
|
|||||||
// mouse
|
// mouse
|
||||||
final isPhysicalMouse = false.obs;
|
final isPhysicalMouse = false.obs;
|
||||||
int _lastMouseDownButtons = 0;
|
int _lastMouseDownButtons = 0;
|
||||||
|
Offset last_mouse_pos = Offset.zero;
|
||||||
|
|
||||||
get id => parent.target?.id ?? "";
|
get id => parent.target?.id ?? "";
|
||||||
|
|
||||||
@ -303,6 +304,22 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleMouse(Map<String, dynamic> evt) {
|
void handleMouse(Map<String, dynamic> evt) {
|
||||||
|
double x = evt['x'];
|
||||||
|
double y = max(0.0, evt['y']);
|
||||||
|
final cursorModel = parent.target!.cursorModel;
|
||||||
|
|
||||||
|
if (!cursorModel.got_mouse_control) {
|
||||||
|
bool self_get_control = (x - last_mouse_pos.dx).abs() > 12 ||
|
||||||
|
(y - last_mouse_pos.dy).abs() > 12;
|
||||||
|
if (self_get_control) {
|
||||||
|
cursorModel.got_mouse_control = true;
|
||||||
|
} else {
|
||||||
|
last_mouse_pos = ui.Offset(x, y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last_mouse_pos = ui.Offset(x, y);
|
||||||
|
|
||||||
var type = '';
|
var type = '';
|
||||||
var isMove = false;
|
var isMove = false;
|
||||||
switch (evt['type']) {
|
switch (evt['type']) {
|
||||||
@ -319,8 +336,6 @@ class InputModel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
evt['type'] = type;
|
evt['type'] = type;
|
||||||
double x = evt['x'];
|
|
||||||
double y = max(0.0, evt['y']);
|
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
y = y - stateGlobal.tabBarHeight;
|
y = y - stateGlobal.tabBarHeight;
|
||||||
}
|
}
|
||||||
|
@ -740,6 +740,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
double _hoty = 0;
|
double _hoty = 0;
|
||||||
double _displayOriginX = 0;
|
double _displayOriginX = 0;
|
||||||
double _displayOriginY = 0;
|
double _displayOriginY = 0;
|
||||||
|
bool got_mouse_control = true;
|
||||||
String id = '';
|
String id = '';
|
||||||
WeakReference<FFI> parent;
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
@ -748,13 +749,11 @@ class CursorModel with ChangeNotifier {
|
|||||||
CursorData? get defaultCache => _getDefaultCache();
|
CursorData? get defaultCache => _getDefaultCache();
|
||||||
|
|
||||||
double get x => _x - _displayOriginX;
|
double get x => _x - _displayOriginX;
|
||||||
|
|
||||||
double get y => _y - _displayOriginY;
|
double get y => _y - _displayOriginY;
|
||||||
|
|
||||||
Offset get offset => Offset(_x, _y);
|
Offset get offset => Offset(_x, _y);
|
||||||
|
|
||||||
double get hotx => _hotx;
|
double get hotx => _hotx;
|
||||||
|
|
||||||
double get hoty => _hoty;
|
double get hoty => _hoty;
|
||||||
|
|
||||||
CursorModel(this.parent);
|
CursorModel(this.parent);
|
||||||
@ -981,6 +980,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
|
|
||||||
/// Update the cursor position.
|
/// Update the cursor position.
|
||||||
updateCursorPosition(Map<String, dynamic> evt, String id) async {
|
updateCursorPosition(Map<String, dynamic> evt, String id) async {
|
||||||
|
got_mouse_control = false;
|
||||||
_x = double.parse(evt['x']);
|
_x = double.parse(evt['x']);
|
||||||
_y = double.parse(evt['y']);
|
_y = double.parse(evt['y']);
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user