window_manager icon indicating copy to clipboard operation
window_manager copied to clipboard

macOS fullscreen blocking content

Open edeuss opened this issue 3 years ago • 19 comments

When making the window full screen (green expand button), there seems to be a bar blocking content.

If I disable windows manager, the issue goes away.

Screenshots Not Fullscreen: Screen Shot 2022-06-21 at 4 57 35 PM

Fullscreen: Screen Shot 2022-06-21 at 4 54 44 PM

Fullscreen on top hover: Screen Shot 2022-06-21 at 4 54 56 PM

edeuss avatar Jun 22 '22 23:06 edeuss

Is there any example code? I think this is a macOS bug, what is your operating system environment?

d1y avatar Sep 09 '22 19:09 d1y

Original issue: https://github.com/GroovinChip/macos_ui/issues/266

damywise avatar Oct 23 '22 09:10 damywise

I can reproduce this issue with these steps:

  1. Add latest window_manager to pubpspec.yaml
  2. Replace macos/Runner/MainFlutterWindow.swift with https://github.com/GroovinChip/macos_ui#modern-window-look
  3. Initialize windowManager using await windowManager.ensureInitialized();

Minimal main.dart code:

import 'package:flutter/cupertino.dart';
import 'package:window_manager/window_manager.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      title: 'Flutter Demo',
      home: Text('test'),
    );
  }
}

damywise avatar Oct 23 '22 10:10 damywise

The problem is, this line in the modified macos/Runner/MainFlutterWindow.swift

self.toolbar?.isVisible = false

It's supposed to hide to toolbar when going to fullscreen, but it isn't working as expected. It just doesn't do anything

damywise avatar Nov 06 '22 06:11 damywise

Found a fix: add these line to WindowManager.swift

    public func windowWillEnterFullScreen(_ notification: Notification) {
        mainWindow.toolbar?.isVisible = false
    }

and this line

        mainWindow.toolbar?.isVisible = true

after

    public func windowDidExitFullScreen(_ notification: Notification){

Also, you can remove

  func windowWillEnterFullScreen(_ notification: Notification) {
      self.toolbar?.isVisible = false
  }
  
  func windowDidExitFullScreen(_ notification: Notification) {
      self.toolbar?.isVisible = true
  }

from macos/Runner/MainFlutterWindow.swift since it's useless as of now

damywise avatar Nov 06 '22 07:11 damywise

Note that this is only a temporary fix for this specific use case and I'm not experienced enough in swift to make a pull request for this issue

damywise avatar Nov 06 '22 07:11 damywise

@edeuss

damywise avatar Nov 06 '22 07:11 damywise

@damywise may I ask you to make a fork and add this temporary fix to it?

It will help people who need to fix it right now :)

Maksimka101 avatar Nov 09 '22 18:11 Maksimka101

@Maksimka101 here you go window_manager_issue171

damywise avatar Nov 10 '22 05:11 damywise

I guess another way to solve it is to implement new method like hideToolbar/showToolbar and simply calling them when window is entering/leaving full screen

damywise avatar Nov 10 '22 06:11 damywise

https://github.com/alexmercerind/flutter_acrylic has a new feature:Window.addToolbar and Window.setToolbarStyle which should eliminate the need for this temporary fix. https://github.com/alexmercerind/flutter_acrylic/issues/43

damywise avatar Nov 28 '22 02:11 damywise

However, we also need to execute Window.removeToolbar() inside onWindowEnterFullScreen and Window.addToolbar() inside onWindowLeaveFullscreen

Note that currently, the function onWindowEnterFullScreen uses windowDidEnterFullScreen instead of windowWillEnterFullScreen, which is what I used in the temporary fix. This makes the transition between normal and full screen not smooth since the empty toolbar will be shown for ~2 seconds (during the transition).

damywise avatar Nov 28 '22 02:11 damywise

public func windowWillEnterFullScreen(_ notification: Notification) {
       mainWindow.toolbar?.isVisible = false
}

@damywise It works for me but it causes the buttons to shift the the top corner:

Before: Screenshot 2023-02-13 at 1 11 57 PM

After: Screenshot 2023-02-13 at 1 10 22 PM

edeuss avatar Feb 13 '23 21:02 edeuss

Oh yeah please don't do that anymore. Use macos_window_utils instead

damywise avatar Feb 13 '23 23:02 damywise

Please check https://github.com/leanflutter/window_manager/pull/319 if you are still affected by this.

cbenhagen avatar Mar 25 '23 14:03 cbenhagen

You can test my proposed fix with this in your pubspec.yaml:

  window_manager:
    git:
      url: https://github.com/cbenhagen/window_manager
      ref: hide_toolbar

cbenhagen avatar Mar 25 '23 14:03 cbenhagen

@cbenhagen Your proposed fix works for me, thanks a lot

edeuss avatar Mar 30 '23 01:03 edeuss

@edeuss

Before: Screenshot 2023-02-13 at 1 11 57 PM

How did you set this padding for traffic lights? Is this an old behavior of this framework? Trying to understand if I can get this with WindowManager or if I need something else.

(Right now I'm getting the version with the buttons glued to the corner).

luizv avatar Oct 31 '23 17:10 luizv

@luizv You don't even need any plugin for that. You can modify the macos/Runner/MainFlutterWindow.swift file as mentioned here in the macos_uidocumentation: https://github.com/macosui/macos_ui#modern-window-look.

However, I recommend using the macos_window_utils package for most macOS window-related tasks because it allows for more programmatic control.

If macos_window_utils doesn't have the specific functionality you need, you can use window_manager as a complementary tool. That's what I do, at least.

damywise avatar Nov 01 '23 02:11 damywise