fix can't use mouse on remote multi screen

This commit is contained in:
csf 2022-09-29 18:56:47 +08:00
parent cae2c2942e
commit 1d04eda6f5
2 changed files with 15 additions and 12 deletions

View File

@ -314,7 +314,7 @@ class _RemotePageState extends State<RemotePage> {
icon: Icon(Icons.tv), icon: Icon(Icons.tv),
onPressed: () { onPressed: () {
setState(() => _showEdit = false); setState(() => _showEdit = false);
showOptions(widget.id, gFFI.dialogManager); showOptions(context, widget.id, gFFI.dialogManager);
}, },
) )
] + ] +
@ -446,8 +446,9 @@ class _RemotePageState extends State<RemotePage> {
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy); gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
inputModel.sendMouse('down', MouseButtons.left); inputModel.sendMouse('down', MouseButtons.left);
} else { } else {
final cursorX = gFFI.cursorModel.x; final offset = gFFI.cursorModel.offset;
final cursorY = gFFI.cursorModel.y; final cursorX = offset.dx;
final cursorY = offset.dy;
final visible = final visible =
gFFI.cursorModel.getVisibleRect().inflate(1); // extend edges gFFI.cursorModel.getVisibleRect().inflate(1); // extend edges
final size = MediaQueryData.fromWindow(ui.window).size; 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'; String quality = await bind.sessionGetImageQuality(id: id) ?? 'balanced';
if (quality == '') quality = 'balanced'; if (quality == '') quality = 'balanced';
String codec = String codec =
@ -902,12 +904,16 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
width: 40, width: 40,
height: 40, height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.black87), border: Border.all(color: Theme.of(context).hintColor),
color: i == cur ? Colors.black87 : Colors.white), borderRadius: BorderRadius.circular(2),
color: i == cur
? Theme.of(context).toggleableActiveColor.withOpacity(0.6)
: null),
child: Center( child: Center(
child: Text((i + 1).toString(), child: Text((i + 1).toString(),
style: TextStyle( style: TextStyle(
color: i == cur ? Colors.white : Colors.black87)))))); color: i == cur ? Colors.white : Colors.black87,
fontWeight: FontWeight.bold))))));
} }
displays.add(Padding( displays.add(Padding(
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),

View File

@ -110,11 +110,11 @@ class InputModel {
RawKeyEventDataLinux newData = e.data as RawKeyEventDataLinux; RawKeyEventDataLinux newData = e.data as RawKeyEventDataLinux;
scanCode = newData.scanCode; scanCode = newData.scanCode;
keyCode = newData.keyCode; keyCode = newData.keyCode;
} else if (e.data is RawKeyEventDataAndroid){ } else if (e.data is RawKeyEventDataAndroid) {
RawKeyEventDataAndroid newData = e.data as RawKeyEventDataAndroid; RawKeyEventDataAndroid newData = e.data as RawKeyEventDataAndroid;
scanCode = newData.scanCode + 8; scanCode = newData.scanCode + 8;
keyCode = newData.keyCode; keyCode = newData.keyCode;
}else { } else {
scanCode = -1; scanCode = -1;
keyCode = -1; keyCode = -1;
} }
@ -357,9 +357,6 @@ class InputModel {
x = 0; x = 0;
y = 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['x'] = '${x.round()}';
evt['y'] = '${y.round()}'; evt['y'] = '${y.round()}';
var buttons = ''; var buttons = '';