window_manager
window_manager copied to clipboard
Linux 下使用拖动移动窗口、调整窗口尺寸时的问题。
系统: Archlinux 桌面环境:Gnome window_manager 版本:0.2.1
拖动问题
使用 DragToMoveArea
移动窗口时第一次点击拖动有效,第二次会无法拖动(这时需要先点击一下鼠标左键,然后就又可以拖动了)。DragToResizeArea
也有类似的问题。
使用 GestureDetector
在 onPanStart
中调用了 startDragging
方法测试发现:点击鼠标拖动并且松开鼠标后,GestureDetector
的 onPanEnd
一直没有被触发,这时需要点击一下鼠标,触发 onPanEnd
然后才可以进行下一次拖动。
调整大小行为不正确
Linux 下 DragToResizeArea
左下和右下的行为好像不对。请看下面的录屏(里面也包含了第一个问题):
https://user-images.githubusercontent.com/13930715/161481523-ea95bb08-c093-42f3-8f32-5e55bc46b945.mp4
测试代码
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
windowManager.waitUntilReadyToShow().then((_) async {
await windowManager.setMinimumSize(const Size(410, 300));
await windowManager.setSize(const Size(450, 600));
await windowManager.setTitle('Butterfly');
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
await windowManager.setResizable(true);
await windowManager.center();
await windowManager.show();
await windowManager.focus();
});
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: DragToResizeArea(
resizeEdgeColor: Colors.red,
resizeEdgeSize: 20,
child: DragToMoveArea(
child: Container(
color: Colors.blue,
),
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
}
+1 setTitleBarStyle = hidden 时无法缩放窗口大小了
+1
@wxxxcxx 拖动问题已经在 https://github.com/leanflutter/window_manager/pull/203 中修复,请更新到最新版本。
调整尺寸的问题已经 https://github.com/leanflutter/window_manager/pull/205 和 https://github.com/leanflutter/window_manager/pull/209 中修复