Files
clide/lib/widgets/src/clide_resize_border.dart
T
jpmschweitzerandClaude Opus 4.6 fa0adb0998 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>
2026-04-23 09:47:44 +02:00

54 lines
2.1 KiB
Dart

import 'package:clide/kernel/src/window_controls.dart';
import 'package:flutter/widgets.dart';
class ClideResizeBorder extends StatelessWidget {
const ClideResizeBorder({super.key, required this.windowControls, required this.child});
final WindowControls windowControls;
final Widget child;
static const double _edge = 6;
static const double _corner = 12;
@override
Widget build(BuildContext context) {
return Stack(
children: [
Positioned.fill(child: child),
// Corners
_zone(Alignment.topLeft, _corner, _corner, SystemMouseCursors.resizeUpLeft, ResizeEdge.topLeft),
_zone(Alignment.topRight, _corner, _corner, SystemMouseCursors.resizeUpRight, ResizeEdge.topRight),
_zone(Alignment.bottomLeft, _corner, _corner, SystemMouseCursors.resizeDownLeft, ResizeEdge.bottomLeft),
_zone(Alignment.bottomRight, _corner, _corner, SystemMouseCursors.resizeDownRight, ResizeEdge.bottomRight),
// Edges
Positioned(top: _corner, bottom: _corner, left: 0, width: _edge, child: _edgeZone(SystemMouseCursors.resizeLeft, ResizeEdge.left)),
Positioned(top: _corner, bottom: _corner, right: 0, width: _edge, child: _edgeZone(SystemMouseCursors.resizeRight, ResizeEdge.right)),
Positioned(left: _corner, right: _corner, top: 0, height: _edge, child: _edgeZone(SystemMouseCursors.resizeUp, ResizeEdge.top)),
Positioned(left: _corner, right: _corner, bottom: 0, height: _edge, child: _edgeZone(SystemMouseCursors.resizeDown, ResizeEdge.bottom)),
],
);
}
Widget _zone(Alignment alignment, double w, double h, MouseCursor cursor, ResizeEdge edge) {
return Positioned(
left: alignment.x < 0 ? 0 : null,
right: alignment.x > 0 ? 0 : null,
top: alignment.y < 0 ? 0 : null,
bottom: alignment.y > 0 ? 0 : null,
width: w,
height: h,
child: _edgeZone(cursor, edge),
);
}
Widget _edgeZone(MouseCursor cursor, ResizeEdge edge) {
return MouseRegion(
cursor: cursor,
child: GestureDetector(
onPanStart: (_) => windowControls.startResize(edge),
child: const ColoredBox(color: Color(0x00000000)),
),
);
}
}