From 1d04eda6f53b65de2e312ac707e840d9e84d78a5 Mon Sep 17 00:00:00 2001 From: csf Date: Thu, 29 Sep 2022 18:56:47 +0800 Subject: [PATCH] fix can't use mouse on remote multi screen --- flutter/lib/mobile/pages/remote_page.dart | 20 +++++++++++++------- flutter/lib/models/input_model.dart | 7 ++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index 014266fb8..c5775236a 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -314,7 +314,7 @@ class _RemotePageState extends State { icon: Icon(Icons.tv), onPressed: () { setState(() => _showEdit = false); - showOptions(widget.id, gFFI.dialogManager); + showOptions(context, widget.id, gFFI.dialogManager); }, ) ] + @@ -446,8 +446,9 @@ class _RemotePageState extends State { gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy); inputModel.sendMouse('down', MouseButtons.left); } else { - final cursorX = gFFI.cursorModel.x; - final cursorY = gFFI.cursorModel.y; + final offset = gFFI.cursorModel.offset; + final cursorX = offset.dx; + final cursorY = offset.dy; final visible = gFFI.cursorModel.getVisibleRect().inflate(1); // extend edges final size = MediaQueryData.fromWindow(ui.window).size; @@ -873,7 +874,8 @@ class ImagePainter extends CustomPainter { } } -void showOptions(String id, OverlayDialogManager dialogManager) async { +void showOptions( + BuildContext context, String id, OverlayDialogManager dialogManager) async { String quality = await bind.sessionGetImageQuality(id: id) ?? 'balanced'; if (quality == '') quality = 'balanced'; String codec = @@ -902,12 +904,16 @@ void showOptions(String id, OverlayDialogManager dialogManager) async { width: 40, height: 40, decoration: BoxDecoration( - border: Border.all(color: Colors.black87), - color: i == cur ? Colors.black87 : Colors.white), + border: Border.all(color: Theme.of(context).hintColor), + borderRadius: BorderRadius.circular(2), + color: i == cur + ? Theme.of(context).toggleableActiveColor.withOpacity(0.6) + : null), child: Center( child: Text((i + 1).toString(), style: TextStyle( - color: i == cur ? Colors.white : Colors.black87)))))); + color: i == cur ? Colors.white : Colors.black87, + fontWeight: FontWeight.bold)))))); } displays.add(Padding( padding: const EdgeInsets.only(top: 8), diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index 655757720..21278367f 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -110,11 +110,11 @@ class InputModel { RawKeyEventDataLinux newData = e.data as RawKeyEventDataLinux; scanCode = newData.scanCode; keyCode = newData.keyCode; - } else if (e.data is RawKeyEventDataAndroid){ + } else if (e.data is RawKeyEventDataAndroid) { RawKeyEventDataAndroid newData = e.data as RawKeyEventDataAndroid; scanCode = newData.scanCode + 8; keyCode = newData.keyCode; - }else { + } else { scanCode = -1; keyCode = -1; } @@ -357,9 +357,6 @@ class InputModel { x = 0; y = 0; } - // fix mouse out of bounds - x = min(max(0.0, x), d.width.toDouble()); - y = min(max(0.0, y), d.height.toDouble()); evt['x'] = '${x.round()}'; evt['y'] = '${y.round()}'; var buttons = '';