fix mouse jumping: query GDK pointer position at call time

Flutter's globalPosition is window-relative, not screen-absolute.
Now using gdk_device_get_position() on the native side to get
the actual screen coordinates at the moment startDrag/startResize
is called. Dart no longer passes coordinates — the native handler
queries the pointer directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 09:47:44 +02:00
co-authored by Claude Opus 4.6
parent 5debc57d31
commit fa0adb0998
5 changed files with 20 additions and 27 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ class _HatBar extends StatelessWidget {
Widget build(BuildContext context) {
final tokens = ClideTheme.of(context).surface;
return GestureDetector(
onPanStart: (d) => kernel.window.startDrag(d.globalPosition),
onPanStart: (_) => kernel.window.startDrag(),
child: Container(
height: hatHeight,
decoration: BoxDecoration(
+4 -11
View File
@@ -17,24 +17,17 @@ class WindowControls extends ChangeNotifier {
notifyListeners();
}
Future<void> startResize(ResizeEdge edge, Offset screenPosition) async {
Future<void> startResize(ResizeEdge edge) async {
try {
await _channel.invokeMethod('startResize', {
'edge': edge.index,
'x': screenPosition.dx.round(),
'y': screenPosition.dy.round(),
});
await _channel.invokeMethod('startResize', edge.index);
} on MissingPluginException {
// no-op
}
}
Future<void> startDrag(Offset screenPosition) async {
Future<void> startDrag() async {
try {
await _channel.invokeMethod('startDrag', {
'x': screenPosition.dx.round(),
'y': screenPosition.dy.round(),
});
await _channel.invokeMethod('startDrag');
} on MissingPluginException {
// no-op
}
+1 -1
View File
@@ -33,7 +33,7 @@ class ColumnHat extends StatelessWidget {
Widget build(BuildContext context) {
final tokens = ClideTheme.of(context).surface;
return GestureDetector(
onPanStart: (d) => windowControls.startDrag(d.globalPosition),
onPanStart: (_) => windowControls.startDrag(),
child: Container(
height: hatHeight,
color: tokens.panelHeader,
+1 -1
View File
@@ -45,7 +45,7 @@ class ClideResizeBorder extends StatelessWidget {
return MouseRegion(
cursor: cursor,
child: GestureDetector(
onPanStart: (d) => windowControls.startResize(edge, d.globalPosition),
onPanStart: (_) => windowControls.startResize(edge),
child: const ColoredBox(color: Color(0x00000000)),
),
);