window_manager icon indicating copy to clipboard operation
window_manager copied to clipboard

[Windows] Fix `flutter_acrylic` compatibility

Open damywise opened this issue 2 years ago • 0 comments

Alright I've been kind of trying to fix this issue. Here's what I found:

  1. WindowEffect.transparent is compatible, no issues there.
  2. TitleBarStyle.hidden is NOT compatible with WindowEffect.mica, WindowEffect.acrylic, and WindowEffect.tabbed. However, this can be workaround by calling Window.setEffect AFTER setTitleBarStyle. For example, this will NOT work:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Window.initialize();
  await windowManager.ensureInitialized();
  
  await Window.setEffect(effect: WindowEffect.tabbed);
  await windowManager.setTitleBarStyle(TitleBarStyle.hidden);

  runApp(const MyApp());

  await windowManager.show();
}

while this will work:


void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Window.initialize();
  await windowManager.ensureInitialized();
  
  await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
  await Window.setEffect(effect: WindowEffect.tabbed);

  runApp(const MyApp());

  await windowManager.show();
}
  1. Similar to above, setFullScreen is NOT compatible with WindowEffect.mica, WindowEffect.acrylic, and WindowEffect.tabbed. However, this can be workaround by calling Window.setEffect AFTER setFullScreen
  2. setAsFrameless() is NOT compatible AT ALL with WindowEffect.mica, WindowEffect.acrylic, and WindowEffect.tabbed. No workaround found yet, probably never. What happens is that since those effects needs the window frame, setAsFrameless will be overridden, or the effects will be overridden, depends on which line is called first.
  3. If TitleBarStyle.hidden, going from WindowEffect.mica, WindowEffect.acrylic, and WindowEffect.tabbed to WindowEffect.transparent results in a white line on the top of the window. The solution is to call setTitleBarStyle(TitleBarStyle.hidden) once again, after calling setWindowEffect(WindowEffect.transparent).
  4. Different WindowEffects will result in different shadow. WindowEffect.mica, WindowEffect.acrylic, and WindowEffect.tabbed has shorter shadow than the rest.
  5. windowManager.setBackgroundColor overrides all WindowEffects

Some Screenshots and Recording

transparent: image

mica: image

video:

https://github.com/leanflutter/window_manager/assets/25608913/01f1466f-4f50-4846-a962-43474e12771b

damywise avatar Aug 09 '23 15:08 damywise