Files
clide/lib/kernel/src/window_controls.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

69 lines
1.5 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
enum ChromeStyle { seam, prompt, inline }
enum ResizeEdge { topLeft, top, topRight, left, right, bottomLeft, bottom, bottomRight }
class WindowControls extends ChangeNotifier {
static const _channel = MethodChannel('clide/window');
ChromeStyle _style = ChromeStyle.seam;
ChromeStyle get style => _style;
void setStyle(ChromeStyle s) {
if (_style == s) return;
_style = s;
notifyListeners();
}
Future<void> startResize(ResizeEdge edge) async {
try {
await _channel.invokeMethod('startResize', edge.index);
} on MissingPluginException {
// no-op
}
}
Future<void> startDrag() async {
try {
await _channel.invokeMethod('startDrag');
} on MissingPluginException {
// no-op
}
}
Future<void> minimize() async {
try {
await _channel.invokeMethod('minimize');
} on MissingPluginException {
// no-op
}
}
Future<void> toggleMaximize() async {
try {
await _channel.invokeMethod('maximize');
} on MissingPluginException {
// no-op
}
}
Future<void> close() async {
try {
await _channel.invokeMethod('close');
} on MissingPluginException {
// no-op
}
}
Future<bool> isMaximized() async {
try {
final result = await _channel.invokeMethod<bool>('isMaximized');
return result ?? false;
} on MissingPluginException {
return false;
}
}
}