leanflutter / window_manager

This plugin allows Flutter desktop apps to resizing and repositioning the window.
https://pub.dev/packages/window_manager
MIT License
676 stars 177 forks source link

[macOS]启动App时无法聚焦 #440

Closed Zhoucheng133 closed 4 months ago

Zhoucheng133 commented 4 months ago

设备是macOS 14 Intel的Mac,在以下情况下无法聚焦到窗口:

注:我确定我在主函数中添加了await windowManager.focus();

经过测试:

情况如视频所示:

https://github.com/leanflutter/window_manager/assets/54197427/0c8cc0fb-add8-49fa-a85b-84c95850d0b8

目前有一个折中的方法可以避免问题,就是在initState里调用windowManager.focus();

Future<void> focusTest() async {
  if(await windowManager.isFocused()==false){
    await windowManager.focus();
  }
}

@override
void initState() {
  super.initState();
  windowManager.addListener(this);
  focusTest();
}

但是经过测试会出现窗口闪烁的问题

望解决谢谢

Zhoucheng133 commented 4 months ago

使用vs code的Release模式运行不会出现这个问题